import type { SponsorsApiClient } from '../../api/sponsors/SponsorsApiClient'; import type { GetEntitySponsorshipPricingResultDto } from '../../api/sponsors/SponsorsApiClient'; import { SponsorshipPricingViewModel, SponsorSponsorshipsViewModel, SponsorshipRequestViewModel } from '../../view-models'; import type { SponsorSponsorshipsDTO } from '../../types/generated'; /** * Sponsorship Service * * Orchestrates sponsorship operations by coordinating API calls and view model creation. * All dependencies are injected via constructor. */ export class SponsorshipService { constructor( private readonly apiClient: SponsorsApiClient ) {} /** * Get sponsorship pricing with view model transformation */ async getSponsorshipPricing(): Promise { const dto = await this.apiClient.getPricing(); return new SponsorshipPricingViewModel(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); } /** * Get pending sponsorship requests for an entity */ async getPendingSponsorshipRequests(params: { entityType: string; entityId: string }): Promise { const dto = await this.apiClient.getPendingSponsorshipRequests(params); return dto.requests.map(dto => new SponsorshipRequestViewModel(dto)); } /** * Accept a sponsorship request */ async acceptSponsorshipRequest(requestId: string, respondedBy: string): Promise { await this.apiClient.acceptSponsorshipRequest(requestId, respondedBy); } /** * Reject a sponsorship request */ async rejectSponsorshipRequest(requestId: string, respondedBy: string, reason?: string): Promise { await this.apiClient.rejectSponsorshipRequest(requestId, respondedBy, reason); } }