@bilipay/openapi-core
TypeScript icon, indicating that this package has built-in type declarations

1.0.9 • Public • Published

@bilipay/openapi-core

The SDK of Client API.

NPM version

Installation

Install it and write into package.json dependences.

$ npm install @bilipay/openapi-core -S

Prerequisite

Node.js >= 8.x

Usage

The ROA style client:

var Client = require('@bilipay/openapi-core').Client;

var client = new Client({
  accessKeyId: '<accessKeyId>',
  accessKeySecret: '<accessKeySecret>',
  endpoint: '<endpoint>',
  apiVersion: '<apiVersion>'
});

// => returns Promise
client.request(url, options);
// co/yield, async/await

// options
client.request(url, {
  timeout: 3000, // default 3000 ms
  method: 'GET', // set the http method, default is GET
  headers: {}, // set the http request headers
});

Custom opts

We offer two ways to customize request opts.

One way is passing opts through the Client constructor. You should treat opts passed through the constructor as default custom opts, because all requests will use this opts.

var client = new Client({
  accessKeyId: '<accessKeyId>',
  accessKeySecret: '<accessKeySecret>',
  opts: {
    timeout: 3000
  }
});

Another way is passing opts through the function's parameter. You should use this way when you want to just pass opts in specific functions.

client.request(url, {
  timeout: 3000
});

When both ways are used, opts will be merged. But for the opt with the same key, the opts provided by the function parameter overrides the opts provided by the constructor.

Http Proxy Support

var tunnel = require('tunnel-agent');

var Client = require('@bilipay/openapi-core').Client;

var client = new Client({
  accessKeyId: '<accessKeyId>',
  accessKeySecret: '<accessKeySecret>'
});


client.request(url, {
  agent: tunnel.httpOverHttp({
    proxy: {
      host: 'host',
      port: port
    }
  });
});

License

The MIT License

Readme

Keywords

Package Sidebar

Install

npm i @bilipay/openapi-core

Weekly Downloads

4

Version

1.0.9

License

MIT

Unpacked Size

33.9 kB

Total Files

8

Last publish

Collaborators

  • killheaven
  • pony.ma.bilipay