<?php

declare(strict_types=1);

namespace PhpWA\Client;

use InvalidArgumentException;

final class OutgoingMessageResult
{
      private $messageId;
      private $participantHash;
      private $recipientDevices;

    public function __construct(string $messageId, string $participantHash, int $recipientDevices)
    {
        if (preg_match('/\A[A-Za-z0-9._:-]{1,256}\z/D', $messageId) !== 1
            || preg_match('/\A2:[A-Za-z0-9+\/]{6}\z/D', $participantHash) !== 1
            || $recipientDevices < 0 || $recipientDevices > 10000) {
            throw new InvalidArgumentException('Outgoing message result is invalid.');
        }
        $this->messageId = $messageId; $this->participantHash = $participantHash; $this->recipientDevices = $recipientDevices;
    }

    public function messageId(): string { return $this->messageId; }
    public function participantHash(): string { return $this->participantHash; }
    public function recipientDevices(): int { return $this->recipientDevices; }
}
