From 6c360f30bc833f351e9ab0c8526c982d0c1cedc2 Mon Sep 17 00:00:00 2001 From: Craig Riley <68274157+craigrileyuk@users.noreply.github.com> Date: Tue, 1 Oct 2024 01:49:46 +0100 Subject: [PATCH 1/2] Refactor to match Message structure --- src/Send/RawMessage.php | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/Send/RawMessage.php b/src/Send/RawMessage.php index 51a12b8..e284f6c 100644 --- a/src/Send/RawMessage.php +++ b/src/Send/RawMessage.php @@ -7,36 +7,32 @@ class RawMessage { /** - * @var array{rcpt_to: array, mail_from: string, data: string} + * @var array */ - public array $attributes; + public array $rcpt_to = []; + + public ?string $mail_from = null; + + public ?string $data = null; - public function __construct() - { - $this->attributes = [ - 'rcpt_to' => [], - 'mail_from' => '', - 'data' => '', - ]; - } public function mailFrom(string $address): self { - $this->attributes['mail_from'] = $address; + $this->mail_from = $address; return $this; } public function rcptTo(string $address): self { - $this->attributes['rcpt_to'][] = $address; + $this->rcpt_to[] = $address; return $this; } public function data(string $data): self { - $this->attributes['data'] = base64_encode($data); + $this->data = base64_encode($data); return $this; } From 77b722dd973a14dd4d8a79a4687ab10feb8455b8 Mon Sep 17 00:00:00 2001 From: Craig Riley <68274157+craigrileyuk@users.noreply.github.com> Date: Tue, 1 Oct 2024 02:24:15 +0100 Subject: [PATCH 2/2] Change 'raw' send-service to send to 'send/raw' API endpoint --- src/SendService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SendService.php b/src/SendService.php index eb6aeb2..a6fd9cb 100644 --- a/src/SendService.php +++ b/src/SendService.php @@ -30,7 +30,7 @@ public function message(Message $message): Result public function raw(RawMessage $message): Result { return $this->client->prepareResponse( - $this->client->getHttpClient()->post('send/message', [ + $this->client->getHttpClient()->post('send/raw', [ 'json' => $message, ]), Result::class,