@paramander/ois-api-node
v2.4.15
Published
Omnichannel Integration Suite API client
Downloads
56
Keywords
Readme
OIS Node.js Library
The OIS Node library provides convenient access to the OIS API from applications written in server-side JavaScript.
Documentation
See the OIS REST API docs,
Requirements
Node 14 or higher. Uses ES modules.
Installation
Install the package with:
npm install @paramander/ois-api-node
# or
yarn add @paramander/ois-api-node
Usage
The package needs to be configured with your account's access token, which you should generate using OAuth credentials flow, via Auth0.com
Use Auth0 to retrieve your token by POST
ing
to https://divide.eu.auth0.com//oauth/token with the Auth0 client ID and client secret
provided to you by Divide.
const { createOisClient } = require("@paramander/ois-api-node");
const client = createOisClient({
apiKey: "<auth0 access token>",
});
const { data: catalog } = client.catalog.list().then((response) => {
const { data: catalog } = response;
catalog.forEach((product) => {
console.log(product.id);
});
});
Or using ES modules and async
/await
:
import { createOisClient } from "@paramander/ois-api-node";
const client = createOisClient({
apiKey: "<auth0 access token>",
});
(async () => {
const { data: catalog } = await client.catalog.list();
catalog.forEach((product) => {
console.log(product.id);
});
})();
Configuration
The package can be initialized with several options:
const client = createOisClient({
apiKey: "<insert here>",
apiVersion: "v1",
timeout: 15 * 1000, // 15 seconds
host: "https://production-app.azurewebsites.net", // change the OIS API URL",
locale: "en-US", // Use a default locale, can be overridden with each request
});
Development
Run all tests:
npm install
npm test
Run a single test in watch mode:
npm run mocha test/createOisClient.spec.js -- --grep 'succeeds with apiKey' --watch
Run prettier:
Add an editor integration or:
npm run fix