Class: WebhookClient
Defined in: rest/v2/webhooks/client.ts:40
Constructors
Constructor
new WebhookClient(
oauth):WebhookClient
Defined in: rest/v2/webhooks/client.ts:65
Parameters
| Parameter | Type |
|---|---|
oauth | PatreonOauthClient |
Returns
WebhookClient
Properties
| Property | Modifier | Type | Default value | Description |
|---|---|---|---|---|
oauth | public | PatreonOauthClient | undefined | - |
payloads | public | typeof WebhookPayloadClient | WebhookPayloadClient | - |
headers | static | { event: "X-Patreon-Event"; signature: "X-Patreon-Signature"; } | undefined | The headers that are sent on webhook requests |
headers.event | readonly | "X-Patreon-Event" | 'X-Patreon-Event' | - |
headers.signature | readonly | "X-Patreon-Signature" | 'X-Patreon-Signature' | - |
Methods
createWebhook()
createWebhook(
webhook,options?):Promise<WriteResourceResponse<Webhook>>
Defined in: rest/v2/webhooks/client.ts:75
Creates a new webhook owned by this client.
Parameters
| Parameter | Type | Description |
|---|---|---|
webhook | WebhookAPICreateBody | The webhook data: uri, event triggers and the campaign of the events |
options? | Oauth2WebhookRouteOptions | Request options |
Returns
Promise<WriteResourceResponse<Webhook>>
the API response from Patreon: either the created webhook on success or undefined when failed.
deleteWebhook()
deleteWebhook(
webhookId,options?):Promise<void>
Defined in: rest/v2/webhooks/client.ts:152
Delete a webhook created by this client
Parameters
| Parameter | Type | Description |
|---|---|---|
webhookId | string | The webhook id |
options? | Oauth2WebhookRouteOptions | Request options |
Returns
Promise<void>
editWebhook()
editWebhook(
webhook,options?):Promise<WriteResourceResponse<Webhook>>
Defined in: rest/v2/webhooks/client.ts:124
Edit the webhook, created by this client, attributes
Parameters
| Parameter | Type | Description |
|---|---|---|
webhook | WebhookAPIEditBody | The data to edit |
options? | Oauth2WebhookRouteOptions | Request options |
Returns
Promise<WriteResourceResponse<Webhook>>
The updated webhook or undefined when failed to update
fetchWebhooks()
fetchWebhooks<
Query>(query,options?):Promise<GetResponsePayload<Query>>
Defined in: rest/v2/webhooks/client.ts:111
Fetch webhooks created by this client
Type Parameters
| Type Parameter |
|---|
Query extends BasePatreonQueryType<Webhook, true> |
Parameters
| Parameter | Type | Description |
|---|---|---|
query | Query | The query to fetch attributes and relationships |
options? | Oauth2WebhookRouteOptions | Request options |
Returns
Promise<GetResponsePayload<Query>>
the webhooks managed by this client
hasUnsentEvents()
hasUnsentEvents(
webhook):boolean
Defined in: rest/v2/webhooks/client.ts:170
Check if the webhook should be unpaused as events have failed to send.
If true, you can call unpauseWebhook.
Parameters
| Parameter | Type | Description |
|---|---|---|
webhook | Webhook | The webhook to check for unsent events |
Returns
boolean
whether the webhook has failed events that can be resent
pauseWebhook()
pauseWebhook(
webhookId,options?):Promise<WriteResourceResponse<Webhook>>
Defined in: rest/v2/webhooks/client.ts:180
To temporarily pause events, such as when updating servers or deploying a new version.
Parameters
| Parameter | Type | Description |
|---|---|---|
webhookId | string | The webhook to pause events for |
options? | Oauth2WebhookRouteOptions | Request options |
Returns
Promise<WriteResourceResponse<Webhook>>
the updated (paused) webhook
unpauseWebhook()
unpauseWebhook(
webhookId,options?):Promise<WriteResourceResponse<Webhook>>
Defined in: rest/v2/webhooks/client.ts:196
Continue sending events to this webhook.
Parameters
| Parameter | Type | Description |
|---|---|---|
webhookId | string | The webhook to unpause events for |
options? | Oauth2WebhookRouteOptions | Request options |
Returns
Promise<WriteResourceResponse<Webhook>>
the updated (unpaused) webhook
getWebhookHeaders()
staticgetWebhookHeaders(headers):Record<"signature"|"event",null|string>
Defined in: rest/v2/webhooks/client.ts:53
Parameters
| Parameter | Type |
|---|---|
headers | RestHeaders |
Returns
Record<"signature" | "event", null | string>