export type GetApiTimezoneV1ConvertTimeArgs = {base_location: string, base_datetime?: string | undefined, target_location: string}; export type GetApiTimezoneV1ConvertTimeOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Convert time between two locations or timezones. * * GET /timezone/v1/convert_time */ export const getApiTimezoneV1ConvertTime = async (args: GetApiTimezoneV1ConvertTimeArgs, options?: GetApiTimezoneV1ConvertTimeOptions) => { const {baseUrl = "https://api.orthogonal.com/mpp", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.base_location != null) query.append("base_location", String(args.base_location)) if (args.base_datetime != null) query.append("base_datetime", String(args.base_datetime)) if (args.target_location != null) query.append("target_location", String(args.target_location)) const url = `${baseUrl.replace(/\/+$/, '')}/timezone/v1/convert_time${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 undefined };