export type GetApiApiLeagueDealsArgs = {season: number, status?: Array | undefined, platform_id?: number | undefined, subplatform_id?: number | undefined, item_id?: number | undefined, leagues?: Array | undefined, scouting_groups?: Array | undefined, scouting_markets?: Array | undefined, properties?: Array | undefined, scouting_market_owners?: Array | undefined, divisions?: Array | undefined, sort_by?: ('name' | 'owner' | 'division' | 'companies_total' | 'sponsor_companies' | 'sponsor_in_venue' | 'tv_companies' | 'radio_companies' | 'social_companies' | 'digital_companies' | 'vendor_companies' | 'sponsor_subcategories_count') | undefined, sort_order?: ('asc' | 'desc') | undefined, with_assets_count_by_audit_status?: boolean | undefined, use_new_behavior?: boolean | undefined, per_page?: number | undefined, page?: number | undefined}; export type GetApiApiLeagueDealsOptions = {baseUrl: string, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * List league deals per property with aggregated statistics. * * GET /api/league/deals */ export const getApiApiLeagueDeals = async (args: GetApiApiLeagueDealsArgs, options: GetApiApiLeagueDealsOptions) => { const {baseUrl, fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.season != null) query.append("season", String(args.season)) if (args.status != null) query.append("status", args.status.join(',')) if (args.platform_id != null) query.append("platform_id", String(args.platform_id)) if (args.subplatform_id != null) query.append("subplatform_id", String(args.subplatform_id)) if (args.item_id != null) query.append("item_id", String(args.item_id)) if (args.leagues != null) query.append("leagues", args.leagues.join(',')) if (args.scouting_groups != null) query.append("scouting_groups", args.scouting_groups.join(',')) if (args.scouting_markets != null) query.append("scouting_markets", args.scouting_markets.join(',')) if (args.properties != null) query.append("properties", args.properties.join(',')) if (args.scouting_market_owners != null) query.append("scouting_market_owners", args.scouting_market_owners.join(',')) if (args.divisions != null) query.append("divisions", args.divisions.join(',')) if (args.sort_by != null) query.append("sort_by", String(args.sort_by)) if (args.sort_order != null) query.append("sort_order", String(args.sort_order)) if (args.with_assets_count_by_audit_status != null) query.append("with_assets_count_by_audit_status", String(args.with_assets_count_by_audit_status)) if (args.use_new_behavior != null) query.append("use_new_behavior", String(args.use_new_behavior)) if (args.per_page != null) query.append("per_page", String(args.per_page)) if (args.page != null) query.append("page", String(args.page)) if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/league/deals${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 };