bas
basecrm
npm i basecrm
bas

basecrm

Base CRM client for NodeJS

by Yury Paleev

0.1.3 (see all)License:MITTypeScript:Not Found
npm i basecrm
Readme

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.

Downloads/wk

7

GitHub Stars

11

LAST COMMIT

5yrs ago

MAINTAINERS

1

CONTRIBUTORS

4

OPEN ISSUES

2

OPEN PRs

0
VersionTagPublished
0.1.3
latest
5yrs ago
No alternatives found
No tutorials found
Add a tutorial