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
Products
Caven edited this page Jan 31, 2024
·
2 revisions
Retrieves the product with the given ID.
import { type Product, getProduct } from '@heybrostudio/lemonsqueezy.js'
const productId = 234567
const { statusCode, error, data } = await getProduct(productId)
With related resources:
import { type GetProductParams, type Product, getProduct } from '@heybrostudio/lemonsqueezy.js'
const productId = 234567
const { statusCode, error, data } = await getProduct(productId, { include: ['store'] })
/**
* Retrieve a product.
*
* @param productId The given product id.
* @param [params] (Optional) Additional parameters.
* @param [params.include] (Optional) Related resources.
* @returns A product object.
*/
declare function getProduct(productId: number | string, params?: GetProductParams): Promise<FetchResponse<Product>>
Returns a product object.
{
statusCode: number | null
error: Error | null
data: Product | null
}
Returns a paginated list of products.
import { type ListProducts, listProducts } from '@heybrostudio/lemonsqueezy.js'
const { statusCode, error, data } = await listProducts()
With filter:
import { type ListProducts, type ListProductsParams, listProducts } from '@heybrostudio/lemonsqueezy.js'
const { statusCode, error, data } = await listProducts({ filter: { storeId: 123456 } })
With pagination:
import { type ListProducts, type ListProductsParams, listProducts } from '@heybrostudio/lemonsqueezy.js'
const { statusCode, error, data } = await listProducts({ page: { number: 1, size: 10 } })
With related resources:
import { type ListProducts, type ListProductsParams, listProducts } from '@heybrostudio/lemonsqueezy.js'
const { statusCode, error, data } = await listProducts({ include: ['store'] })
/**
* List all products.
*
* @param [params] (Optional) Additional parameters.
* @param [params.filter] (Optional) Filter parameters.
* @param [params.filter.storeId] (Optional) Only return products 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 product objects ordered by `name`.
*/
declare function listProducts(params?: ListProductsParams): Promise<FetchResponse<ListProducts>>
Returns a paginated list of product objects ordered by name
.
{
statusCode: number | null
error: Error | null
data: ListProducts | null
}