Node wrapper for the Fomo API
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
.gitignore
README.md
package.json
tests.js

README.md

Fomo-NodeJS-SDK

Fomo NodeJS SDK is the official SDK wrapper for the Fomo API service

API docs: https://docs.fomo.com

Requirements

  • NodeJS 0.10+

User Installation

$ npm install fomo-nodejs-sdk

Initialize Fomo client:

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

Create a new event with template name:

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:

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:

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

Get all events:

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

Get all events with meta:

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

Delete an event:

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

Update an event:

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.