Repository navigation
Add Subscription Topics and topic fields on campaigns, contacts, imports, suppressions, email logs and webhooks #92
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
Open
Rabsztok
wants to merge
6
commits into
main
Choose a base branch
from
add-subscription-topics-to-the-sdks-and
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9fb0cb9
Add Subscription Topics and topic fields
Rabsztok a220451
Keep non-string values in server errors from crashing
Rabsztok f02004b
Format non-string error values in getErrorMsg itself
Rabsztok 4edf10b
Skip topic steps in examples when the lookup fails
Rabsztok f84a226
Share one null check for contact topics and list webhook types once
Rabsztok 332cc75
Drop the retry hint from server errors that say what went wrong
Rabsztok 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
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
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
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,60 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| use Mailtrap\Config; | ||
| use Mailtrap\Helper\ResponseHelper; | ||
| use Mailtrap\MailtrapGeneralClient; | ||
|
|
||
| require __DIR__ . '/../../vendor/autoload.php'; | ||
|
|
||
| $config = new Config($_ENV['MAILTRAP_API_KEY']); // your API token from https://mailtrap.io/api-tokens | ||
| $subscriptionTopics = (new MailtrapGeneralClient($config))->subscriptionTopics(); | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
|
|
||
| /** | ||
| * Get a paginated list of subscription topics; deleted topics are left out. | ||
| * Optional: $perPage (max 100, default 50) and $token (page number). | ||
| * | ||
| * The response is wrapped in `{ data: [...], pagination }`. A topic's `domain_id` is null when | ||
| * it covers every domain of the account. | ||
| * | ||
| * GET https://mailtrap.io/api/subscription_topics | ||
| */ | ||
| try { | ||
| $topics = ResponseHelper::toArray($subscriptionTopics->getSubscriptionTopics(perPage: 50)); | ||
|
|
||
| var_dump($topics); | ||
|
|
||
| // pass `pagination.next_token` with the same $perPage to get the next page | ||
| $nextToken = $topics['pagination']['next_token'] ?? null; | ||
| if ($nextToken !== null) { | ||
| var_dump(ResponseHelper::toArray($subscriptionTopics->getSubscriptionTopics(perPage: 50, token: $nextToken))); | ||
| } | ||
| } catch (Exception $e) { | ||
| echo $e->getCode() === 403 | ||
| ? 'Subscription Topics are not available for this account.' | ||
| : 'Caught exception: ' . $e->getMessage(); | ||
| echo PHP_EOL; | ||
|
|
||
| exit(1); | ||
| } | ||
|
|
||
| /** | ||
| * Get a subscription topic by ID (wrapped in `data`). A deleted topic is returned too, with | ||
| * `deleted_at` set. | ||
| * | ||
| * GET https://mailtrap.io/api/subscription_topics/{subscription_topic_id} | ||
| */ | ||
| try { | ||
| $subscriptionTopicId = $topics['data'][0]['id'] ?? null; | ||
|
|
||
| if ($subscriptionTopicId !== null) { | ||
| $response = $subscriptionTopics->getSubscriptionTopic($subscriptionTopicId); | ||
|
|
||
| var_dump(ResponseHelper::toArray($response)); | ||
| } else { | ||
| echo 'No subscription topics yet: create one in Mailtrap first.', PHP_EOL; | ||
| } | ||
| } catch (Exception $e) { | ||
| echo 'Caught exception: ', $e->getMessage(), PHP_EOL; | ||
| } | ||
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
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
Oops, something went wrong.
Oops, something went wrong.
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.