<?php

namespace App\Services\Communications\Providers\Fakes;

use App\Contracts\Communications\SmsChannelProvider;
use App\Enum\Contact\MessageProvider;
use App\Models\Contact\Hub\ContactMessage;
use App\ValueObjects\Communications\ProviderSendResult;

class FakeSmsChannelProvider implements SmsChannelProvider
{
    /** @var array<int, array{message: ContactMessage, id: string}> */
    public array $sent = [];

    public function identifier(): MessageProvider
    {
        return MessageProvider::TWILIO;
    }

    public function send(ContactMessage $message): ProviderSendResult
    {
        $id = 'fake-sms-' . $message->id . '-' . uniqid();
        $this->sent[] = ['message' => $message, 'id' => $id];

        return new ProviderSendResult(
            providerMessageId: $id,
            payload: ['fake' => true, 'to' => $message->recipient_phone],
            accepted: true,
        );
    }
}
