Home
Softono
BaseCRM

BaseCRM

Open source MIT JavaScript
15
Stars
8
Forks
3
Issues
4
Watchers
9 years
Last Commit

About BaseCRM

# BaseCRM BaseCRM Official API V2 library client for NodeJS ## Installation $ npm install basecrm ## Usage ```javascript var BaseCRM = require('basecrm'); ``` ### Build __Using this api without authentication gives an error__ ```javascript // 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. - [Account](https://github.com/yurypaleev/BaseCRM/blob/master/src/account/README.md "API Documentation") - [Associated Contacts](https://github.com/yurypaleev/BaseCRM/blob/master/src/associated_contacts/README.md "API Documentation") - [Contacts](https://github.com/yurypaleev/BaseCRM/blob/master/src/contacts/README.md "API Docume ...

Platforms

Web Self-hosted

Languages

JavaScript

Links

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.