Skip to content

yurypaleev/BaseCRM

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BaseCRM

BaseCRM Official API V2 library client for NodeJS

Installation

$ npm install basecrm

Usage

var BaseCRM = require('basecrm');

Build

Using this api without authentication gives an error

//  BaseCRM equal to BaseCRM.Client
var client = new BaseCRM.Client({
  accessToken: '<YOUR_PERSONAL_ACCESS_TOKEN>'
});

Options

The following options are available while instantiating a client:

  • accessToken: Personal access token
  • baseUrl: Base url for the api
  • timeout: Request timeout

Resources documentations

Most of the resources now have a Model API, read the details in the documentations below.

Sync API

The following sample code shows how to perform a full synchronization flow using high-level wrapper.

First of all you need an instance of BaseCRM.Client. High-level BaseCRM.Sync wrapper uses BaseCRM.Sync.Service to interact with the Sync API. In addition to the client instance, you must provide a device’s UUID within deviceUUID parameter. The device’s UUID must not change between synchronization sessions, otherwise the sync service will not recognize the device and will send all the data again.

var client = new BaseCRM.Client({
  accessToken: '<YOUR_PERSONAL_ACCESS_TOKEN>'
});
var sync = new BaseCRM.Sync(client, '<YOUR_DEVICES_UUID>');

Now all you have to do is to call fetch method and pass a block that you might use to store fetched data to a database.

var db = [];
sync.fetch(function(type, action, data) {
  return db.indexOf(type + '_' + JSON.stringify(data)) ? BaseCRM.Sync.ACK : BaseCRM.Sync.NACK;
});

Notice that you must return BaseCRM.Sync.ACK or BaseCRM.Sync.NACK.

License

MIT

Bug Reports

Report here.

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •