export type DemandDataPoint = {date: string, demand: number}; export type CreateApiV1BeamAnalysesAnalysisIdSinkArgs = {analysis_id: string, 'Content-Type': 'text/csv' | 'application/x-ndjson' | 'application/json' | 'application/x-ldjson', body: DemandDataPoint}; export type CreateApiV1BeamAnalysesAnalysisIdSinkOptions = {baseUrl?: string | undefined, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Upload Demand Data * * POST /v1/beam/analyses/{analysis_id}/sink */ export const createApiV1BeamAnalysesAnalysisIdSink = async (args: CreateApiV1BeamAnalysesAnalysisIdSinkArgs, options?: CreateApiV1BeamAnalysesAnalysisIdSinkOptions) => { 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/beam/analyses/${encodeURIComponent(String(args.analysis_id))}/sink${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 };