Interface ISystemWebhookPlugin
Webhook plugin - there is only one of these per system (as determined by the plugin priority). The plugin handles broadcasting the HTTP hooks to subscribing systems, and saving and storing the plugin info. Plugins must be marked with the CustomWebhookPluginAttribute to be found by the class factory.
Namespace: SuperOffice.CRM.Webhooks
Assembly: SoDataBase.dll
Syntax
public interface ISystemWebhookPlugin : ICustomWebhookPlugin
Methods
DeleteWebhookAsync(int, CancellationToken)
Remove a given webhook from storage.
Declaration
Task DeleteWebhookAsync(int id, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |
GetAllWebhooksAsync(string, string, string, WebhookState?, CancellationToken)
Return all the stored webhooks.
Declaration
Task<IEnumerable<Webhook>> GetAllWebhooksAsync(string name = null, string eventName = null, string appToken = null, WebhookState? state = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Optional name of webhook to filter on. |
| string | eventName | Optional name of event to filter list of webhooks on. Default NULL for no filter. |
| string | appToken | Optional appToken name to filter on. |
| WebhookState? | state | Optional state to filter list of webhooks on. |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<IEnumerable<Webhook>> | List of webhooks (that are listening to eventName) |
GetLastErrorAsync(int, CancellationToken)
Return most recent error message received from webhook target.
Declaration
Task<string> GetLastErrorAsync(int webhookId, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| int | webhookId | webhook definition id |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<string> | String containing most recent error message received from webhook target. |
GetWebhookAsync(int, CancellationToken)
Get a single webhook by id
Declaration
Task<Webhook> GetWebhookAsync(int id, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | primary key for webhook |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<Webhook> | The given webhook, or NULL if no found |
RecordResultAsync(Webhook, WebhookResponse, CancellationToken)
Webhook plugin - there is only one of these per system (as determined by the plugin priority). The plugin handles broadcasting the HTTP hooks to subscribing systems, and saving and storing the plugin info. Plugins must be marked with the CustomWebhookPluginAttribute to be found by the class factory.
Declaration
Task RecordResultAsync(Webhook webhook, WebhookResponse result, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Webhook | webhook | |
| WebhookResponse | result | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |
SaveWebhookAsync(Webhook)
Store/Create a webhook.
Declaration
Task<Webhook> SaveWebhookAsync(Webhook webhook)
Parameters
| Type | Name | Description |
|---|---|---|
| Webhook | webhook | webhook to store. Create new hook if id=0 |
Returns
| Type | Description |
|---|---|
| Task<Webhook> | Updated webhook, with primary key set. |
TestWebhookAsync(Webhook, CancellationToken)
Test invoke a webhook with a PING event to see if it works.
Declaration
Task<WebhookResponse> TestWebhookAsync(Webhook webhook, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Webhook | webhook | webhook definition |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<WebhookResponse> | True if the webhook invocation worked, False if we did not get 200 OK. NULL is treated as failure. |