export type GetApiV2ForecastsCalculatedVariablesExtCalculatedVarIdArgs = {extCalculatedVarId: string, externalUnitId: string, startTime: string, endTime: string}; export type GetApiV2ForecastsCalculatedVariablesExtCalculatedVarIdOptions = {baseUrl?: string | undefined, OAuth2ClientCredentials?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get calculated variable data by external id, up to 120 days * * GET /v2/forecasts/calculated-variables/{extCalculatedVarId} */ export const getApiV2ForecastsCalculatedVariablesExtCalculatedVarId = async (args: GetApiV2ForecastsCalculatedVariablesExtCalculatedVarIdArgs, options?: GetApiV2ForecastsCalculatedVariablesExtCalculatedVarIdOptions) => { const {baseUrl = "https://api.quinyx.com", fetch: fetchFn = fetch, OAuth2ClientCredentials} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "*/*") if (args.externalUnitId != null) query.append("externalUnitId", String(args.externalUnitId)) if (args.startTime != null) query.append("startTime", String(args.startTime)) if (args.endTime != null) query.append("endTime", String(args.endTime)) if (OAuth2ClientCredentials !== undefined) headers.set('authorization', `Bearer ${OAuth2ClientCredentials}`) const url = `${baseUrl.replace(/\/+$/, '')}/v2/forecasts/calculated-variables/${encodeURIComponent(String(args.extCalculatedVarId))}${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 res.blob() };