Repository navigation
Add Subscription Topics and topic fields on campaigns, contacts, imports, suppressions, email logs and webhooks #96
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
Draft
Rabsztok
wants to merge
4
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.
+1,619
−31
Draft
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
44dd42d
Add Subscription Topics and topic fields
Rabsztok c5c1e84
Keep the previous constructors and tolerate a null error body
Rabsztok bade5c8
Simplify the topic changes
Rabsztok b50a8e5
Look for the campaign example's subscription topic on every page
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
55 changes: 55 additions & 0 deletions
55
examples/java/io/mailtrap/examples/subscriptiontopics/SubscriptionTopicsExample.java
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,55 @@ | ||
| package io.mailtrap.examples.subscriptiontopics; | ||
|
|
||
| import io.mailtrap.api.subscriptiontopics.SubscriptionTopicListFilter; | ||
| import io.mailtrap.config.MailtrapConfig; | ||
| import io.mailtrap.exception.http.HttpClientException; | ||
| import io.mailtrap.factory.MailtrapClientFactory; | ||
| import io.mailtrap.model.response.subscriptiontopics.SubscriptionTopicListResponse; | ||
|
|
||
| public class SubscriptionTopicsExample { | ||
|
|
||
| private static final String TOKEN = System.getenv("MAILTRAP_API_KEY"); | ||
|
|
||
| public static void main(String[] args) { | ||
| final var config = new MailtrapConfig.Builder() | ||
| .token(TOKEN) | ||
| .build(); | ||
|
|
||
| final var client = MailtrapClientFactory.createMailtrapClient(config); | ||
|
|
||
| // The subscription topic endpoints are token-scoped: the account is resolved from the API token. | ||
| // They are read-only: topics are created and edited in the Mailtrap app. | ||
| final var subscriptionTopics = client.marketingApi().subscriptionTopics(); | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
|
|
||
| final SubscriptionTopicListResponse page; | ||
| try { | ||
| // Topics by id, deleted ones left out. Pass null for the first page with API defaults. | ||
| page = subscriptionTopics.getSubscriptionTopics(SubscriptionTopicListFilter.builder().perPage(50).build()); | ||
| } catch (final HttpClientException e) { | ||
| if (e.getStatusCode() == 403) { | ||
| System.out.println("Subscription topics aren't available for this account or token"); | ||
| return; | ||
| } | ||
| throw e; | ||
| } | ||
|
|
||
| // A topic with a null domainId covers every sending domain. | ||
| page.getData().forEach(System.out::println); | ||
|
|
||
| // Pass the next token with the same perPage to get the next page. | ||
| if (page.getPagination().getNextToken() != null) { | ||
| System.out.println(subscriptionTopics.getSubscriptionTopics(SubscriptionTopicListFilter.builder() | ||
| .perPage(50) | ||
| .token(page.getPagination().getNextToken()) | ||
| .build()).getData()); | ||
| } | ||
|
|
||
| if (page.getData().isEmpty()) { | ||
| System.out.println("The account has no subscription topics yet"); | ||
| return; | ||
| } | ||
|
|
||
| // Get one topic by id. This also returns a topic deleted after a campaign was assigned it, with deletedAt set. | ||
| System.out.println(subscriptionTopics.getSubscriptionTopic(page.getData().get(0).getId()).getData()); | ||
| } | ||
| } | ||
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
27 changes: 27 additions & 0 deletions
27
src/main/java/io/mailtrap/api/subscriptiontopics/SubscriptionTopicListFilter.java
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,27 @@ | ||
| package io.mailtrap.api.subscriptiontopics; | ||
|
|
||
| import lombok.AllArgsConstructor; | ||
| import lombok.Builder; | ||
| import lombok.Data; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| /** | ||
| * Pagination parameters for listing subscription topics. All fields are optional; | ||
| * {@code null} fields are omitted from the query string. | ||
| */ | ||
| @Data | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| @Builder | ||
| public class SubscriptionTopicListFilter { | ||
|
|
||
| /** | ||
| * Number of topics per page (max 100, default 50). | ||
| */ | ||
| private Integer perPage; | ||
|
|
||
| /** | ||
| * Page number to retrieve (page-token pagination, default 1). | ||
| */ | ||
| private Integer token; | ||
| } |
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.