1.1.0 • Published 6 years ago

fomo-nodejs-sdk v1.1.0

Weekly downloads
69
License
MIT
Repository
github
Last release
6 years ago

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.

1.1.0

6 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago