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
Variants
Caven edited this page Jan 31, 2024
·
1 revision
Retrieves the variant with the given ID.
import { type Variant, getVariant } from '@heybrostudio/lemonsqueezy.js'
const variantId = 234567
const { statusCode, error, data } = await getVariant(variantId)
With related resources:
import { type GetVariantParams, type Variant, getVariant } from '@heybrostudio/lemonsqueezy.js'
const variantId = 234567
const { statusCode, error, data } = await getVariant(variantId, { include: ['product'] })
/**
* Retrieve a variant.
*
* @param variantId The given variant id.
* @param [params] (Optional) Additional parameters.
* @param [params.include] (Optional) Related resources.
* @returns A variant object.
*/
declare function getVariant(variantId: number | string, params?: GetVariantParams): Promise<FetchResponse<Variant>>
Returns a variant object.
{
statusCode: number | null
error: Error | null
data: Variant | null
}
Returns a paginated list of variants.
import { type ListVariants, listVariants } from '@heybrostudio/lemonsqueezy.js'
const { statusCode, error, data } = await listVariants()
With filter:
import { type ListVariants, type ListVariantsParams, listVariants } from '@heybrostudio/lemonsqueezy.js'
const { statusCode, error, data } = await listVariants({ filter: { productId: 234567 } })
With pagination:
import { type ListVariants, type ListVariantsParams, listVariants } from '@heybrostudio/lemonsqueezy.js'
const { statusCode, error, data } = await listVariants({ page: { number: 1, size: 10 } })
With related resources:
import { type ListVariants, type ListVariantsParams, listVariants } from '@heybrostudio/lemonsqueezy.js'
const { statusCode, error, data } = await listVariants({ include: ['product'] })
/**
* List all variants
*
* @param [params] (Optional) Additional parameters.
* @param [params.filter] (Optional) Filter parameters.
* @param [params.filter.productId] (Optional) Only return variants belonging to the product with this ID.
* @param [params.filter.status] (Optional) Only return variants with this status.
* @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 variant objects ordered by `sort`.
*/
declare function listVariants(params?: ListVariantsParams): Promise<FetchResponse<ListVariants>>
Returns a paginated list of variant objects ordered by sort.
{
statusCode: number | null
error: Error | null
data: ListVariants | null
}