export type GetApiV1InstoreOrdersTokenArgs = {token: unknown}; export type GetApiV1InstoreOrdersTokenOptions = {baseUrl?: string | undefined, InstoreApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get an instore order * * GET /v1/instore/orders/{token} */ export const getApiV1InstoreOrdersToken = async (args: GetApiV1InstoreOrdersTokenArgs, options?: GetApiV1InstoreOrdersTokenOptions) => { const {baseUrl = "https://integration.api.scalapay.com", fetch: fetchFn = fetch, InstoreApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (InstoreApiKeyAuth !== undefined) headers.set("Authorization", InstoreApiKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/v1/instore/orders/${encodeURIComponent(String(args.token))}${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 (await res.json()) as unknown };