Skip to content
Ionut Moraru edited this page Mar 16, 2015 · 3 revisions

Topics are used in the events library library to allow to call API endpoints.

Topics are encoded using a specific structure which essentially maps to an AngularJS resource. The service component has to be added first in the topic name.

If the topic is used to GET data and the response will be an object, the service has to be prefixed with @. If the response will be an array, the service should not be prefixed by @.

Example:

  • Do not prepend @ for GET /v1/modules/1/configurations (service:modules/id:1/controller:configurations) which returns:
[{
  "id":1,
  "type":"string",
  "key":"name",
  "value":"Table Module",
  "created_at":"2015-01-28T08:47:32.298Z",
  "updated_at":"2015-01-28T08:47:32.298Z"
}]
  • Prepend @ for GET /v1/modules/1 (@service:modules/id:1) which returns:
{
  "id":1,
  "slug":"table-module",
  "placeholder":"1",
  "version":"0.0.1",
  "created_at":"2015-01-28T08:47:32.298Z",
  "updated_at":"2015-01-28T08:47:49.000Z"
}

Mapping Examples:

  • service:modules/id:1/controller:configurations decodes as /v1/modules/1/configurations (ModulesService)
  • service:rates/controller:schedules/id:1/verb:periods/action:current decodes as /v1/rates/schedules/1/periods/current (RatesService)
  • service:facilities/user_id:1 decodes as /v1/facilities?user_id=1 (FacilitiesService)

Clone this wiki locally