export type GetApiEpisodesListArgs = {subtitles?: string | undefined, limit?: string | undefined, showsLimit?: string | undefined, page?: string | undefined, showId?: string | undefined, showTheTVDBId?: string | undefined, showIMDBId?: string | undefined, userId?: string | undefined, specials?: string | undefined, released?: string | undefined, order?: string | undefined, since?: string | undefined, excludes?: string | undefined, platforms?: string | undefined, with_rewatch?: string | undefined, locale?: string | undefined}; export type GetApiEpisodesListOptions = {baseUrl?: string | undefined, BetaSeriesApiKey?: string | undefined, BetaSeriesToken?: string | undefined, fetch?: typeof fetch | undefined}; /** * Retrieve the list of episodes to watch. * * GET /episodes/list */ export const getApiEpisodesList = async (args: GetApiEpisodesListArgs, options?: GetApiEpisodesListOptions) => { const {baseUrl = "https://api.betaseries.com", fetch: fetchFn = fetch, BetaSeriesApiKey, BetaSeriesToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.subtitles != null) query.append("subtitles", String(args.subtitles)) if (args.limit != null) query.append("limit", String(args.limit)) if (args.showsLimit != null) query.append("showsLimit", String(args.showsLimit)) if (args.page != null) query.append("page", String(args.page)) if (args.showId != null) query.append("showId", String(args.showId)) if (args.showTheTVDBId != null) query.append("showTheTVDBId", String(args.showTheTVDBId)) if (args.showIMDBId != null) query.append("showIMDBId", String(args.showIMDBId)) if (args.userId != null) query.append("userId", String(args.userId)) if (args.specials != null) query.append("specials", String(args.specials)) if (args.released != null) query.append("released", String(args.released)) if (args.order != null) query.append("order", String(args.order)) if (args.since != null) query.append("since", String(args.since)) if (args.excludes != null) query.append("excludes", String(args.excludes)) if (args.platforms != null) query.append("platforms", String(args.platforms)) if (args.with_rewatch != null) query.append("with_rewatch", String(args.with_rewatch)) if (args.locale != null) query.append("locale", String(args.locale)) if (BetaSeriesApiKey !== undefined) headers.set("X-BetaSeries-Key", BetaSeriesApiKey) if (BetaSeriesToken !== undefined) headers.set("X-BetaSeries-Token", BetaSeriesToken) const url = `${baseUrl.replace(/\/+$/, '')}/episodes/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 undefined };