export type GetApiApiCollectionItemsArgs = {offset?: number | undefined, size?: string | undefined, cursor?: string | undefined, collection_id?: string | undefined, user_id?: string | undefined, artwork_id?: string | undefined}; export type GetApiApiCollectionItemsOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Retrieve collection items. * * GET /api/collection_items */ export const getApiApiCollectionItems = async (args: GetApiApiCollectionItemsArgs, options: GetApiApiCollectionItemsOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.offset != null) query.append("offset", String(args.offset)) if (args.size != null) query.append("size", String(args.size)) if (args.cursor != null) query.append("cursor", String(args.cursor)) if (args.collection_id != null) query.append("collection_id", String(args.collection_id)) if (args.user_id != null) query.append("user_id", String(args.user_id)) if (args.artwork_id != null) query.append("artwork_id", String(args.artwork_id)) const url = `${baseUrl.replace(/\/+$/, '')}/api/collection_items${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };