export type StationFilters = {country?: Array | undefined, countryCode?: Array | undefined, language?: Array | undefined, genre?: Array | undefined}; export type StationSearchParams = {query?: string | undefined, filters?: StationFilters | undefined, hitsPerPage?: number | undefined, page?: number | undefined, minSessions?: number | undefined}; export type CreateApiApiV2StationsSearchArgs = {body: StationSearchParams}; export type CreateApiApiV2StationsSearchOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Search stations * * POST /api/v2/stations/search */ export const createApiApiV2StationsSearch = async (args: CreateApiApiV2StationsSearchArgs, options?: CreateApiApiV2StationsSearchOptions) => { const {baseUrl = "https://api.zeno.fm", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "*/*") const url = `${baseUrl.replace(/\/+$/, '')}/api/v2/stations/search${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", 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 res.blob() };