export type GetApiV1PromotionsFacebookProductsArgs = {facebookAccountId?: string | undefined, instagramAccountId?: string | undefined, catalogId?: string | undefined, q?: string | undefined, Origin?: string | undefined}; export type GetApiV1PromotionsFacebookProductsOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * GET /v1/promotions/facebook/products */ export const getApiV1PromotionsFacebookProducts = async (args: GetApiV1PromotionsFacebookProductsArgs, options: GetApiV1PromotionsFacebookProductsOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.facebookAccountId != null) query.append("facebookAccountId", String(args.facebookAccountId)) if (args.instagramAccountId != null) query.append("instagramAccountId", String(args.instagramAccountId)) if (args.catalogId != null) query.append("catalogId", String(args.catalogId)) if (args.q != null) query.append("q", String(args.q)) if (args.Origin != null) headers.set("Origin", String(args.Origin)) const url = `${baseUrl.replace(/\/+$/, '')}/v1/promotions/facebook/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 (await res.json()) as unknown };