export type GetApiSearchMoviesArgs = {text?: string | undefined, limit?: string | undefined, offset?: string | undefined, genres?: string | undefined, diffusions?: string | undefined, casting?: string | undefined, svods?: string | undefined, releases?: string | undefined, debut?: string | undefined, tri?: string | undefined, autres?: string | undefined, locale?: string | undefined}; export type GetApiSearchMoviesOptions = {baseUrl?: string | undefined, BetaSeriesApiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Return movie search results with advanced filters. * * GET /search/movies */ export const getApiSearchMovies = async (args: GetApiSearchMoviesArgs, options?: GetApiSearchMoviesOptions) => { 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.casting != null) query.append("casting", String(args.casting)) if (args.svods != null) query.append("svods", String(args.svods)) if (args.releases != null) query.append("releases", String(args.releases)) 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/movies${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 };