Class WebhookManager
Webhook manager. Queues webhooks and processes them on a background queue using the ISystemWebhookPlugin and ICustomWebhookPlugin.
Namespace: SuperOffice.CRM.Webhooks
Assembly: SoDataBase.dll
Syntax
[SoInject("Database")]
public class WebhookManager : Object
Methods
DeleteWebhook(Int32)
Remove a given webhook from storage.
Declaration
public void DeleteWebhook(int id)
Parameters
Type | Name | Description |
---|---|---|
Int32 | id |
GetAllWebhooks(String, String, String, Nullable<WebhookState>)
Return all the stored webhooks.
Declaration
public IEnumerable<Webhook> GetAllWebhooks(string name = null, string eventName = null, string appToken = null, Nullable<WebhookState> state = null)
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. |
Nullable<WebhookState> | state | Optional state to filter list of webhooks on. |
Returns
Type | Description |
---|---|
IEnumerable<Webhook> | List of webhooks (that are listening to eventName, in state, with given name) |
GetCurrent()
Return the current webhook manager instance. It uses a SuperOffice.CRM.Webhooks.WebhookCache and a WebhookDispatcher to process webhooks on a background thread.
Declaration
public static WebhookManager GetCurrent()
Returns
Type | Description |
---|---|
WebhookManager | The one and only webhook manager. |
GetLastError(Int32)
Return the most recent error message received when calling this webhook.
Declaration
public string GetLastError(int webhookId)
Parameters
Type | Name | Description |
---|---|---|
Int32 | webhookId | Webhook to get error message for |
Returns
Type | Description |
---|---|
String | Error message, or NULL if no errors received |
GetWebhook(Int32)
Get a single webhook by id
Declaration
public Webhook GetWebhook(int id)
Parameters
Type | Name | Description |
---|---|---|
Int32 | id | primary key for webhook |
Returns
Type | Description |
---|---|
Webhook | The given webhook, or NULL if no found |
SaveWebhook(Webhook)
Store/Create a webhook.
Declaration
public Webhook SaveWebhook(Webhook webhook)
Parameters
Type | Name | Description |
---|---|---|
Webhook | webhook | webhook to store. Create new hook if id=0 |
Returns
Type | Description |
---|---|
Webhook | Updated webhook, with primary key set. |
SignalEvent(String, Int32, String, IDictionary<String, Object>, Int32)
Asynchronously inform all interested webhooks that an event has occurred. In other words, we don't block on calls here. This method will return before the webhooks finish processing.
Declaration
public void SignalEvent(string eventName, int primaryKey, string entityName, IDictionary<string, object> changes, int associateId)
Parameters
Type | Name | Description |
---|---|---|
String | eventName | |
Int32 | primaryKey | id |
String | entityName | "contact", "sale", etc |
IDictionary<String, Object> | changes | Dictionary of changed fields "name", "country_id" mapped to the new values. |
Int32 | associateId | User id who triggered event. |
TestWebhook(Webhook)
Test invoke a webhook with a PING event to see if it works.
Declaration
public WebhookResponse TestWebhook(Webhook webhook)
Parameters
Type | Name | Description |
---|---|---|
Webhook | webhook | webhook definition |
Returns
Type | Description |
---|---|
WebhookResponse | True if the webhook invocation worked, False if we did not get 200 OK. NULL is treated as failure. |
WaitForWebhooksToComplete()
Webhook manager. Queues webhooks and processes them on a background queue using the ISystemWebhookPlugin and ICustomWebhookPlugin.
Declaration
public static void WaitForWebhooksToComplete()