TidyHQWebhook

new TidyHQWebhook(webhookId, signingKey)

This class is used to listen and act on Webhooks.
Parameters:
NameTypeDescription
webhookIdstringThe ID of the webhook.
signingKeystringThe signing key for the webhook.

Members

callbacks :Record.<string, function()>

Type:
  • Record.<string, function()>

Methods

handleEvent(event, data)

Parameters:
NameTypeDescription
eventstring
dataobject

parseHeader(header, scheme) → {Object|null}

Parameters:
NameTypeDescription
headerstring | null | undefined
schemestring
Returns:
Type: 
Object | null

registerCallback(event, callback)

Parameters:
NameTypeDescription
eventstring
callbackfunction

(async) verify(tidySignatureHeader, body, httpMethod) → {Promise.<Tidy_V2_WebhookMessage>}

Verify a message from TidyHQ.
Parameters:
NameTypeDefaultDescription
tidySignatureHeaderstringThe signature header from TidyHQ.
bodystringThe raw body of the message.
httpMethodstringPOSTThe HTTP method of the webhook.
Returns:
- The message from the webhook.
Type: 
Promise.<Tidy_V2_WebhookMessage>

verifyAndHandle(tidySignatureHeader, body, httpMethod) → {void|string}

Verify a message from TidyHQ.
Parameters:
NameTypeDefaultDescription
tidySignatureHeaderstringThe signature header from TidyHQ.
bodystringThe raw body of the message.
httpMethodstringPOSTThe HTTP method of the webhook.
Returns:
- If an error occurs, the error message is returned.
Type: 
void | string