view models

This commit is contained in:
2025-12-18 01:20:23 +01:00
parent 7c449af311
commit cc2553876a
216 changed files with 485 additions and 10179 deletions

View File

@@ -1,44 +1,40 @@
import type { SponsorsApiClient } from '../../api/sponsors/SponsorsApiClient';
import type { SponsorshipPricingPresenter } from '../../presenters/SponsorshipPricingPresenter';
import type { SponsorSponsorshipsPresenter } from '../../presenters/SponsorSponsorshipsPresenter';
import type {
import {
SponsorshipPricingViewModel,
SponsorSponsorshipsViewModel
} from '../../view-models';
import type {
GetEntitySponsorshipPricingResultDto,
SponsorSponsorshipsDto
} from '../../dtos';
import type { SponsorSponsorshipsDTO } from '../../types/generated';
// TODO: Move these types to apps/website/lib/types/generated when available
type GetEntitySponsorshipPricingResultDto = { pricing: Array<{ entityType: string; price: number }> };
/**
* Sponsorship Service
*
* Orchestrates sponsorship operations by coordinating API calls and presentation logic.
* 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,
private readonly sponsorshipPricingPresenter: SponsorshipPricingPresenter,
private readonly sponsorSponsorshipsPresenter: SponsorSponsorshipsPresenter
private readonly apiClient: SponsorsApiClient
) {}
/**
* Get sponsorship pricing with presentation transformation
* Get sponsorship pricing with view model transformation
*/
async getSponsorshipPricing(): Promise<SponsorshipPricingViewModel> {
const dto = await this.apiClient.getPricing();
return this.sponsorshipPricingPresenter.present(dto);
return new SponsorshipPricingViewModel(dto);
}
/**
* Get sponsor sponsorships with presentation transformation
* Get sponsor sponsorships with view model transformation
*/
async getSponsorSponsorships(sponsorId: string): Promise<SponsorSponsorshipsViewModel | null> {
const dto = await this.apiClient.getSponsorships(sponsorId);
if (!dto) {
return null;
}
return this.sponsorSponsorshipsPresenter.present(dto);
return new SponsorSponsorshipsViewModel(dto);
}
}