This repository has been archived by the owner on Feb 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Webhooks
Caven edited this page Jan 31, 2024
·
1 revision
Create a webhook.
import { type NewWebhook, type Webhook, createWebhook } from '@heybrostudio/lemonsqueezy.js'
const storeId = 123456
const { statusCode, error, data } = await createWebhook(storeId, {
url: 'https://google.com/webhooks',
events: ['subscription_created', 'subscription_cancelled'],
secret: 'SUBSCRIPTION_SECRET',
})
/**
* Create a webhook.
*
* @param storeId The store id.
* @param webhook a new webhook info.
* @returns A webhook object.
*/
declare function createWebhook(storeId: number | string, webhook: NewWebhook): Promise<FetchResponse<Webhook>>
Returns a webhook object.
{
statusCode: number | null
error: Error | null
data: Webhook | null
}
Update a webhook.
import { type UpdateWebhook, type Webhook, updateWebhook } from '@heybrostudio/lemonsqueezy.js'
const webhookId = 456789
const { statusCode, error, data } = await updateWebhook(webhookId, { url: 'https://google.com/webhooks2' })
/**
* Update a webhook.
*
* @param webhookId The webhook id.
* @param webhook The webhook info you want to update.
* @returns A webhook object.
*/
declare function updateWebhook(webhookId: number | string, webhook: UpdateWebhook): Promise<FetchResponse<Webhook>>
Returns a webhook object.
{
statusCode: number | null
error: Error | null
data: Webhook | null
}
Delete a webhook with the given ID.
import { deleteWebhook } from '@heybrostudio/lemonsqueezy.js'
const webhookId = 456789
const { statusCode, error, data } = await deleteWebhook(webhookId)
/**
* Delete a webhook.
*
* @param webhookId The webhook id.
* @returns A `204` status code and `No Content` response on success.
*/
declare function deleteWebhook(webhookId: number | string): Promise<FetchResponse<null>>
Returns a status code 204
and No Content
response on success.
{
statusCode: number | null
error: Error | null
data: null
}
Retrieves the webhook with the given ID.
import { type Webhook, getWebhook } from '@heybrostudio/lemonsqueezy.js'
const { statusCode, error, data } = await getWebhook()
With related resources:
import { type Webhook, type GetWebhookParams, getWebhook } from '@heybrostudio/lemonsqueezy.js'
const { statusCode, error, data } = await getWebhook({ include: ['store'] })
/**
* Retrieve a webhook.
*
* @param webhookId The given webhook id.
* @param [params] (Optional) Additional parameters.
* @param [params.include] (Optional) Related resources.
* @returns A webhook object.
*/
declare function getWebhook(webhookId: number | string, params?: GetWebhookParams): Promise<FetchResponse<Webhook>>
Returns a webhook object.
{
statusCode: number | null
error: Error | null
data: Webhook | null
}
Returns a paginated list of webhooks.
import { type ListWebhooks, listWebhooks } from '@heybrostudio/lemonsqueezy.js'
const { statusCode, error, data } = await listWebhooks()
With filter:
import { type ListWebhooks, type ListWebhooksParams, listWebhooks } from '@heybrostudio/lemonsqueezy.js'
const { statusCode, error, data } = await listWebhooks({ filter: { storeId: 123456 } })
With pagination:
import { type ListWebhooks, type ListWebhooksParams, listWebhooks } from '@heybrostudio/lemonsqueezy.js'
const { statusCode, error, data } = await listWebhooks({ page: { number: 1, size: 10 } })
With related resources:
import { type ListWebhooks, type ListWebhooksParams, listWebhooks } from '@heybrostudio/lemonsqueezy.js'
const { statusCode, error, data } = await listWebhooks({ include: ['store'] })
/**
* List all webhooks.
*
* @param [params] (Optional) Additional parameters.
* @param [params.filter] (Optional) Filter parameters.
* @param [params.filter.storeId] (Optional) Only return webhooks belonging to the store with this ID.
* @param [params.page] (Optional) Custom paginated queries.
* @param [params.page.number] (Optional) The parameter determine which page to retrieve.
* @param [params.page.size] (Optional) The parameter to determine how many results to return per page.
* @param [params.include] (Optional) Related resources.
* @returns A paginated list of webhook objects ordered by `created_at`.
*/
declare function listWebhooks(params?: ListWebhooksParams): Promise<FetchResponse<ListWebhooks>>
Returns a paginated list of subscription objects ordered by created_at
(descending).
{
statusCode: number | null
error: Error | null
data: ListWebhooks | null
}