Get unlimited public & private packages + team-based management with npm Teams.Learn more »

fsm-sdk

1.0.0-rc6 • Public • Published

NodeJS FSM-SDK to Interface with Coresystems APIs and Services.

Find more documentation and related information at Coresystems API Documentation

Some illustrative cases are provided in the examples folder.


Build Status Coverage Status

npm version

Getting started

install from NPM

npm i fsm-sdk --save

using the sdk with credentials:

const fsm = require('fsm-sdk');
 
const client = new fsm.CoreAPIClient({
 
  // [mandatory] your client configuration
  clientIdentifier: '<your-clientIdentifier>',
  clientSecret: '<your-clientSecret>',
  clientVersion: '<your-clientVersion>',
 
  // [mandatory] your auth & account configuration
  authAccountName: '<your-authAccountName>',
  authUserName: '<your-authUserName>',
  authPassword: '<your-authPassword>',
 
  // [optional] provide verbose logs
  debug: true,
 
  // [optional] enable using custom oauthEndpoints
  oauthEndpoint: 'https://ds.coresuite.com/api/oauth2/v1',
 
  // [optional] client will cache token (helpful for writing integration tests)
  tokenCacheFilePath: './.myToken.json'
 
});

related doc's:


CoreAPIClient

The CoreAPIClient will return a Promise and is asynchronous by default.

Query for objects using CoreSQL

Provides the [coreSQL] and the [dtos] used in the query see Query API Documentation

 
const coreSQL =
  `SELECT
    sc.id,
    sc.subject
  FROM
    ServiceCall sc
  WHERE
   sc.id = '36A5626F65A54FE7911F536C501D151A'
  `;
 
await client.query(coreSQL, ['ServiceCall']);

CRUD object

related doc's:

Create a new object

const serviceCall = {
   id: fsm.CoreAPIClient.createUUID(), // => 36A5626F65A54FE7911F536C501D151A
   ...
};
 
await client.post('ServiceCall', serviceCall);

Read object by id

await client.getById('ServiceCall', '36A5626F65A54FE7911F536C501D151A');

Update object (providing full new version)

await client.put('ServiceCall', { ... });

Update object (providing only fields to change)

await client.patch('ServiceCall', {
    id: '36A5626F65A54FE7911F536C501D151A',
    subject: 'update-only-subject',
    lastChanged: 1535712340
  });

Delete object

await client.deleteById('ServiceCall', {
    id: '36A5626F65A54FE7911F536C501D151A',
    lastChanged: 1535712340
  });
lastChanged

The lastChanged field is used for optimistic locking. It's like a version-key you have to provide in order to update an object.

Keywords

none

Install

npm i fsm-sdk

DownloadsWeekly Downloads

4

Version

1.0.0-rc6

License

MIT

Unpacked Size

39 kB

Total Files

29

Last publish

Collaborators

  • avatar