1.0.4 • Published 1 year ago

dc_rest_js v1.0.4

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

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 your dist directory
  • lint Runs ESlint and Prettier
  • cypress:run Runs e2e tests in headless mode
  • cypress: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 given id through GET method.
  • create(entity): will create a new entity through POST method.
  • update(entity): will update the given entity through PUT method.
  • del(entity): will delete the provided entity through DELETE method.
  • patch(entity): will update the given entity through PATCH method.

All these methods returns promises.

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago