export type GetApiStatsShowsRankingArgs = {day?: string | undefined, country?: string | undefined, type?: string | undefined, period?: string | undefined, svod?: string | undefined, genre?: string | undefined, platform_id?: string | undefined, limit?: string | undefined, locale?: string | undefined}; export type GetApiStatsShowsRankingOptions = {baseUrl?: string | undefined, BetaSeriesApiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get shows ranking based on BigQuery aggregated data. * * GET /stats/shows_ranking */ export const getApiStatsShowsRanking = async (args: GetApiStatsShowsRankingArgs, options?: GetApiStatsShowsRankingOptions) => { const {baseUrl = "https://api.betaseries.com", fetch: fetchFn = fetch, BetaSeriesApiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.day != null) query.append("day", String(args.day)) if (args.country != null) query.append("country", String(args.country)) if (args.type != null) query.append("type", String(args.type)) if (args.period != null) query.append("period", String(args.period)) if (args.svod != null) query.append("svod", String(args.svod)) if (args.genre != null) query.append("genre", String(args.genre)) if (args.platform_id != null) query.append("platform_id", String(args.platform_id)) if (args.limit != null) query.append("limit", String(args.limit)) if (args.locale != null) query.append("locale", String(args.locale)) if (BetaSeriesApiKey !== undefined) headers.set("X-BetaSeries-Key", BetaSeriesApiKey) const url = `${baseUrl.replace(/\/+$/, '')}/stats/shows_ranking${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 };