44 lines
1.5 KiB
TypeScript
44 lines
1.5 KiB
TypeScript
import type { SponsorsApiClient } from '../../api/sponsors/SponsorsApiClient';
|
|
import type { SponsorshipPricingPresenter } from '../../presenters/SponsorshipPricingPresenter';
|
|
import type { SponsorSponsorshipsPresenter } from '../../presenters/SponsorSponsorshipsPresenter';
|
|
import type {
|
|
SponsorshipPricingViewModel,
|
|
SponsorSponsorshipsViewModel
|
|
} from '../../view-models';
|
|
import type {
|
|
GetEntitySponsorshipPricingResultDto,
|
|
SponsorSponsorshipsDto
|
|
} from '../../dtos';
|
|
|
|
/**
|
|
* Sponsorship Service
|
|
*
|
|
* Orchestrates sponsorship operations by coordinating API calls and presentation logic.
|
|
* All dependencies are injected via constructor.
|
|
*/
|
|
export class SponsorshipService {
|
|
constructor(
|
|
private readonly apiClient: SponsorsApiClient,
|
|
private readonly sponsorshipPricingPresenter: SponsorshipPricingPresenter,
|
|
private readonly sponsorSponsorshipsPresenter: SponsorSponsorshipsPresenter
|
|
) {}
|
|
|
|
/**
|
|
* Get sponsorship pricing with presentation transformation
|
|
*/
|
|
async getSponsorshipPricing(): Promise<SponsorshipPricingViewModel> {
|
|
const dto = await this.apiClient.getPricing();
|
|
return this.sponsorshipPricingPresenter.present(dto);
|
|
}
|
|
|
|
/**
|
|
* Get sponsor sponsorships with presentation transformation
|
|
*/
|
|
async getSponsorSponsorships(sponsorId: string): Promise<SponsorSponsorshipsViewModel | null> {
|
|
const dto = await this.apiClient.getSponsorships(sponsorId);
|
|
if (!dto) {
|
|
return null;
|
|
}
|
|
return this.sponsorSponsorshipsPresenter.present(dto);
|
|
}
|
|
} |