65 lines
2.3 KiB
TypeScript
65 lines
2.3 KiB
TypeScript
import type { SponsorsApiClient } from '../../api/sponsors/SponsorsApiClient';
|
|
import type { SponsorListPresenter } from '../../presenters/SponsorListPresenter';
|
|
import type { SponsorDashboardPresenter } from '../../presenters/SponsorDashboardPresenter';
|
|
import type { SponsorSponsorshipsPresenter } from '../../presenters/SponsorSponsorshipsPresenter';
|
|
import type { SponsorViewModel, SponsorDashboardViewModel, SponsorSponsorshipsViewModel } from '../../view-models';
|
|
import type { CreateSponsorInputDto, CreateSponsorOutputDto, GetEntitySponsorshipPricingResultDto } from '../../dtos';
|
|
|
|
/**
|
|
* Sponsor Service
|
|
*
|
|
* Orchestrates sponsor operations by coordinating API calls and presentation logic.
|
|
* All dependencies are injected via constructor.
|
|
*/
|
|
export class SponsorService {
|
|
constructor(
|
|
private readonly apiClient: SponsorsApiClient,
|
|
private readonly sponsorListPresenter: SponsorListPresenter,
|
|
private readonly sponsorDashboardPresenter: SponsorDashboardPresenter,
|
|
private readonly sponsorSponsorshipsPresenter: SponsorSponsorshipsPresenter
|
|
) {}
|
|
|
|
/**
|
|
* Get all sponsors with presentation transformation
|
|
*/
|
|
async getAllSponsors(): Promise<SponsorViewModel[]> {
|
|
const dto = await this.apiClient.getAll();
|
|
return this.sponsorListPresenter.present(dto);
|
|
}
|
|
|
|
/**
|
|
* Get sponsor dashboard with presentation transformation
|
|
*/
|
|
async getSponsorDashboard(sponsorId: string): Promise<SponsorDashboardViewModel | null> {
|
|
const dto = await this.apiClient.getDashboard(sponsorId);
|
|
if (!dto) {
|
|
return null;
|
|
}
|
|
return this.sponsorDashboardPresenter.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);
|
|
}
|
|
|
|
/**
|
|
* Create a new sponsor
|
|
*/
|
|
async createSponsor(input: CreateSponsorInputDto): Promise<CreateSponsorOutputDto> {
|
|
return await this.apiClient.create(input);
|
|
}
|
|
|
|
/**
|
|
* Get sponsorship pricing
|
|
*/
|
|
async getSponsorshipPricing(): Promise<GetEntitySponsorshipPricingResultDto> {
|
|
return await this.apiClient.getPricing();
|
|
}
|
|
} |