Delivery Chain API SDK is implemented using TypeScript and all services available return promises.
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
});
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
});
Install dependencies
yarn install
or
npm install
-
build
Builds your api library and outpus it in yourdist
directory -
lint
Runs ESlint and Prettier -
cypress:run
Runs e2e tests in headless mode -
cypress:open
Runs e2e tests opening Electron window
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:
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.