import { ApiResponse, WeatherApi, WeatherData, SettingsData } from "./types.js"; export function checkForError(resp: ApiResponse): boolean { return !resp.error; } export class RealWeatherApi implements WeatherApi { async getWeatherData(tenantId: string, account: string, orderId: string): Promise> { const params = new URLSearchParams({ tenantId, account, orderId }); const response = await fetch(`/hook/c7/anchor-weather-2/api/weather-data?${params}`); return await response.json(); } async getSettings(tenantId: string, account: string): Promise> { const params = new URLSearchParams({ tenantId, account }); const response = await fetch(`/hook/c7/anchor-weather-2/api/get-settings?${params}`); return await response.json(); } async saveSettings(tenantId: string, account: string, values: Record): Promise> { const params = new URLSearchParams({ tenantId, account }); const response = await fetch(`/hook/c7/anchor-weather-2/api/save-settings?${params}`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ values }), }); return await response.json(); } }