Class: BusinessEndpoint

BusinessEndpoint

BusinessEndpoint is the main interaction class against non-resourceful sequoia endpoints.

Business endpoints are simple rest-like endpoints. Due to the nature of them, this SDK is not (currently) intending to provide anything other than simple validation for paths and query strings. Objects are just the plain JSON returned from the service, unlike ResourcefulEndpoint which will send back ResourceCollection and Resources.

This class should not be used directly, but should instead be obtained from ServiceDescriptor#businessEndpoint


<private> new BusinessEndpoint(transport, business)

Parameters:
Name Type Description
transport Transport

Transport instance to use for fetching

business Object

JSON object describing this business endpoint (fetched from sequoia services 'descriptor')

Source:
Example
// `contents` is used in the rest of the examples as our reference
// to a ResourcefulEndpoint
let feeds;

client.generate().then(() => {
  client.service('feed').then((service) => {
    // Get a business endpoint (this is synchronous as the service passed
    // all the necessary data):
    feeds = service.businessEndpoint('feeds', { name: 'UTV-15246' });
    // whatever
  });
});

Members


requiredQueryParameterNames :Array.<string>

Returns an array of query parameter names

Type:
  • Array.<string>
Source:
Example
// Returns e.g.
['currency', 'price']

requiredQueryParameters :Array.<object>

Required query parameters for the business endpoint from the routes['name'].inputs.query portion of the descriptor

Returns the raw objects

Type:
  • Array.<object>
Source:
Example
// Returns e.g.
[{
  "type": "name",
  "meta": [{
    "sequoiaType": "name"
    }],
  "invalids": ["" ],
  "name": "count",
  "required": false
 },
 {
   "type": "string",
   "description": "language to localise response to",
   "invalids": [""],
   "name": "lang",
   "required": false
 }]

Methods


<private> criteriaToQuery(criteria)

Return a query string to append to the HTTP call. Will default to appending ?owner=<owner>

Parameters:
Name Type Argument Description
criteria string | Query <nullable>

A (potential) query string to append to the request

Source:
Throws:

InvalidCriteriaException

Returns:
Type
string

<private> endPointUrl(criteria)

Get the full URL to the business endpoint/item we will send the request to

Parameters:
Name Type Argument Description
criteria string | Query <nullable>

A (potential) query string to append to the request

Source:
See:
Throws:

InvalidCriteriaException

Returns:
Type
string

fetch(criteria, options)

Perform an action against the business endpoint. Note, the HTTP method comes from the routes['name'].method portion of the descriptor

Parameters:
Name Type Description
criteria string | Query

A query string to append to the request

options object

fetch options

Source:
See:
Throws:

InvalidCriteriaException

Returns:
  • JSON returned from the endpoint
Type
Promise