import { SponsorshipRequestsService } from '@/lib/services/sponsors/SponsorshipRequestsService'; import type { Mutation } from '@/lib/contracts/mutations/Mutation'; import { Result } from '@/lib/contracts/Result'; export interface RejectSponsorshipRequestCommand { requestId: string; actorDriverId: string; reason: string | null; } export type RejectSponsorshipRequestMutationError = | 'REJECT_SPONSORSHIP_REQUEST_FAILED'; export class RejectSponsorshipRequestMutation implements Mutation { private readonly service: SponsorshipRequestsService; constructor() { this.service = new SponsorshipRequestsService(); } async execute( command: RejectSponsorshipRequestCommand, ): Promise> { try { const result = await this.service.rejectRequest(command); if (result.isErr()) { return Result.err('REJECT_SPONSORSHIP_REQUEST_FAILED'); } return Result.ok(undefined); } catch (error) { return Result.err('REJECT_SPONSORSHIP_REQUEST_FAILED'); } } }