1.0.4 • Published 1 year ago
dc_rest_js v1.0.4
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 install
or
npm install
Scripts
build
Builds your api library and outpus it in yourdist
directorylint
Runs ESlint and Prettiercypress:run
Runs e2e tests in headless modecypress:open
Runs 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 givenid
throughGET
method.create(entity)
: will create a new entity throughPOST
method.update(entity)
: will update the given entity throughPUT
method.del(entity)
: will delete the provided entity throughDELETE
method.patch(entity)
: will update the given entity throughPATCH
method.
All these methods returns promises.