import type { SponsorsApiClient } from '../../api/sponsors/SponsorsApiClient'; import { SponsorViewModel } from '../../view-models/SponsorViewModel'; import { SponsorDashboardViewModel } from '../../view-models/SponsorDashboardViewModel'; import { SponsorSponsorshipsViewModel } from '../../view-models/SponsorSponsorshipsViewModel'; import type { CreateSponsorInputDTO } from '../../types/generated/CreateSponsorInputDTO'; import type { SponsorDTO } from '../../types/generated/SponsorDTO'; /** * Sponsor Service * * Orchestrates sponsor operations by coordinating API calls and view model creation. * All dependencies are injected via constructor. */ export class SponsorService { constructor( private readonly apiClient: SponsorsApiClient ) {} /** * Get all sponsors with view model transformation */ async getAllSponsors(): Promise { const dto = await this.apiClient.getAll(); return (dto?.sponsors || []).map((sponsor: SponsorDTO) => new SponsorViewModel(sponsor)); } /** * Get sponsor dashboard with view model transformation */ async getSponsorDashboard(sponsorId: string): Promise { const dto = await this.apiClient.getDashboard(sponsorId); if (!dto) { return null; } return new SponsorDashboardViewModel(dto); } /** * Get sponsor sponsorships with view model transformation */ async getSponsorSponsorships(sponsorId: string): Promise { const dto = await this.apiClient.getSponsorships(sponsorId); if (!dto) { return null; } return new SponsorSponsorshipsViewModel(dto); } /** * Create a new sponsor */ async createSponsor(input: CreateSponsorInputDTO): Promise { return await this.apiClient.create(input); } /** * Get sponsorship pricing */ async getSponsorshipPricing(): Promise { return await this.apiClient.getPricing(); } /** * Get sponsor billing information */ async getBilling(sponsorId: string): Promise<{ paymentMethods: any[]; invoices: any[]; stats: any; }> { return await this.apiClient.getBilling(sponsorId); } /** * Get available leagues for sponsorship */ async getAvailableLeagues(): Promise { return await this.apiClient.getAvailableLeagues(); } /** * Get detailed league information */ async getLeagueDetail(leagueId: string): Promise<{ league: any; drivers: any[]; races: any[]; }> { return await this.apiClient.getLeagueDetail(leagueId); } /** * Get sponsor settings */ async getSettings(sponsorId: string): Promise<{ profile: any; notifications: any; privacy: any; }> { return await this.apiClient.getSettings(sponsorId); } /** * Update sponsor settings */ async updateSettings(sponsorId: string, input: any): Promise { return await this.apiClient.updateSettings(sponsorId, input); } }