Class: Client

Client~Client(endpoint, apiToken, signingKey, options)

Handles sending API requests

Constructor

new Client(endpoint, apiToken, signingKey, options)

Client Constructor.

Client Constructor.

Parameters:
Name Type Description
endpoint URL | string
apiToken string
signingKey string
options Object
Source:
See:

Members

(static, constant) SIGN_DIGEST_NONE

Constant SIGN_DIGEST_NONE

.

Constant SIGN_DIGEST_NONE

Source:

(static, constant) SIGN_DIGEST_SHA1

Constant SIGN_DIGEST_SHA1

.

Constant SIGN_DIGEST_SHA1

Source:

(static, constant) SIGN_DIGEST_SHA256

Constant SIGN_DIGEST_SHA256

.

Constant SIGN_DIGEST_SHA256

Source:

Methods

createRequest(name, modelnullable)

Create a Request object by name.

Create a Request object by name.

Parameters:
Name Type Attributes Default Description
name string
model Model <nullable>
null
Source:
Throws:
Error

generateAuthHeader(data) → {string}

Generates the authentication header value.

Generates the authentication header value.

Parameters:
Name Type Description
data string
Source:
Returns:
Type
string

getApiToken() → {string}

Get the api token used to authenticate the request.

Get the api token used to authenticate the request.

Source:
Returns:
Type
string

getEndpoint() → {URL}

Get the API endpoint URL.

Get the API endpoint URL.

Source:
Returns:
Type
URL

getOption(key) → {*}

Get a client option.

Get a client option.

Parameters:
Name Type Description
key string
Source:
Returns:
Type
*

getSigningKey() → {string}

Get the signing key used to sign requests.

Get the signing key used to sign requests. Base64 encoded.

Source:
Returns:
Type
string

promise(request) → {Promise}

Queue a Request object for a Promise.

Queue a Request object for a Promise.

Parameters:
Name Type Description
request Request
Source:
Returns:
Type
Promise

send(request, callback) → {void}

Send a Request object with callback.

Send a Request object with callback.

Parameters:
Name Type Description
request Request
callback Client~sendCallback
Source:
Throws:

When an invalid callback is supplied

Type
Error
Returns:
Type
void

sendLowLevel(data, callback) → {http.ClientRequest|https.ClientRequest}

Send an low level API request with callback.

Send an low level API request with callback.

Parameters:
Name Type Description
data Object
callback Client~sendLowLevelCallback
Source:
Returns:
Type
http.ClientRequest | https.ClientRequest

setApiToken(apiToken) → {Client}

Set the api token used to authenticate the request.

Set the api token used to authenticate the request.

Parameters:
Name Type Description
apiToken string
Source:
Returns:
Type
Client

setEndpoint(endpoint) → {Client}

Set the API endpoint URL.

Set the API endpoint URL.

Parameters:
Name Type Description
endpoint URL | string
Source:
Returns:
Type
Client

setOption(key, value) → {Client}

Set a client option.

Set a client option.

Parameters:
Name Type Description
key string
value *
Source:
Returns:
Type
Client

setSigningKey(signingKey) → {Client}

Set the signing key used to sign requests.

Set the signing key used to sign requests. Base64 encoded.

Parameters:
Name Type Description
signingKey string
Source:
Returns:
Type
Client