Skip to content

Commit

Permalink
Merge pull request #19 from craigrileyuk/patch-1
Browse files Browse the repository at this point in the history
Refactor for RawMessage and endpoint correction
  • Loading branch information
willpower232 authored Oct 1, 2024
2 parents e361d11 + 77b722d commit d9b59cd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
22 changes: 9 additions & 13 deletions src/Send/RawMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,32 @@
class RawMessage
{
/**
* @var array{rcpt_to: array<string>, mail_from: string, data: string}
* @var array<string>
*/
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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/SendService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit d9b59cd

Please sign in to comment.