Class: ResponseAPI

API.ResponseAPI

Singleton class that handle every Response requests.
Author:
  • Bruno Morceli - pirofagista@gmail.com
Source:

Extends

  • ApiBase

Methods

(async) create(responseObj) → {Promise}

Create a Response.
Parameters:
Name Type Description
responseObj Entity.ResponseEntity Response entity instance.
Source:
Returns:
Type
Promise
Example
// create a new response entity.
const responseData = new CannedIO.entity.response(
  null, // id
  'New sell procedure', // title
  'You need to pass all instructions over here...', // response body.
  categoryID,
  ['sell', 'new', 'procedure', 'anything-else'] // tags
);

CannedIO.api.response
.create(responseData)
.then(newResponse => console.log('success:', newResponse.toJSON()))
.catch(error => console.log('something is wrong:', error));

(async) get(responseId) → {Promise}

Get a response by ID.
Parameters:
Name Type Description
responseId string response UUID.
Source:
Returns:
Type
Promise
Example
CannedIO.api.response
.get(responseId)
.then(resp => console.log('success:', resp.toJSON()))
.catch(error => console.log('something is wrong:', error));

(async) list() → {Promise}

Get all active responses.
Source:
Returns:
Type
Promise
Example
CannedIO.api.response
.list()
.then(list => {

  list.forEach((item, index) => {
    console.log('item ' + index + ':', item.toJSON());
  });

})
.catch(error => console.log('something is wrong:', error));

(async) remove(responseId) → {Promise}

Remove a response by ID.
Parameters:
Name Type Description
responseId string response UUID.
Source:
Returns:
Type
Promise
Example
CannedIO.api.response
.remove(responseId)
.then(resp => console.log('success:', resp.toJSON()))
.catch(error => console.log('something is wrong:', error));

(async) update(responseObj) → {Promise}

Update a Response.
Parameters:
Name Type Description
responseObj Entity.ResponseEntity Response entity instance.
Source:
Returns:
Type
Promise
Example
// get a existing response (you can create a new one too)...
existingResponse.title = 'this is my new title';

CannedIO.api.response
.update(existingResponse)
.then(updatedResponse => console.log('success:', updatedResponse.toJSON()))
.catch(error => console.log('something is wrong:', error));