Show / Hide Table of Contents

Class DefaultWebhookPlugin

Default webhook plugin. The plugin handles broadcasting the HTTP hooks to subscribing systems, and saving and storing the plugin info in the local database.

Inheritance
object
DefaultWebhookPlugin
Implements
ISystemWebhookPlugin
ICustomWebhookPlugin
IDisposable
Inherited Members
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
Namespace: SuperOffice.CRM.Webhooks
Assembly: SoDataBase.BusinessLogic.dll
Syntax
[SystemWebhookPlugin("Default", 2147483647)]
public class DefaultWebhookPlugin : ISystemWebhookPlugin, ICustomWebhookPlugin, IDisposable
Remarks

Actual broadcast of webhook events is in the NotifyAsync(Webhook, WebhookPayload, CancellationToken) method. REST webhooks are notified through the IWebhookTransmitter. Other webhooks are notified through their own plugins, classes parallel to this one. The rest of the code is about defining and administration of the definitions of webhooks.

Constructors

DefaultWebhookPlugin(IWebhookTransmitter, ILogger<DefaultWebhookPlugin>)

Default webhook plugin. The plugin handles broadcasting the HTTP hooks to subscribing systems, and saving and storing the plugin info in the local database.

Declaration
public DefaultWebhookPlugin(IWebhookTransmitter webhookTransmitter, ILogger<DefaultWebhookPlugin> logger)
Parameters
Type Name Description
IWebhookTransmitter webhookTransmitter
ILogger<DefaultWebhookPlugin> logger
Remarks

Actual broadcast of webhook events is in the NotifyAsync(Webhook, WebhookPayload, CancellationToken) method. REST webhooks are notified through the IWebhookTransmitter. Other webhooks are notified through their own plugins, classes parallel to this one. The rest of the code is about defining and administration of the definitions of webhooks.

Fields

_webhookTransmitter

Default webhook plugin. The plugin handles broadcasting the HTTP hooks to subscribing systems, and saving and storing the plugin info in the local database.

Declaration
protected readonly IWebhookTransmitter _webhookTransmitter
Field Value
Type Description
IWebhookTransmitter
Remarks

Actual broadcast of webhook events is in the NotifyAsync(Webhook, WebhookPayload, CancellationToken) method. REST webhooks are notified through the IWebhookTransmitter. Other webhooks are notified through their own plugins, classes parallel to this one. The rest of the code is about defining and administration of the definitions of webhooks.

Methods

AddToWebhookCountersAsync(int, int, int, int, string, CancellationToken)

Default webhook plugin. The plugin handles broadcasting the HTTP hooks to subscribing systems, and saving and storing the plugin info in the local database.

Declaration
protected Task AddToWebhookCountersAsync(int webhookId, int numCalls, int numErrors, int numConsecutive, string message, CancellationToken cancellationToken)
Parameters
Type Name Description
int webhookId
int numCalls
int numErrors
int numConsecutive
string message
CancellationToken cancellationToken
Returns
Type Description
Task
Remarks

Actual broadcast of webhook events is in the NotifyAsync(Webhook, WebhookPayload, CancellationToken) method. REST webhooks are notified through the IWebhookTransmitter. Other webhooks are notified through their own plugins, classes parallel to this one. The rest of the code is about defining and administration of the definitions of webhooks.

DeleteWebhookAsync(int, CancellationToken)

Remove a given webhook from storage.

Declaration
public Task DeleteWebhookAsync(int id, CancellationToken cancellationToken = default)
Parameters
Type Name Description
int id
CancellationToken cancellationToken
Returns
Type Description
Task
Remarks

Actual broadcast of webhook events is in the NotifyAsync(Webhook, WebhookPayload, CancellationToken) method. REST webhooks are notified through the IWebhookTransmitter. Other webhooks are notified through their own plugins, classes parallel to this one. The rest of the code is about defining and administration of the definitions of webhooks.

Dispose()

Default webhook plugin. The plugin handles broadcasting the HTTP hooks to subscribing systems, and saving and storing the plugin info in the local database.

Declaration
public void Dispose()
Remarks

Actual broadcast of webhook events is in the NotifyAsync(Webhook, WebhookPayload, CancellationToken) method. REST webhooks are notified through the IWebhookTransmitter. Other webhooks are notified through their own plugins, classes parallel to this one. The rest of the code is about defining and administration of the definitions of webhooks.

Dispose(bool)

Default webhook plugin. The plugin handles broadcasting the HTTP hooks to subscribing systems, and saving and storing the plugin info in the local database.

Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type Name Description
bool disposing
Remarks

Actual broadcast of webhook events is in the NotifyAsync(Webhook, WebhookPayload, CancellationToken) method. REST webhooks are notified through the IWebhookTransmitter. Other webhooks are notified through their own plugins, classes parallel to this one. The rest of the code is about defining and administration of the definitions of webhooks.

GetAllWebhooksAsync(string, string, string, WebhookState?, CancellationToken)

Return all the stored webhooks.

Declaration
public 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)

Remarks

Actual broadcast of webhook events is in the NotifyAsync(Webhook, WebhookPayload, CancellationToken) method. REST webhooks are notified through the IWebhookTransmitter. Other webhooks are notified through their own plugins, classes parallel to this one. The rest of the code is about defining and administration of the definitions of webhooks.

GetLastErrorAsync(int, CancellationToken)

Return most recent error message received from webhook target.

Declaration
public Task<string> GetLastErrorAsync(int id, CancellationToken cancellationToken = default)
Parameters
Type Name Description
int id
CancellationToken cancellationToken
Returns
Type Description
Task<string>

String containing most recent error message received from webhook target.

Remarks

Actual broadcast of webhook events is in the NotifyAsync(Webhook, WebhookPayload, CancellationToken) method. REST webhooks are notified through the IWebhookTransmitter. Other webhooks are notified through their own plugins, classes parallel to this one. The rest of the code is about defining and administration of the definitions of webhooks.

GetWebhookAsync(int, CancellationToken)

Get a single webhook by id

Declaration
public 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 not found

Remarks

Actual broadcast of webhook events is in the NotifyAsync(Webhook, WebhookPayload, CancellationToken) method. REST webhooks are notified through the IWebhookTransmitter. Other webhooks are notified through their own plugins, classes parallel to this one. The rest of the code is about defining and administration of the definitions of webhooks.

NotifyAsync(Webhook, WebhookPayload, CancellationToken)

Send the event to a webhook, and mark failures/success status on the passed webhook objects. Called from the dispatcher on a background thread.

Declaration
public virtual Task<WebhookResponse> NotifyAsync(Webhook webhook, WebhookPayload eventInfo, CancellationToken cancellationToken)
Parameters
Type Name Description
Webhook webhook

Inform the given webhook that the event has occurred.

WebhookPayload eventInfo

Event name, unique id and details

CancellationToken cancellationToken
Returns
Type Description
Task<WebhookResponse>

Success/Failure information. NULL is taken as SUCCESS

Remarks

Actual broadcast of webhook events is in the NotifyAsync(Webhook, WebhookPayload, CancellationToken) method. REST webhooks are notified through the IWebhookTransmitter. Other webhooks are notified through their own plugins, classes parallel to this one. The rest of the code is about defining and administration of the definitions of webhooks.

RecordResultAsync(Webhook, WebhookResponse, CancellationToken)

Default webhook plugin. The plugin handles broadcasting the HTTP hooks to subscribing systems, and saving and storing the plugin info in the local database.

Declaration
public Task RecordResultAsync(Webhook webhook, WebhookResponse result, CancellationToken cancellationToken = default)
Parameters
Type Name Description
Webhook webhook
WebhookResponse result
CancellationToken cancellationToken
Returns
Type Description
Task
Remarks

Actual broadcast of webhook events is in the NotifyAsync(Webhook, WebhookPayload, CancellationToken) method. REST webhooks are notified through the IWebhookTransmitter. Other webhooks are notified through their own plugins, classes parallel to this one. The rest of the code is about defining and administration of the definitions of webhooks.

SaveWebhookAsync(Webhook)

Store/Create a webhook.

Declaration
public 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.

Remarks

Actual broadcast of webhook events is in the NotifyAsync(Webhook, WebhookPayload, CancellationToken) method. REST webhooks are notified through the IWebhookTransmitter. Other webhooks are notified through their own plugins, classes parallel to this one. The rest of the code is about defining and administration of the definitions of webhooks.

TestWebhookAsync(Webhook, CancellationToken)

Test invoke a webhook with a PING event to see if it works. Calls webhook with event "test" on entity "test".

Declaration
public Task<WebhookResponse> TestWebhookAsync(Webhook webhook, CancellationToken cancellationToken)
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.

Remarks

Actual broadcast of webhook events is in the NotifyAsync(Webhook, WebhookPayload, CancellationToken) method. REST webhooks are notified through the IWebhookTransmitter. Other webhooks are notified through their own plugins, classes parallel to this one. The rest of the code is about defining and administration of the definitions of webhooks.

UpdateWebhookStateAsync(int, WebhookState, CancellationToken)

Default webhook plugin. The plugin handles broadcasting the HTTP hooks to subscribing systems, and saving and storing the plugin info in the local database.

Declaration
protected Task UpdateWebhookStateAsync(int webhookId, WebhookState webhookState, CancellationToken cancellationToken)
Parameters
Type Name Description
int webhookId
WebhookState webhookState
CancellationToken cancellationToken
Returns
Type Description
Task
Remarks

Actual broadcast of webhook events is in the NotifyAsync(Webhook, WebhookPayload, CancellationToken) method. REST webhooks are notified through the IWebhookTransmitter. Other webhooks are notified through their own plugins, classes parallel to this one. The rest of the code is about defining and administration of the definitions of webhooks.

Implements

ISystemWebhookPlugin
ICustomWebhookPlugin
IDisposable

Extension Methods

EnumUtil.MapEnums<From, To>(From)
Converters.MapEnums<From, To>(From)
© SuperOffice. All rights reserved.
SuperOffice |  Community |  Release Notes |  Privacy |  Site feedback |  Search Docs |  About Docs |  Contribute |  Back to top