export type GetApiV2ZonesIdArgs = {page?: number | undefined, per_page?: number | undefined, order_by?: string | undefined, direction?: string | undefined, 'x-customer-api-key'?: string | undefined}; export type GetApiV2ZonesIdOptions = {baseUrl: string, defaultValue?: string | undefined, fetch?: typeof fetch | undefined}; /** * Return a zone by its ID * * GET /v2/zones/{id} */ export const getApiV2ZonesId = async (args: GetApiV2ZonesIdArgs, options: GetApiV2ZonesIdOptions) => { const {baseUrl, fetch: fetchFn = fetch, defaultValue} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.page != null) query.append("page", String(args.page)) if (args.per_page != null) query.append("per_page", String(args.per_page)) if (args.order_by != null) query.append("order_by", String(args.order_by)) if (args.direction != null) query.append("direction", String(args.direction)) if (args['x-customer-api-key'] != null) headers.set("x-customer-api-key", String(args['x-customer-api-key'])) if (defaultValue !== undefined) headers.set("x-customer-api-key", defaultValue) const url = `${baseUrl.replace(/\/+$/, '')}/v2/zones/${encodeURIComponent(String(args.id))}${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 };