export type CreateApiV2ZonesSmartDataArgs = {'x-customer-api-key'?: string | undefined, body: {provider_key: string, date: string, data: {zones?: (Array<{id: number, current_occupation?: number | undefined, current_capacity?: number | undefined, current_occupied?: number | undefined}>) | undefined}}}; export type CreateApiV2ZonesSmartDataOptions = {baseUrl: string, defaultValue?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update a zone smart data * * POST /v2/zones/smart/data */ export const createApiV2ZonesSmartData = async (args: CreateApiV2ZonesSmartDataArgs, options: CreateApiV2ZonesSmartDataOptions) => { const {baseUrl, fetch: fetchFn = fetch, defaultValue} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") 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/smart/data${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };