-
Notifications
You must be signed in to change notification settings - Fork 0
Topics
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
@forGET /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
@forGET /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:configurationsdecodes as/v1/modules/1/configurations(ModulesService) -
service:rates/controller:schedules/id:1/verb:periods/action:currentdecodes as/v1/rates/schedules/1/periods/current(RatesService) -
service:facilities/user_id:1decodes as/v1/facilities?user_id=1(FacilitiesService)