diff --git a/src/Endpoints/EmailEndpoint.php b/src/Endpoints/EmailEndpoint.php index 7841e90..53af4d0 100644 --- a/src/Endpoints/EmailEndpoint.php +++ b/src/Endpoints/EmailEndpoint.php @@ -183,6 +183,18 @@ public function metadata(array $metadata): self return $this; } + /** + * Set the tag of the email. + * + * @param string|null $tag The tag formatted as slug + */ + public function tag(?string $tag): self + { + $this->payload['tag'] = $tag; + + return $this; + } + /** * Send the composed email using the current payload. * diff --git a/tests/Endpoints/EmailEndpointTest.php b/tests/Endpoints/EmailEndpointTest.php index 852824f..92f83a4 100644 --- a/tests/Endpoints/EmailEndpointTest.php +++ b/tests/Endpoints/EmailEndpointTest.php @@ -253,3 +253,23 @@ ->metadata(['foo' => 'bar']) ->send(); }); + +test('it handles tags', function () { + $this->httpClient + ->shouldReceive('post') + ->once() + ->with('/v1/send', [ + 'from' => 'sender@example.com', + 'to' => ['recipient@example.com'], + 'subject' => 'Test Subject', + 'tag' => 'campaign', + ], []) + ->andReturn(['message_id' => '123', 'status' => 'pending']); + + $this->endpoint + ->from('sender@example.com') + ->to('recipient@example.com') + ->subject('Test Subject') + ->tag('campaign') + ->send(); +});