# fomo-nodejs-sdk

> Fomo NodeJS SDK for Fomo service

Latest version **1.1.0** (published 2018-10-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install fomo-nodejs-sdk
pnpm add fomo-nodejs-sdk
yarn add fomo-nodejs-sdk
bun add fomo-nodejs-sdk
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2018-10-08 |
| First published | 2016-08-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.10 |
| Dependencies | 0 |
| Unpacked size | 19 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Fomo |
| Maintainers | fomo |

## Links

- npm: https://www.npmjs.com/package/fomo-nodejs-sdk
- Repository: https://github.com/usefomo/fomo-nodejs-sdk
- Homepage: https://github.com/usefomo/fomo-nodejs-sdk#readme
- Issues: https://github.com/usefomo/fomo-nodejs-sdk/issues
- npm.io page: https://npm.io/package/fomo-nodejs-sdk

## Recent versions

- 1.1.0 (latest) — 2018-10-08
- 1.0.8 — 2017-06-10
- 1.0.7 — 2017-05-31
- 1.0.6 — 2016-11-14
- 1.0.5 — 2016-09-30
- 1.0.4 — 2016-09-30
- 1.0.3 — 2016-09-01
- 1.0.2 — 2016-08-19
- 1.0.1 — 2016-08-10
- 1.0.0 — 2016-08-10

## README

Fomo-NodeJS-SDK
================

*Fomo NodeJS SDK* is the official SDK wrapper for the [Fomo API service](https://fomo.com)

API docs: [https://docs.fomo.com](https://docs.fomo.com)

Requirements
------------

- NodeJS 0.10+

User Installation
-----------------

```bash
$ npm install fomo-nodejs-sdk
```

Initialize Fomo client:

```javascript
var FomoClient = require('fomo-nodejs-sdk');
var client = new FomoClient('<token>');
```

Create a new event with template name:

```javascript
var basicEvent = client.FomoEventBasic();
basicEvent.event_type_tag = 'new_order'; // Event type tag is found on Fomo dashboard (Templates -> Template name)
basicEvent.title = 'Test event';
basicEvent.first_name = 'Ryan';
basicEvent.email_address = 'ryan.kulp@fomo.com'; // used to fetch Gravatar for notification images
basicEvent.ip_address = '128.177.108.102'; // used to extract location parameters (city, province, country)
basicEvent.city = 'Atlanta';
basicEvent.url = 'https://fomo.com';

// Add event custom attribute value
basicEvent.addCustomEventField('variable_name', 'value');

client.createEvent(basicEvent, function (savedEvent) {
  console.log(savedEvent);
});
```

or with template ID:

```javascript
var basicEvent = client.FomoEventBasic();
basicEvent.event_type_id = '4'; // Event type ID is found on Fomo dashboard (Templates -> Template ID)
basicEvent.title = 'Test event';
basicEvent.first_name = 'Ryan';
basicEvent.email_address = 'ryan.kulp@fomo.com';
basicEvent.url = 'https://fomo.com';

// Add event custom attribute value
basicEvent.addCustomEventField('variable_name', 'value');

client.createEvent(basicEvent, function (savedEvent) {
  console.log(savedEvent);
});
```

Fetch an event:

```javascript
client.getEvent('<id>', function (event) {
  console.log(event);
});
```

Get all events:

```javascript
client.getEvents(function(events) {
  console.log(events);
});
```

Get all events with meta:

```javascript
client.getEventsWithMeta(function(data) {
  console.log(data.events);
  console.log(data.meta);
}, 30 /* page size */, 1 /* page number */);
```

Delete an event:

```javascript
client.deleteEvent("<id>", function(response) {
  console.log(response);
});
```

Update an event:

```javascript
client.getEvent('<id>', function (event) {
  console.log(event);
  event.first_name = 'John';
  client.updateEvent(event, function(updatedEvent) {
      console.log(updatedEvent);
  });
});
```

If you have questions, email us at [hello@fomo.com](mailto:hello@fomo.com).

---
_Source: https://npm.io/package/fomo-nodejs-sdk · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
