WebhooksWebhooks extends WebhooksModel
Webhooks
Table of Contents
Methods
| add() | Adds a new webhook |
| delete() | Deletes an existing webhook |
| edit() | Updates an existing webhook |
| get() | Fetches a single webhook |
| getAll() | Returns a list with all the webhooks for the given type |
| getByCallback() | Fetches a single webhook by the callback and type |
| getByEvent() | Fetches a single webhook by the event and type |
| getEvents() | Returns a list of all available events |
| getList() | Returns a list of webhooks for the given type |
| getMethods() | Returns a list of all available webhook methods |
| getTypeCount() | Returns the number of results available for the given type |
| getTypes() | Returns a list of all available webhook types |
| getRules() | Retrieves the rule set for adding/editing webhooks |
Methods
add()
Adds a new webhook
public
add(array<string|int, mixed> $vars) : mixed
Parameters
- $vars : array<string|int, mixed>
-
An array of webhook info including:
- company_id The ID of company for this webhook
- callback The callback for the webhook, must be a URL for outgoing webhooks or a string for incoming webhooks
- event The name of the event to listen or trigger
- type The type of the webhook, it could be "incoming" or "outgoing"
- method The method of th webhook, it could be "get", "post" or "json"
- fields A numerically indexed array of arrays, each one containing
- field The name of the field from the event
- parameter The new name for the field
Return values
mixed —Returns the ID of the webhook or void on error
delete()
Deletes an existing webhook
public
delete(int $webhook_id) : mixed
Parameters
- $webhook_id : int
-
The ID of the webhook to remove
edit()
Updates an existing webhook
public
edit(int $webhook_id, array<string|int, mixed> $vars) : mixed
Parameters
- $webhook_id : int
-
The ID of the webhook to update
- $vars : array<string|int, mixed>
-
An array of webhook info including:
- company_id The ID of company for this webhook
- callback The callback for the webhook, must be a URL for outgoing webhooks or a string for incoming webhooks
- event The name of the event to listen or trigger
- type The type of the webhook, it could be "incoming" or "outgoing"
- method The method of th webhook, it could be "get", "post" or "json"
- fields A numerically indexed array of arrays, each one containing
- field The name of the field from the event
- parameter The new name for the field
Return values
mixed —Returns the ID of the webhook or void on error
get()
Fetches a single webhook
public
get(int $webhook_id) : array<string|int, mixed>
Parameters
- $webhook_id : int
-
The ID of the webhook to fetch
Return values
array<string|int, mixed> —An array of stdClass objects representing webhooks
getAll()
Returns a list with all the webhooks for the given type
public
getAll([string $type = 'incoming' ][, array<string|int, mixed> $order_by = ['method' => 'DESC'] ]) : array<string|int, mixed>
Parameters
- $type : string = 'incoming'
-
The type of the webhook to filter by (optional, default "incoming"), one of:
- incoming All incoming webhooks
- outgoing All outgoing webhooks
- null All webhooks
- $order_by : array<string|int, mixed> = ['method' => 'DESC']
-
The sort and order conditions (e.g. array('sort_field'=>"ASC"), optional)
Return values
array<string|int, mixed> —An array of stdClass objects representing webhooks
getByCallback()
Fetches a single webhook by the callback and type
public
getByCallback(string $callback[, string $type = 'incoming' ]) : array<string|int, mixed>
Parameters
- $callback : string
-
The callback of the webhook
- $type : string = 'incoming'
-
The type of webhook (optional)
Return values
array<string|int, mixed> —An array of stdClass objects representing webhooks
getByEvent()
Fetches a single webhook by the event and type
public
getByEvent(string $event[, string $type = 'incoming' ]) : array<string|int, mixed>
Parameters
- $event : string
-
The event of the webhook
- $type : string = 'incoming'
-
The type of webhook (optional)
Return values
array<string|int, mixed> —An array of stdClass objects representing webhooks
getEvents()
Returns a list of all available events
public
getEvents() : array<string|int, mixed>
Return values
array<string|int, mixed> —A list of webhook types
getList()
Returns a list of webhooks for the given type
public
getList([string $type = 'incoming' ][, int $page = 1 ][, array<string|int, mixed> $order_by = ['method' => 'DESC'] ]) : array<string|int, mixed>
Parameters
- $type : string = 'incoming'
-
The type of the webhook to filter by (optional, default "incoming"), one of:
- incoming All incoming webhooks
- outgoing All outgoing webhooks
- $page : int = 1
-
The page to return results for (optional, default 1)
- $order_by : array<string|int, mixed> = ['method' => 'DESC']
-
The sort and order conditions (e.g. array('sort_field'=>"ASC"), optional)
Return values
array<string|int, mixed> —An array of stdClass objects representing webhooks
getMethods()
Returns a list of all available webhook methods
public
getMethods() : array<string|int, mixed>
Return values
array<string|int, mixed> —A list of webhook methods
getTypeCount()
Returns the number of results available for the given type
public
getTypeCount([string $type = 'incoming' ]) : int
Parameters
- $type : string = 'incoming'
-
The type of the webhook to filter by (optional, default "incoming"), one of:
- incoming All incoming webhooks
- outgoing All outgoing webhooks
Return values
int —The number representing the total number of services for this client with that status
getTypes()
Returns a list of all available webhook types
public
getTypes() : array<string|int, mixed>
Return values
array<string|int, mixed> —A list of webhook types
getRules()
Retrieves the rule set for adding/editing webhooks
private
getRules(array<string|int, mixed> &$vars[, bool $edit = false ]) : array<string|int, mixed>
Parameters
- $vars : array<string|int, mixed>
-
An array of input fields
- $edit : bool = false
-
Whether or not this is an edit request
Return values
array<string|int, mixed> —The rules