dc_rest_js
v1.0.4
Published
Delivery Chain JavaScript REST Library
Readme
Delivery Chain API SDK
Getting Started
Delivery Chain API SDK is implemented using TypeScript and all services available return promises.
Creating the Client
Create a new instance of DCAgent client with your configuration(configuration object)
const DCAgent = new DCAgent({
host: 'http://localhost:8000',
cache: true,//by default its false
});Accounts
Get Account
Get the account record identified by your authorization token.
DCAgent
.accounts()
.get()
.then(accountData => {
// Process accountData here
});Also, you can send a set of parameters to perform the same operation:
const params = {
email: '',
given_name: '',
nickname: '',
//... other parameters
};
DCAgent
.accounts()
.get(params)
.then(accountData => {
// Process accountData here
});Development Quickstart
Install dependencies
yarn installor
npm installScripts
buildBuilds your api library and outpus it in yourdistdirectorylintRuns ESlint and Prettiercypress:runRuns e2e tests in headless modecypress:openRuns e2e tests opening Electron window
Implementation Details
This API library uses a TypeScript-based fetch wrapper, which returns a Promise<ResponseModel> for every HTTP method.
In order to have a better understanding of all available methods, it defines a set of services to make HTTP calls:
Services verbs
As a development convention, this API library uses the following verbs into Services implementation:
get(id): will find the entity with givenidthroughGETmethod.create(entity): will create a new entity throughPOSTmethod.update(entity): will update the given entity throughPUTmethod.del(entity): will delete the provided entity throughDELETEmethod.patch(entity): will update the given entity throughPATCHmethod.
All these methods returns promises.
