services refactor
This commit is contained in:
@@ -1,11 +1,44 @@
|
||||
import { api as api } from '../../api';
|
||||
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';
|
||||
|
||||
export async function getSponsorshipPricing(): Promise<any> {
|
||||
const dto = await api.sponsors.getPricing();
|
||||
return dto;
|
||||
}
|
||||
/**
|
||||
* 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
|
||||
) {}
|
||||
|
||||
export async function getSponsorSponsorships(sponsorId: string): Promise<any> {
|
||||
const dto = await api.sponsors.getSponsorships(sponsorId);
|
||||
return dto;
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user