export type GetApiProductsIdPricesArgs = {id: string, days?: number | undefined}; export type GetApiProductsIdPricesOptions = {baseUrl?: string | undefined, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get price history for a product * * GET /products/{id}/prices */ export const getApiProductsIdPrices = async (args: GetApiProductsIdPricesArgs, options?: GetApiProductsIdPricesOptions) => { const {baseUrl = "https://api.buywhere.ai/v1", fetch: fetchFn = fetch, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.days != null) query.append("days", String(args.days)) if (BearerAuth !== undefined) headers.set('authorization', `Bearer ${BearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/products/${encodeURIComponent(String(args.id))}/prices${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 };