1.1.4 • Published 6 years ago

classy-pay-client v1.1.4

Weekly downloads
51
License
MIT
Repository
github
Last release
6 years ago

classy-pay-client

Simple client for Classy Pay.

installation

$ yarn install classy-pay-client

usage

PayClient.request(appId, method, resource, payload, params, callback)

const PayClient = require('classy-pay-client')({
  apiUrl: 'https://pay.classy.org',
  timeout: 10000,
  token: 'YOUR_TOKEN'
  secret: 'YOUR_SECRET'
});

PayClient.get(0, '/transaction/1', (error, result) => {
  if (error) {
    console.log(error);
  } else {
    console.log(result);
  }
});

PayClient.request(0, 'GET', '/transaction/1', null, null, (error, result) => {
  if (error) {
    console.log(error);
  } else {
    console.log(result);
  }
});

Functions

getHeaders(context, method, resource, payload) ⇒ Object

Get all the necessary headers for the request.

Kind: global function
Returns: Object - the headers objects

ParamTypeDescription
contextObjectthe request context
methodStringthe HTTP method for the request
resourceStringthe resource being requested
payloadObjectthe body of the request

getQs(appId, params) ⇒ Object

Build the request query.

Kind: global function
Returns: Object - params for request

ParamTypeDescription
appIdNumberthe pay application id
paramsObjectparams passed by client user

getOptions(context, appId, method, resource, payload, params) ⇒ Object

Get the request options.

Kind: global function
Returns: Object - the options for the request

ParamTypeDescription
contextObjectthe request context
appIdNumberthe pay application id
methodStringthe http method
resourceStringthe resource for the request
payloadObjectthe body of the request
paramsObjectthe params provided by the caller

getResult(error, response, body) ⇒ Object

Get the response for http request.

Kind: global function
Returns: Object - a well formed response object

ParamTypeDescription
errorObjectthe error
responseObjectthe http response
bodyObjectthe body of the response

request(context, appId, method, resource, payload, params, callback)

A general Pay request.

Kind: global function

ParamTypeDescription
contextObjectthe context for the request
appIdNumberthe pay application id
methodStringthe http method
resourceStringthe pay resource
payloadObjectthe payload for the request
paramsObjectthe parameters for the request
callbackMethoda callback

getMax(context, appId, resource) ⇒ Number

Retrieve the total number of objects for the resource.

Kind: global function
Returns: Number - the total number of objects for the resource

ParamTypeDescription
contextObjectthe context for the request
appIdNumberthe pay application id
resourceStringthe pay resource

getAll(context, appId, resource, max, collection) ⇒ Promise

Get all the objects for a resource.

Kind: global function
Returns: Promise - a promise when resolved populates the collection

ParamTypeDescription
contextObjectthe context for the request
appIdNumberthe pay application id
resourceStringthe pay resource
maxNumbertotal objects to retrieve
collectionArraythe collection to add objects to

forList(context, appId, resource, callback)

Get all objects.

Kind: global function

ParamTypeDescription
contextObjectthe context for the request
appIdNumberthe pay application id
resourceStringthe pay resource
callbackfunctionthe callback

forObject(context, appId, method, resource, body, callback)

Get an object.

Kind: global function

ParamTypeDescription
contextObjectthe context for the request
appIdNumberthe pay application id
methodStringthe http method
resourceStringthe pay resource
bodyObjectthe body of the request
callbackfunctionthe callback

list(context, appId, resource, callback) ⇒ Array

Get a list of objects for a resource.

Kind: global function
Returns: Array - an array of objects

ParamTypeDescription
contextObjectthe context for the request
appIdNumberthe pay application id
resourceStringthe pay resource
callbackfunctionthe callback

get(context, appId, resource, callback) ⇒ Object

Get an object given a resource.

Kind: global function
Returns: Object - an object

ParamTypeDescription
contextObjectthe context for the request
appIdNumberthe pay application id
resourceStringthe pay resource
callbackfunctionthe callback

post(context, appId, resource, object, callback) ⇒ Object

Create an object at a resource.

Kind: global function
Returns: Object - the created object

ParamTypeDescription
contextObjectthe context for the request
appIdNumberthe pay application id
resourceStringthe pay resource
objectObjectthe object to create
callbackfunctionthe callback

put(context, appId, resource, object, callback) ⇒ Object

Update an object at a resource.

Kind: global function
Returns: Object - the updated object

ParamTypeDescription
contextObjectthe context for the request
appIdNumberthe pay application id
resourceStringthe pay resource
objectObjectthe updated object
callbackfunctionthe callback

del(context, appId, resource, callback) ⇒ Object

Remove an object at a resource.

Kind: global function
Returns: Object - the removed object

ParamTypeDescription
contextObjectthe context for the request
appIdNumberthe pay application id
resourceStringthe pay resource
callbackfunctionthe callback
1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago