<?php

namespace App\Domain\WhatsApp;

/** Normalized provider response. */
class SendResult
{
    public function __construct(
        public bool $ok,
        public ?string $providerMessageId = null,
        public ?string $failureCode = null,
        public ?string $failureReason = null,
        public bool $retryable = false,
    ) {
    }

    public static function success(string $id): self
    {
        return new self(ok: true, providerMessageId: $id);
    }

    public static function failure(string $code, string $reason, bool $retryable): self
    {
        return new self(ok: false, failureCode: $code, failureReason: $reason, retryable: $retryable);
    }
}
