export type PodcastFilters = {country?: Array | undefined, countryCode?: Array | undefined, language?: Array | undefined, category?: Array | undefined, podcastType?: ('podcasts' | 'shows') | undefined}; export type PodcastSearchParams = {query?: string | undefined, filters?: PodcastFilters | undefined, hitsPerPage?: number | undefined, page?: number | undefined}; export type CreateApiApiV2PodcastsSearchArgs = {body: PodcastSearchParams}; export type CreateApiApiV2PodcastsSearchOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Search podcasts * * POST /api/v2/podcasts/search */ export const createApiApiV2PodcastsSearch = async (args: CreateApiApiV2PodcastsSearchArgs, options?: CreateApiApiV2PodcastsSearchOptions) => { 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/podcasts/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() };