Skip to content
Branko Conjic edited this page Feb 8, 2024 · 2 revisions

getFile

Retrieves the file with the given ID.

Usage

import { type File, getFile } from '@lemonsqueezy/lemonsqueezy.js';

const fileId = 234567;
const { statusCode, error, data } = await getFile(fileId);

With related resources:

import { type GetFileParams, type File, getFile } from '@lemonsqueezy/lemonsqueezy.js';

const fileId = 234567;
const { statusCode, error, data } = await getFile(priceId, { include: ['variant'] });

Type Declarations

/**
 * Retrieve a file.
 *
 * @param fileId The given file id
 * @param [params] (Optional) Additional parameters.
 * @param [params.include] (Optional) Related resources.
 * @returns A file object.
 */
declare function getFile(fileId: number | string, params?: GetFileParams): Promise<FetchResponse<File>>;

Returns

Returns a file object.

{
	statusCode: number | null;
	error: Error | null;
	data: File | null;
}

Source

Source ~ Type ~ Test

listFiles

Returns a paginated list of files.

Usage

import { type ListFiles, listFiles } from '@lemonsqueezy/lemonsqueezy.js';

const { statusCode, error, data } = await listFiles();

With filter:

import { type ListFiles, type ListFilesParams, listFiles } from '@lemonsqueezy/lemonsqueezy.js';

const { statusCode, error, data } = await listFiles({ filter: { variantId: 234567 } });

With pagination:

import { type ListFiles, type ListFilesParams, listFiles } from '@lemonsqueezy/lemonsqueezy.js';

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

With related resources:

import { type ListFiles, type ListFilesParams, listFiles } from '@lemonsqueezy/lemonsqueezy.js';

const { statusCode, error, data } = await listFiles({ include: ['variant'] });

Type Declarations

/**
 * List all files.
 *
 * @param [params] (Optional) Additional parameters.
 * @param [params.filter] (Optional) Filter parameters.
 * @param [params.filter.variantId] (Optional) Only return files belonging to the variant 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 file objects ordered by `sort`.
 */
declare function listFiles(params?: ListFilesParams): Promise<FetchResponse<ListFiles>>;

Returns

Returns a paginated list of file objects ordered by sort.

{
	statusCode: number | null;
	error: Error | null;
	data: ListFiles | null;
}

Source

Source ~ Type ~ Test

Clone this wiki locally