export type GetApiPointsLatitudeLongitudeRadioOptions = {baseUrl?: string | undefined, userAgent?: string | undefined, fetch?: typeof fetch | undefined}; /** * Returns NOAA Weather Radio broadcast script for a latitude/longitude point * * GET /points/{latitude},{longitude}/radio * * Also accepts auth: apiKeyAuth */ export const getApiPointsLatitudeLongitudeRadio = async (options?: GetApiPointsLatitudeLongitudeRadioOptions) => { const {baseUrl = "https://api.weather.gov", fetch: fetchFn = fetch, userAgent} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/ssml+xml") if (userAgent !== undefined) headers.set("User-Agent", userAgent) const url = `${baseUrl.replace(/\/+$/, '')}/points/${encodeURIComponent(String(args.latitude))},${encodeURIComponent(String(args.longitude))}/radio${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() };