export type GetApiSearchShowsArgs = {text?: string | undefined, limit?: string | undefined, offset?: string | undefined, genres?: string | undefined, diffusions?: string | undefined, duration?: string | undefined, svods?: string | undefined, creations?: string | undefined, pays?: string | undefined, chaines?: string | undefined, debut?: string | undefined, tri?: string | undefined, autres?: string | undefined, locale?: string | undefined}; export type GetApiSearchShowsOptions = {baseUrl?: string | undefined, BetaSeriesApiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Return series search results with advanced filters. * * GET /search/shows */ export const getApiSearchShows = async (args: GetApiSearchShowsArgs, options?: GetApiSearchShowsOptions) => { const {baseUrl = "https://api.betaseries.com", fetch: fetchFn = fetch, BetaSeriesApiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.text != null) query.append("text", String(args.text)) if (args.limit != null) query.append("limit", String(args.limit)) if (args.offset != null) query.append("offset", String(args.offset)) if (args.genres != null) query.append("genres", String(args.genres)) if (args.diffusions != null) query.append("diffusions", String(args.diffusions)) if (args.duration != null) query.append("duration", String(args.duration)) if (args.svods != null) query.append("svods", String(args.svods)) if (args.creations != null) query.append("creations", String(args.creations)) if (args.pays != null) query.append("pays", String(args.pays)) if (args.chaines != null) query.append("chaines", String(args.chaines)) if (args.debut != null) query.append("debut", String(args.debut)) if (args.tri != null) query.append("tri", String(args.tri)) if (args.autres != null) query.append("autres", String(args.autres)) if (args.locale != null) query.append("locale", String(args.locale)) if (BetaSeriesApiKey !== undefined) headers.set("X-BetaSeries-Key", BetaSeriesApiKey) const url = `${baseUrl.replace(/\/+$/, '')}/search/shows${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 };