<?php

declare(strict_types=1);

namespace PhpWA\Client;

use InvalidArgumentException;
use PhpWA\Protocol\Proto\Message;

final class DecryptedIncomingMessage
{
      private $message;
    public function __construct(Message $message)
    {
        $bytes = $message->serializeToString();
        if ($bytes === '' || strlen($bytes) > 3000000) { throw new InvalidArgumentException('Decrypted message protobuf is empty or too large.'); }
        $this->message = $message;
    }
    public function message(): Message { return $this->message; }
    public function protobufBytes(): string { return $this->message->serializeToString(); }
}
