export type DemandInput = {demand: number, date: string}; export type CreateModelDemandRequest = {demand: Array}; export type CreateApiV1ForecastsModelsModelIdDemandArgs = {model_id: string, 'Content-Type': 'text/csv' | 'application/x-ndjson' | 'application/json', body: CreateModelDemandRequest}; export type CreateApiV1ForecastsModelsModelIdDemandOptions = {baseUrl?: string | undefined, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create Model Demand * * POST /v1/forecasts/models/{model_id}/demand */ export const createApiV1ForecastsModelsModelIdDemand = async (args: CreateApiV1ForecastsModelsModelIdDemandArgs, options?: CreateApiV1ForecastsModelsModelIdDemandOptions) => { const {baseUrl = "https://api.predicthq.com", fetch: fetchFn = fetch, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args['Content-Type'] != null) headers.set("Content-Type", String(args['Content-Type'])) if (BearerAuth !== undefined) headers.set('authorization', `Bearer ${BearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/forecasts/models/${encodeURIComponent(String(args.model_id))}/demand${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 };