Skip to content
This repository has been archived by the owner on Feb 4, 2024. It is now read-only.

Products

Caven edited this page Jan 31, 2024 · 2 revisions

getProduct

Retrieves the product with the given ID.

Usage

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'] })

Type Declarations

/**
 * 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

Returns a product object.

{
  statusCode: number | null
  error: Error | null
  data: Product | null
}

Source

Source ~ Type ~ Test

listProducts

List all products.

Usage

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'] })

Type Declarations

/**
 * 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

Returns a paginated list of product objects ordered by name.

{
  statusCode: number | null
  error: Error | null
  data: ListProducts | null
}

Source

Source ~ Type ~ Test

Clone this wiki locally