export type GetApiApiProductsIdArgs = {id: number, key?: string | undefined, secret?: string | undefined}; export type GetApiApiProductsIdOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Get product info * * GET /api/products/{id} */ export const getApiApiProductsId = async (args: GetApiApiProductsIdArgs, options: GetApiApiProductsIdOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.key != null) query.append("key", String(args.key)) if (args.secret != null) query.append("secret", String(args.secret)) const url = `${baseUrl.replace(/\/+$/, '')}/api/products/${encodeURIComponent(String(args.id))}${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 };