export type GetApiMapMapsArgs = {'user-agent': string, siteCode: string, keys: string, prettyPrint?: boolean | undefined}; export type GetApiMapMapsOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get data for several keys * * GET /map/maps */ export const getApiMapMaps = async (args: GetApiMapMapsArgs, options?: GetApiMapMapsOptions) => { 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.keys != null) query.append("keys", String(args.keys)) if (args.prettyPrint != null) query.append("prettyPrint", String(args.prettyPrint)) const url = `${baseUrl.replace(/\/+$/, '')}/map/maps${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 };