export type ForecastWindowDay = '1d' | '7d' | '14d' | '28d' | '30d' | '60d' | '90d'; export type GeoPoint = {lat: string, lon: string}; export type Location = {geopoint?: GeoPoint | undefined, radius?: number | undefined, unit?: ('m' | 'mi' | 'km' | 'ft') | undefined, saved_location_id?: string | undefined}; export type AlgoType = 'phq-xgboost'; export type InputInterval = 'day'; export type Industry = 'accommodation' | 'cpg' | 'tourism' | 'marketing' | 'parking' | 'restaurants' | 'retail' | 'transportation' | 'other'; export type InputDemandType = {interval?: InputInterval | undefined, industry?: Industry | undefined}; export type UpdateModelRequest = {name?: (string | null) | undefined, external_id?: (string | null) | undefined, forecast_window?: (ForecastWindowDay | null) | undefined, generate_baseline?: boolean | undefined, label?: (Array | null) | undefined, location?: (Location | null) | undefined, algo?: (AlgoType | null) | undefined, demand_type?: (InputDemandType | null) | undefined}; export type PatchApiV1ForecastsModelsModelIdArgs = {model_id: string, body: UpdateModelRequest}; export type PatchApiV1ForecastsModelsModelIdOptions = {baseUrl?: string | undefined, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update Model * * PATCH /v1/forecasts/models/{model_id} */ export const patchApiV1ForecastsModelsModelId = async (args: PatchApiV1ForecastsModelsModelIdArgs, options?: PatchApiV1ForecastsModelsModelIdOptions) => { 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 (BearerAuth !== undefined) headers.set('authorization', `Bearer ${BearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/forecasts/models/${encodeURIComponent(String(args.model_id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", 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 };