Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Resend.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
14 changes: 14 additions & 0 deletions src/Service/Broadcast.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
9 changes: 9 additions & 0 deletions tests/Service/Broadcast.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@
->id->toBe('559ac32e-9ef5-46fb-82a1-b76b840c0f7b');
});

it('can cancel a broadcast resource', function () {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Custom agent: API Key Permission Check SDK Methods

This PR introduces a new provider SDK operation, Broadcast::cancel() (calling POST /broadcasts/{id}/cancel), which is not previously used by this SDK. Since this adds a new broadcast-management permission scope, please confirm that the broadcast API keys used in production have the required permission for the cancel operation, so the call doesn't fail with a permission error after deployment.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At tests/Service/Broadcast.php, line 65:

<comment>This PR introduces a new provider SDK operation, `Broadcast::cancel()` (calling `POST /broadcasts/{id}/cancel`), which is not previously used by this SDK. Since this adds a new broadcast-management permission scope, please confirm that the broadcast API keys used in production have the required permission for the `cancel` operation, so the call doesn't fail with a permission error after deployment.</comment>

<file context>
@@ -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());
+
</file context>

$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());

Expand Down