clyde-sdk
TypeScript icon, indicating that this package has built-in type declarations

0.1.8 • Public • Published

Clyde API

A node.js client library for the Clyde API. Head to https://api.joinclyde.com/docs for full documentation.

Install

$ npm install clyde-sdk

Getting started

The module supports all Clyde API Endpoints. For complete information about the API, head to the docs.

All endpoints require a valid clientKey and clientSecret.

const Clyde = require('clyde-sdk');
 
const clyde = new Clyde({
  clientKey: 'ck_your_key',
  clientSecret: 'sk_your_secret',
  isLive: true
});

When testing, set isLive to false and use test keys instead of live keys. This will allow you to test without creating active customers or contracts. When you are done testing, set isLive to true and use your live keys. Note that at this point all contract orders are considered live and valid.

Methods

All methods will return a promise. Feel free to use promises or async / await for control flow. Callbacks are not supported at this time. For a full list of parameters and return types, please see our documentation.

Create Product

Create a product. Please see documentation for available properties.

clyde.createProduct(productProperties).then((results) => {
  // Do something with results
});

Update Product

Update your product. First parameter is the product SKU; second is a list of properties to update.

clyde.updateProduct(exampleSku, productProperties).then((results) => {
  // Do something with results
});

Get One Product

Get only one product. Product SKU is the first parameter; there is an optional second parameter of anIP address for geo-sensitive queries.

clyde.getProduct(exampleSku, optionalIp).then((results) => {
  // Do something with results
});

Get Many Products

Get all products associated with your store. Optionally, you may pass in an opts object with a page number or comma-seperated list of SKUs to retrieve a particular page or a subset of SKUs, as well as an IP address for geo-sensitive queries.

clyde.getProducts(optionalOpts, optionalIp).then((results) => {
  // Do something with results
});

Get Contracts for a Product

Get all available contracts for a product. Product SKU is the first parameter; there is an optional second parameter of anIP address for geo-sensitive queries.

clyde.getContractsForProduct(exampleSku, optionalIp).then((results) => {
  // Do something with results
});

Create Order

Create an order. Use this to create a contract sale or report line items of insurable products for later sales. First parameter is your internal ID for the order; second is a list of options. Please see our documentation for available options.

clyde.createOrder(yourId, orderOptions).then((results) => {
  // Do something with results
});

Get Order

Get an order that has already been placed. The order ID from your system is the first and only parameter.

clyde.getOrder(yourId).then((results) => {
  // Do something with results
});

Cancel Order

Cancel an order you have already placed. Use this to cancel all contract sales, or generally remove from our system all line items associated with an order. The order ID from your system is the first and only parameter.

clyde.cancelOrder(yourId).then((results) => {
  // Do something with results
});

Get Contract Sale

Get a previously sold contract sale. The ID returned from the original sale is the first and only parameter.

clyde.getContractSale(clydeId).then((results) => {
  // Do something with results
});

Cancel Contract Sale

Cancel a previously sold contract sale. The ID returned from the original sale is the first and only parameter.

clyde.cancelContractSale(clydeId).then((results) => {
  // Do something with results
});

Error Handling

When an error occurs clyde-sdk will throw that error. Use try / catch with async / await or .catch() syntax with promises.

try {
  const product = await clyde.createProduct(productOptions);
} catch(e) {
  // Handle error
}

OR

clyde.createProduct(productOptions).then((results) => {
  // Do something with the results
}).catch((error) => {
  // Handle error
});

License

MIT

Dependencies (2)

Dev Dependencies (8)

Package Sidebar

Install

npm i clyde-sdk

Weekly Downloads

0

Version

0.1.8

License

MIT

Unpacked Size

5.73 kB

Total Files

2

Last publish

Collaborators

  • edclyde