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<RejectSponsorshipRequestCommand, void, RejectSponsorshipRequestMutationError>
{
  private readonly service: SponsorshipRequestsService;

  constructor() {
    this.service = new SponsorshipRequestsService();
  }

  async execute(
    command: RejectSponsorshipRequestCommand,
  ): Promise<Result<void, RejectSponsorshipRequestMutationError>> {
    const result = await this.service.rejectRequest(command);
    
    if (result.isErr()) {
      return Result.err('REJECT_SPONSORSHIP_REQUEST_FAILED');
    }
    
    return Result.ok(undefined);
  }
}
