export type ForecastDataIngestionPayload = {data: number, timestamp: string}; export type ForecastDataIngestionDataProviderInput = {externalForecastVariableId: string, externalUnitId: string, externalSectionId?: string | undefined, forecastDataPayload: Array}; export type ForecastDataIngestionDataProviderInputList = {requests: Array}; export type CreateApiV2ForecastsForecastDataArgs = {appendData?: boolean | undefined, body: ForecastDataIngestionDataProviderInputList}; export type CreateApiV2ForecastsForecastDataOptions = {baseUrl?: string | undefined, OAuth2ClientCredentials?: string | undefined, fetch?: typeof fetch | undefined}; /** * Upload forecast data with maximum 366 rows * * POST /v2/forecasts/forecast-data * * Also accepts auth: OAuth2ClientCredentials, OAuth2ClientCredentials */ export const createApiV2ForecastsForecastData = async (args: CreateApiV2ForecastsForecastDataArgs, options?: CreateApiV2ForecastsForecastDataOptions) => { const {baseUrl = "https://api.quinyx.com", fetch: fetchFn = fetch, OAuth2ClientCredentials} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "*/*") if (args.appendData != null) query.append("appendData", String(args.appendData)) if (OAuth2ClientCredentials !== undefined) headers.set('authorization', `Bearer ${OAuth2ClientCredentials}`) const url = `${baseUrl.replace(/\/+$/, '')}/v2/forecasts/forecast-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 res.blob() };