export type GetApiProductProductCountersArgs = {'user-agent': string, siteCode: string, eans: string, timeBegin?: number | undefined, timeEnd?: number | undefined, prettyPrint?: boolean | undefined}; export type GetApiProductProductCountersOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get product counters * * GET /product/productCounters */ export const getApiProductProductCounters = async (args: GetApiProductProductCountersArgs, options?: GetApiProductProductCountersOptions) => { const {baseUrl = "https://api.kameleoon.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args['user-agent'] != null) headers.set("user-agent", String(args['user-agent'])) if (args.siteCode != null) query.append("siteCode", String(args.siteCode)) if (args.eans != null) query.append("eans", String(args.eans)) if (args.timeBegin != null) query.append("timeBegin", String(args.timeBegin)) if (args.timeEnd != null) query.append("timeEnd", String(args.timeEnd)) if (args.prettyPrint != null) query.append("prettyPrint", String(args.prettyPrint)) const url = `${baseUrl.replace(/\/+$/, '')}/product/productCounters${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 };