-
Notifications
You must be signed in to change notification settings - Fork 7
feat: add broadcasts.clickedLinks() endpoint #143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| <?php | ||
|
|
||
| namespace Resend\Broadcasts; | ||
|
|
||
| use Resend\Resource; | ||
|
|
||
| /** | ||
| * @property string $id An opaque cursor for this row, used only for pagination. It does not identify any entity in Resend. | ||
| * @property string $url The URL that was clicked. | ||
| * @property int $clicks Total number of clicks on this URL. | ||
| * @property int $unique_clicks Number of unique clicks on this URL. | ||
| */ | ||
| class ClickedLink extends Resource | ||
| { | ||
| // | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| <?php | ||
|
|
||
| namespace Resend\Service\Broadcasts; | ||
|
|
||
| use Resend\Service\Service; | ||
| use Resend\ValueObjects\Transporter\Payload; | ||
|
|
||
| class ClickedLink extends Service | ||
| { | ||
| /** | ||
| * Retrieve a broadcast's clicked links. | ||
| * | ||
| * @param array{'limit'?: int, 'before'?: string, 'after'?: string} $options | ||
| * @return \Resend\Collection<\Resend\Broadcasts\ClickedLink> | ||
| * | ||
| * @see https://resend.com/docs/api-reference/broadcasts/list-broadcast-clicked-links | ||
| */ | ||
| public function list(string $broadcastId, array $options = []): \Resend\Collection | ||
| { | ||
| $payload = Payload::list("broadcasts/$broadcastId/clicked-links", $options); | ||
|
|
||
| $result = $this->transporter->request($payload); | ||
|
|
||
| return $this->createResource('broadcast-clicked-links', $result); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| <?php | ||
|
|
||
| function broadcastClickedLinks(): array | ||
| { | ||
| return [ | ||
| 'object' => 'list', | ||
| 'has_more' => false, | ||
| 'data' => [ | ||
| [ | ||
| 'id' => 'b2Zmc2V0OjA', | ||
| 'url' => 'https://resend.com/pricing', | ||
| 'clicks' => 42, | ||
| 'unique_clicks' => 30, | ||
| ], | ||
| [ | ||
| 'id' => 'b2Zmc2V0OjE', | ||
| 'url' => 'https://resend.com/docs', | ||
| 'clicks' => 17, | ||
| 'unique_clicks' => 15, | ||
| ], | ||
| ], | ||
| ]; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| <?php | ||
|
|
||
| use Resend\Broadcasts\ClickedLink; | ||
| use Resend\Collection; | ||
|
|
||
| it('can get a list of a broadcast\'s clicked links', function () { | ||
| $client = mockClient('GET', 'broadcasts/559ac32e-9ef5-46fb-82a1-b76b840c0f7b/clicked-links', [], [], broadcastClickedLinks()); | ||
|
|
||
| $result = $client->broadcasts->clickedLinks->list('559ac32e-9ef5-46fb-82a1-b76b840c0f7b'); | ||
|
|
||
| expect($result)->toBeInstanceOf(Collection::class) | ||
| ->data->toBeArray(); | ||
|
|
||
| expect($result->data[0])->toBeInstanceOf(ClickedLink::class) | ||
| ->url->toBe('https://resend.com/pricing'); | ||
| }); | ||
|
|
||
| it('can get a list of a broadcast\'s clicked links with pagination options', function () { | ||
| $client = mockClient('GET', 'broadcasts/559ac32e-9ef5-46fb-82a1-b76b840c0f7b/clicked-links?limit=1', [], [], broadcastClickedLinks()); | ||
|
|
||
| $result = $client->broadcasts->clickedLinks->list('559ac32e-9ef5-46fb-82a1-b76b840c0f7b', ['limit' => 1]); | ||
|
|
||
| expect($result)->toBeInstanceOf(Collection::class) | ||
| ->data->toBeArray(); | ||
| }); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.