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 = ; const 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;
Update Product
Update your product. First parameter is the product SKU; second is a list of properties to update.
clyde;
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;
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;
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;
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;
Get Order
Get an order that has already been placed. The order ID from your system is the first and only parameter.
clyde;
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;
Get Contract Sale
Get a previously sold contract sale. The ID returned from the original sale is the first and only parameter.
clyde;
Cancel Contract Sale
Cancel a previously sold contract sale. The ID returned from the original sale is the first and only parameter.
clyde;
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; catche // Handle error
OR
clyde;
License
MIT