Hooks
Hooks serve the function of extending the possible functionality of the OCS by allowing users to ‘hook’ into events and additional functionality to the events that have been hooked into.
There following properties make up a hook:
Property | Type | Flags | Description |
---|---|---|---|
ID | String | Required | The internal ID used to reference a particular hook throughout the OCS. |
Name | String | Required | The name used to reference a particular hook throughout the OCS GUI. |
Description | String | Optional | A short description of the function of the hook. |
Class | Enum | Required | Sets what will happen when the hook fires. |
Type | Enum | Required | Sets what area of the OCS the hook will bind to. |
Priority | Integer | Required | Within the OCS each hook has a priority, this priority will manage the order in which each hook will fire. Useful if a hook relies on the action of another hook. |
Types of hooks
There are two types of hooks. The type of hook sets the details of how the hook functions and what events the hook is allowed to hook onto.
API
An API hook will bind to events that are related to the fetching and passing of data from the OCS API routes.
There are twenty events that can be listened too:
Event |
---|
Initialisation |
Pre Database Query |
Post Database Query Success |
Post Database Query Failure |
Pre Database Get |
Post Database Get Success |
Post Database Get Failure |
Pre Validate |
Post Validate Success |
Post Validate Failure |
Pre Database Submit |
Post Database Submit Success |
Post Database Submit Failure |
Post Document Access |
Post Rating Success |
Post Rating Failure |
Post Enquire Success |
Post Enquire Failure |
Post Credit Success |
Post Credit Failure |
Tables
Can have zero or more tables attached to a hook.
Hooks will fire only when the API event relates to any table attached to the hook.
Table |
---|
Account |
Account Pairing |
Hierarchy |
Hook |
Lifecycle |
Location |
Policy |
Ratesheet |
Service |
Voucher |
Voucher Batch |
Voucher Generator |
Voucher Type |
Resources
Can have zero or more resource attached to a hook.
Which resource the hook will bind to.
In addition to the following resources, all tables within the tables section are included in the Resource section.
Resource |
---|
Annotation Class |
Hierarchy Class |
Hook Class |
Lifecycle Class |
Policy Class |
Service Class |
Voucher Generator Class |
Annotation |
Bucket |
Bucket Cascade |
Debit |
Enquire |
Hierarchy Item |
Lifecycle State |
Lifecycle State Action |
Lifecycle State Transition |
Location Rating Policy Schedule |
Rate |
Subscription |
Unit Conversion |
Actions
Can have zero or more action assigned to a hook.
The action sets which HTTP method the event must be related too for the hook to fire.
Which event the hook will bind to.
Action |
---|
Query |
Get |
Insert |
Update |
Delete |
Engine
There are seventeen events that can be listened too:
Event |
---|
Initialisation |
Post Lifecycle Transition |
Pre Account Get |
Post Account Get Success |
Post Account Get Failure |
Pre Policy Selection |
Post Policy Selection |
Post Policy Rating Processing |
Post Credit Success |
Post Debit Success |
Post Debit Failure |
Pre Return Response |
Post Bucket Expiry |
Post Session Expiry |
Post Reserve Success |
Post Commit Success |
Post Revoke Success |
There are ten actions available for the Engine hook type:
Action |
---|
Credit |
Debit |
Enquire |
Reserve |
Create Session |
Commit Session |
Revoke Session |
Subscribe |
Lifecycle Event |
Internal |
An engine hook can have zero or more actions.
An engine hook will only fire if the associated event relates to any action assigned to the hook.
Hook Classes
The hook class sets the action that will be run when the hook fires.
There are two different types of hook classes:
Javascript
A javascript hook will run any valid javascript within the properties field when the hook fires.
For the OCS javascript API, look at the technical guide.
JSLEE Notification
A JSLEE notification hook will run a JSLEE notification when the hook is fired.