export type GetApiApiV2StationsListArgs = {page?: number | undefined, hitsPerPage?: number | undefined, minSessions?: number | undefined}; export type GetApiApiV2StationsListOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * List stations * * GET /api/v2/stations/list */ export const getApiApiV2StationsList = async (args: GetApiApiV2StationsListArgs, options?: GetApiApiV2StationsListOptions) => { const {baseUrl = "https://api.zeno.fm", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "*/*") if (args.page != null) query.append("page", String(args.page)) if (args.hitsPerPage != null) query.append("hitsPerPage", String(args.hitsPerPage)) if (args.minSessions != null) query.append("minSessions", String(args.minSessions)) const url = `${baseUrl.replace(/\/+$/, '')}/api/v2/stations/list${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() };