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

LicenseKeys

Caven edited this page Jan 31, 2024 · 1 revision

updateLicenseKey

Update a license key with the given ID.

Usage

import { type UpdateLicenseKey, type LicenseKey, updateLicenseKey } from '@heybrostudio/lemonsqueezy.js'

const licenseKeyId = 234567
const { statusCode, error, data } = await updateLicenseKey(licenseKeyId, { activationLimit: 5, disabled: false })

Type Declarations

/**
 * Update a license key.
 *
 * @param licenseKeyId The license key id.
 * @param licenseKey (Optional) Values to be updated.
 * @param [licenseKey.activationLimit] (Optional) The activation limit of this license key. Assign `null` to set the activation limit to "unlimited".
 * @param [licenseKey.disabled] (Optional) If `true`, the license key will have "disabled" status.
 * @returns A license key object.
 */
declare function updateLicenseKey(
  licenseKeyId: string | number,
  licenseKey: UpdateLicenseKey,
): Promise<FetchResponse<LicenseKey>>

Returns

Returns a license key object.

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

Source

Source ~ Type ~ Test

getLicenseKey

Retrieves the license key with the given ID.

Usage

import { type LicenseKey, getLicenseKey } from '@heybrostudio/lemonsqueezy.js'

const licenseKeyId = 234567
const { statusCode, error, data } = await getLicenseKey(licenseKeyId)

With related resources:

import { type LicenseKey, type GetLicenseKeyParams, getLicenseKey } from '@heybrostudio/lemonsqueezy.js'

const licenseKeyId = 234567
const { statusCode, error, data } = await getLicenseKey(licenseKeyId, { include: ['order'] })

Type Declarations

/**
 * Retrieve a license key.
 *
 * @param licenseKeyId The license key id.
 * @param [params] (Optional) Additional parameters.
 * @param [params.include] (Optional) Related resources.
 * @returns A license key object.
 */
declare function getLicenseKey(
  licenseKeyId: number | string,
  params?: GetLicenseKeyParams,
): Promise<FetchResponse<LicenseKey>>

Returns

Returns a license key object.

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

Source

Source ~ Type ~ Test

listLicenseKeys

Returns a paginated list of license keys.

Usage

import { type ListLicenseKeys, listLicenseKeys } from '@heybrostudio/lemonsqueezy.js'

const { statusCode, error, data } = await listLicenseKeys()

With filter:

import { type ListLicenseKeys, type ListLicenseKeysParams, listLicenseKeys } from '@heybrostudio/lemonsqueezy.js'

const { statusCode, error, data } = await listLicenseKeys({ filter: { storeId: 123456 } })

With pagination:

import { type ListLicenseKeys, type ListLicenseKeysParams, listLicenseKeys } from '@heybrostudio/lemonsqueezy.js'

const { statusCode, error, data } = await listLicenseKeys({ page: { number: 1, size: 10 } })

With related resources:

import { type ListLicenseKeys, type ListLicenseKeysParams, listLicenseKeys } from '@heybrostudio/lemonsqueezy.js'

const { statusCode, error, data } = await listLicenseKeys({ include: ['order'] })

Type Declarations

/**
 * List all license keys.
 *
 * @param [params] (Optional) Additional parameters.
 * @param [params.filter] (Optional) Filter parameters.
 * @param [params.filter.storeId] (Optional) Only return license keys belonging to the store with this ID.
 * @param [params.filter.orderId] (Optional) (Optional) Only return license keys belonging to the order with this ID.
 * @param [params.filter.orderItemId] (Optional) Only return license keys belonging to the order item with this ID.
 * @param [params.filter.productId] (Optional) Only return license keys belonging to the product 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 license key objects ordered by `id`.
 */
declare function listLicenseKeys(params?: ListLicenseKeysParams): Promise<FetchResponse<ListLicenseKeys>>

Returns

Returns a paginated list of license key objects ordered by id.

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

Source

Source ~ Type ~ Test

Clone this wiki locally