diff --git a/src/Resend.php b/src/Resend.php index a4b3697..b8f45c4 100644 --- a/src/Resend.php +++ b/src/Resend.php @@ -12,7 +12,7 @@ class Resend /** * The current SDK version. */ - public const VERSION = '1.7.0'; + public const VERSION = '1.8.0'; /** * Creates a new Resend Client with the given API key. diff --git a/src/Service/Broadcast.php b/src/Service/Broadcast.php index b1feda7..5d05f3a 100644 --- a/src/Service/Broadcast.php +++ b/src/Service/Broadcast.php @@ -79,6 +79,20 @@ public function send(string $broadcastId, array $parameters): \Resend\Broadcast return $this->createResource('broadcasts', $result); } + /** + * Cancel a queued or scheduled broadcast. + * + * @see https://resend.com/docs/api-reference/broadcasts/cancel-broadcast + */ + public function cancel(string $id): \Resend\Broadcast + { + $payload = Payload::cancel('broadcasts', $id); + + $result = $this->transporter->request($payload); + + return $this->createResource('broadcasts', $result); + } + /** * Remove an existing broadcast. * diff --git a/tests/Service/Broadcast.php b/tests/Service/Broadcast.php index 46eb163..f634084 100644 --- a/tests/Service/Broadcast.php +++ b/tests/Service/Broadcast.php @@ -62,6 +62,15 @@ ->id->toBe('559ac32e-9ef5-46fb-82a1-b76b840c0f7b'); }); +it('can cancel a broadcast resource', function () { + $client = mockClient('POST', 'broadcasts/559ac32e-9ef5-46fb-82a1-b76b840c0f7b/cancel', [], [], broadcast()); + + $result = $client->broadcasts->cancel('559ac32e-9ef5-46fb-82a1-b76b840c0f7b'); + + expect($result)->toBeInstanceOf(Broadcast::class) + ->id->toBe('559ac32e-9ef5-46fb-82a1-b76b840c0f7b'); +}); + it('can remove a broadcast resource', function () { $client = mockClient('DELETE', 'broadcasts/559ac32e-9ef5-46fb-82a1-b76b840c0f7b', [], [], broadcast());