-
Notifications
You must be signed in to change notification settings - Fork 26
Files
Branko Conjic edited this page Feb 8, 2024
·
2 revisions
Retrieves the file with the given ID.
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'] });
/**
* 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 a file object.
{
statusCode: number | null;
error: Error | null;
data: File | null;
}
Returns a paginated list of files.
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'] });
/**
* 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 a paginated list of file objects ordered by sort
.
{
statusCode: number | null;
error: Error | null;
data: ListFiles | null;
}