import { SponsorshipRequestsService } from '@/lib/services/sponsors/SponsorshipRequestsService';
import type { Mutation } from '@/lib/contracts/mutations/Mutation';
import { Result } from '@/lib/contracts/Result';

export interface AcceptSponsorshipRequestCommand {
  requestId: string;
  actorDriverId: string;
}

export type AcceptSponsorshipRequestMutationError =
  | 'ACCEPT_SPONSORSHIP_REQUEST_FAILED';

export class AcceptSponsorshipRequestMutation
  implements Mutation<AcceptSponsorshipRequestCommand, void, AcceptSponsorshipRequestMutationError>
{
  private readonly service: SponsorshipRequestsService;

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

  async execute(
    command: AcceptSponsorshipRequestCommand,
  ): Promise<Result<void, AcceptSponsorshipRequestMutationError>> {
    const result = await this.service.acceptRequest(command);
    
    if (result.isErr()) {
      return Result.err('ACCEPT_SPONSORSHIP_REQUEST_FAILED');
    }
    
    return Result.ok(undefined);
  }
}
