export type GetApiBusinessProductsArgs = {authorization: string, 'content-language': string, limit?: number | undefined, skip?: number | undefined, categoryID?: string | undefined, businessID?: string | undefined, status: string, populates?: string | undefined, updatedAt?: string | undefined}; export type GetApiBusinessProductsOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get all the products from a business * * GET /business/products */ export const getApiBusinessProducts = async (args: GetApiBusinessProductsArgs, options?: GetApiBusinessProductsOptions) => { const {baseUrl = "http://api.pickerexpress.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "*/*") if (args.authorization != null) headers.set("authorization", String(args.authorization)) if (args['content-language'] != null) headers.set("content-language", String(args['content-language'])) if (args.limit != null) query.append("limit", String(args.limit)) if (args.skip != null) query.append("skip", String(args.skip)) if (args.categoryID != null) query.append("categoryID", String(args.categoryID)) if (args.businessID != null) query.append("businessID", String(args.businessID)) if (args.status != null) query.append("status", String(args.status)) if (args.populates != null) query.append("populates", String(args.populates)) if (args.updatedAt != null) query.append("updatedAt", String(args.updatedAt)) const url = `${baseUrl.replace(/\/+$/, '')}/business/products${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 res.blob() };