new TidyHQWebhook(webhookId, signingKey)
This class is used to listen and act on Webhooks.
Parameters:
Name | Type | Description |
---|---|---|
webhookId | string | The ID of the webhook. |
signingKey | string | The signing key for the webhook. |
- Source
Members
callbacks :Record.<string, function()>
Type:
- Record.<string, function()>
- Source
Methods
handleEvent(event, data)
Parameters:
Name | Type | Description |
---|---|---|
event | string | |
data | object |
- Source
parseHeader(header, scheme) → {Object|null}
Parameters:
Name | Type | Description |
---|---|---|
header | string | | |
scheme | string |
- Source
Returns:
- Type:
- Object |
null
registerCallback(event, callback)
Parameters:
Name | Type | Description |
---|---|---|
event | string | |
callback | function |
- Source
(async) verify(tidySignatureHeader, body, httpMethod) → {Promise.<Tidy_V2_WebhookMessage>}
Verify a message from TidyHQ.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
tidySignatureHeader | string | The signature header from TidyHQ. | |
body | string | The raw body of the message. | |
httpMethod | string | POST | The HTTP method of the webhook. |
- Source
Returns:
- The message from the webhook.
- Type:
- Promise.<Tidy_V2_WebhookMessage>
verifyAndHandle(tidySignatureHeader, body, httpMethod) → {void|string}
Verify a message from TidyHQ.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
tidySignatureHeader | string | The signature header from TidyHQ. | |
body | string | The raw body of the message. | |
httpMethod | string | POST | The HTTP method of the webhook. |
- Source
Returns:
- If an error occurs, the error message is returned.
- Type:
- void |
string