import { MembershipFeeDto } from '@/lib/types/generated/MembershipFeeDto'; import type { MemberPaymentDto } from '@/lib/types/generated/MemberPaymentDto'; import { MembershipFeeViewModel } from '@/lib/view-models/MembershipFeeViewModel'; import { PaymentsApiClient } from '../../api/payments/PaymentsApiClient'; // Response shape as returned by the membership-fees payments endpoint; mirrors the API contract until a generated type is introduced export interface GetMembershipFeesOutputDto { fee: MembershipFeeDto | null; payments: MemberPaymentDto[]; } /** * Membership Fee Service * * Orchestrates membership fee operations by coordinating API calls and view model creation. * All dependencies are injected via constructor. */ export class MembershipFeeService { constructor( private readonly apiClient: PaymentsApiClient ) {} /** * Get membership fees by league ID with view model transformation */ async getMembershipFees(leagueId: string): Promise<{ fee: MembershipFeeViewModel | null; payments: MemberPaymentDto[] }> { const dto: GetMembershipFeesOutputDto = await this.apiClient.getMembershipFees({ leagueId }); return { fee: dto.fee ? new MembershipFeeViewModel(dto.fee) : null, // Expose raw member payment DTOs; callers may map these into UI-specific view models if needed payments: dto.payments, }; } }