Getting started¶
Requirements¶
The Cloud Blue Connect Javascript SDK depends on the following 3rd party packages:
lodash version 4.17.15
node-fetch version 2.6.0
Installation¶
The current stable release of the Connect Javascript SDK is 19.0.5.
To install the Connect Javascript SDK at the command prompt enter:
$ npm install @cloudblueconnect/connect-javascript-sdk --save
Usage¶
The connect-javascript-sdk
allow you to consume the Connect public API
directly or using specialized methods to achieve tasks related to a specific
workflow.
High-level Usage¶
const { ConnectClient, Fulfillment } = require('@cloudblueconnect/connect-javascript-sdk');
const client = new ConnectClient('<api_endpoint>', '<api_key>');
const fulfillment = new Fulfillment(client);
const response = await fulfillment.approveRequestWithTemplate('<request_id>', '<template_id>');
Low-level Usage¶
You can access the API endpoints directly through the ConnectClient
.
The ConnectClient
groups operations by the resource they access.
Create an instance of the ConnectClient class:
const { ConnectClient } = require('@cloudblueconnect/connect-javascript-sdk');
const client = new ConnectClient('<api_endpoint>', '<api_key>');
For example to invoke the list operation for the Product resource:
client.products.list()
.then(products => { console.log(products) });
Or if you prefer the async/await syntax:
const products = await client.products.list();
console.log(products);