-
Notifications
You must be signed in to change notification settings - Fork 0
Add missing endpoints #51
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
IgorDobryn
wants to merge
4
commits into
main
Choose a base branch
from
MT-21864-add-missing-endpoints
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
4 commits
Select commit
Hold shift + click to select a range
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 |
|---|---|---|
| @@ -1,2 +1,4 @@ | ||
| export GPG_TTY=$(tty) | ||
| export JAVA_TOOL_OPTIONS='-Duser.language=en -Duser.country=US' | ||
| export MAILTRAP_ACCOUNT_ID="op://Mailtrap Dev/Mailtrap SDK Dev API Key/account_id" | ||
| export MAILTRAP_ORGANIZATION_ID="op://Mailtrap Dev/Mailtrap SDK Dev API Key/organization_id" | ||
| export MAILTRAP_API_KEY="op://Mailtrap Dev/Mailtrap SDK Dev API Key/account_api_token" | ||
| export MAILTRAP_ORGANIZATION_API_KEY="op://Mailtrap Dev/Mailtrap SDK Dev API Key/organization_api_token" | ||
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 |
|---|---|---|
|
|
@@ -36,3 +36,4 @@ build/ | |
|
|
||
| ### Mac OS ### | ||
| .DS_Store | ||
| .idea/ | ||
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,56 @@ | ||
| package io.mailtrap.api.apitokens; | ||
|
|
||
| import io.mailtrap.model.request.apitokens.CreateApiTokenRequest; | ||
| import io.mailtrap.model.response.apitokens.ApiToken; | ||
| import io.mailtrap.model.response.apitokens.ApiTokenWithToken; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| public interface ApiTokens { | ||
|
|
||
| /** | ||
| * List all API tokens visible to the current API token. | ||
| * | ||
| * @param accountId unique account ID | ||
| * @return list of API tokens | ||
| */ | ||
| List<ApiToken> getAllApiTokens(long accountId); | ||
|
|
||
| /** | ||
| * Create a new API token for the account with the given name and resource permissions. | ||
| * The full token value is returned only on creation. | ||
| * | ||
| * @param accountId unique account ID | ||
| * @param request token name and resource permissions | ||
| * @return created token, including the full token value | ||
| */ | ||
| ApiTokenWithToken createApiToken(long accountId, CreateApiTokenRequest request); | ||
|
|
||
| /** | ||
| * Get a single API token by id. | ||
| * | ||
| * @param accountId unique account ID | ||
| * @param id API token ID | ||
| * @return API token | ||
| */ | ||
| ApiToken getApiToken(long accountId, long id); | ||
|
|
||
| /** | ||
| * Permanently delete an API token. | ||
| * | ||
| * @param accountId unique account ID | ||
| * @param id API token ID | ||
| */ | ||
| void deleteApiToken(long accountId, long id); | ||
|
|
||
| /** | ||
| * Reset an API token. Expires the requested token and creates a new one with the same | ||
| * permissions; the new token value is returned only once. | ||
| * | ||
| * @param accountId unique account ID | ||
| * @param id API token ID | ||
| * @return new token, including the full token value | ||
| */ | ||
| ApiTokenWithToken resetApiToken(long accountId, long id); | ||
|
|
||
| } |
67 changes: 67 additions & 0 deletions
67
src/main/java/io/mailtrap/api/apitokens/ApiTokensImpl.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,67 @@ | ||
| package io.mailtrap.api.apitokens; | ||
|
|
||
| import io.mailtrap.Constants; | ||
| import io.mailtrap.api.apiresource.ApiResource; | ||
| import io.mailtrap.config.MailtrapConfig; | ||
| import io.mailtrap.http.RequestData; | ||
| import io.mailtrap.model.AbstractModel; | ||
| import io.mailtrap.model.request.apitokens.CreateApiTokenRequest; | ||
| import io.mailtrap.model.response.apitokens.ApiToken; | ||
| import io.mailtrap.model.response.apitokens.ApiTokenWithToken; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| public class ApiTokensImpl extends ApiResource implements ApiTokens { | ||
|
|
||
| public ApiTokensImpl(final MailtrapConfig config) { | ||
| super(config); | ||
| this.apiHost = Constants.GENERAL_HOST; | ||
| } | ||
|
|
||
| @Override | ||
| public List<ApiToken> getAllApiTokens(final long accountId) { | ||
| return httpClient.getList( | ||
| String.format(apiHost + "/api/accounts/%d/api_tokens", accountId), | ||
| new RequestData(), | ||
| ApiToken.class | ||
| ); | ||
| } | ||
|
|
||
| @Override | ||
| public ApiTokenWithToken createApiToken(final long accountId, final CreateApiTokenRequest request) { | ||
| return httpClient.post( | ||
| String.format(apiHost + "/api/accounts/%d/api_tokens", accountId), | ||
| request, | ||
| new RequestData(), | ||
| ApiTokenWithToken.class | ||
| ); | ||
| } | ||
|
|
||
| @Override | ||
| public ApiToken getApiToken(final long accountId, final long id) { | ||
| return httpClient.get( | ||
| String.format(apiHost + "/api/accounts/%d/api_tokens/%d", accountId, id), | ||
| new RequestData(), | ||
| ApiToken.class | ||
| ); | ||
| } | ||
|
|
||
| @Override | ||
| public void deleteApiToken(final long accountId, final long id) { | ||
| httpClient.delete( | ||
| String.format(apiHost + "/api/accounts/%d/api_tokens/%d", accountId, id), | ||
| new RequestData(), | ||
| Void.class | ||
| ); | ||
| } | ||
|
|
||
| @Override | ||
| public ApiTokenWithToken resetApiToken(final long accountId, final long id) { | ||
| return httpClient.post( | ||
| String.format(apiHost + "/api/accounts/%d/api_tokens/%d/reset", accountId, id), | ||
| (AbstractModel) null, | ||
| new RequestData(), | ||
| ApiTokenWithToken.class | ||
| ); | ||
| } | ||
| } |
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
29 changes: 29 additions & 0 deletions
29
src/main/java/io/mailtrap/api/subaccounts/SubAccounts.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,29 @@ | ||
| package io.mailtrap.api.subaccounts; | ||
|
|
||
| import io.mailtrap.model.request.subaccounts.CreateSubAccountRequest; | ||
| import io.mailtrap.model.response.subaccounts.SubAccount; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| public interface SubAccounts { | ||
|
|
||
| /** | ||
| * Get a list of sub accounts for the specified organization. | ||
| * Requires sub account management permissions for the organization. | ||
| * | ||
| * @param organizationId unique organization ID | ||
| * @return list of sub accounts | ||
| */ | ||
| List<SubAccount> getSubAccounts(long organizationId); | ||
|
|
||
| /** | ||
| * Create a new sub account under the specified organization. | ||
| * Requires sub account management permissions for the organization. | ||
| * | ||
| * @param organizationId unique organization ID | ||
| * @param request sub account data | ||
| * @return created sub account | ||
| */ | ||
| SubAccount createSubAccount(long organizationId, CreateSubAccountRequest request); | ||
|
|
||
| } |
37 changes: 37 additions & 0 deletions
37
src/main/java/io/mailtrap/api/subaccounts/SubAccountsImpl.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,37 @@ | ||
| package io.mailtrap.api.subaccounts; | ||
|
|
||
| import io.mailtrap.Constants; | ||
| import io.mailtrap.api.apiresource.ApiResource; | ||
| import io.mailtrap.config.MailtrapConfig; | ||
| import io.mailtrap.http.RequestData; | ||
| import io.mailtrap.model.request.subaccounts.CreateSubAccountRequest; | ||
| import io.mailtrap.model.response.subaccounts.SubAccount; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| public class SubAccountsImpl extends ApiResource implements SubAccounts { | ||
|
|
||
| public SubAccountsImpl(final MailtrapConfig config) { | ||
| super(config); | ||
| this.apiHost = Constants.GENERAL_HOST; | ||
| } | ||
|
|
||
| @Override | ||
| public List<SubAccount> getSubAccounts(final long organizationId) { | ||
| return httpClient.getList( | ||
| String.format(apiHost + "/api/organizations/%d/sub_accounts", organizationId), | ||
| new RequestData(), | ||
| SubAccount.class | ||
| ); | ||
| } | ||
|
|
||
| @Override | ||
| public SubAccount createSubAccount(final long organizationId, final CreateSubAccountRequest request) { | ||
| return httpClient.post( | ||
| String.format(apiHost + "/api/organizations/%d/sub_accounts", organizationId), | ||
| request, | ||
| new RequestData(), | ||
| SubAccount.class | ||
| ); | ||
| } | ||
| } |
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,57 @@ | ||
| package io.mailtrap.api.webhooks; | ||
|
|
||
| import io.mailtrap.model.request.webhooks.CreateWebhookRequest; | ||
| import io.mailtrap.model.request.webhooks.UpdateWebhookRequest; | ||
| import io.mailtrap.model.response.webhooks.CreateWebhookResponse; | ||
| import io.mailtrap.model.response.webhooks.ListWebhooksResponse; | ||
| import io.mailtrap.model.response.webhooks.WebhookResponse; | ||
|
|
||
| public interface Webhooks { | ||
|
|
||
| /** | ||
| * Create a new webhook for the account. The response includes the | ||
| * {@code signing_secret} used to verify webhook signatures (only returned on creation). | ||
| * | ||
| * @param accountId unique account ID | ||
| * @param request webhook configuration | ||
| * @return created webhook including the signing secret | ||
| */ | ||
| CreateWebhookResponse createWebhook(long accountId, CreateWebhookRequest request); | ||
|
|
||
| /** | ||
| * List all webhooks for the account. | ||
| * | ||
| * @param accountId unique account ID | ||
| * @return webhooks | ||
| */ | ||
| ListWebhooksResponse getAllWebhooks(long accountId); | ||
|
|
||
| /** | ||
| * Get a single webhook by ID. | ||
| * | ||
| * @param accountId unique account ID | ||
| * @param webhookId webhook ID | ||
| * @return webhook details | ||
| */ | ||
| WebhookResponse getWebhook(long accountId, long webhookId); | ||
|
|
||
| /** | ||
| * Update an existing webhook. | ||
| * | ||
| * @param accountId unique account ID | ||
| * @param webhookId webhook ID | ||
| * @param request fields to update | ||
| * @return updated webhook | ||
| */ | ||
| WebhookResponse updateWebhook(long accountId, long webhookId, UpdateWebhookRequest request); | ||
|
|
||
| /** | ||
| * Permanently delete a webhook. | ||
| * | ||
| * @param accountId unique account ID | ||
| * @param webhookId webhook ID | ||
| * @return the deleted webhook | ||
| */ | ||
| WebhookResponse deleteWebhook(long accountId, long webhookId); | ||
|
|
||
| } |
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,66 @@ | ||
| package io.mailtrap.api.webhooks; | ||
|
|
||
| import io.mailtrap.Constants; | ||
| import io.mailtrap.api.apiresource.ApiResource; | ||
| import io.mailtrap.config.MailtrapConfig; | ||
| import io.mailtrap.http.RequestData; | ||
| import io.mailtrap.model.request.webhooks.CreateWebhookRequest; | ||
| import io.mailtrap.model.request.webhooks.UpdateWebhookRequest; | ||
| import io.mailtrap.model.response.webhooks.CreateWebhookResponse; | ||
| import io.mailtrap.model.response.webhooks.ListWebhooksResponse; | ||
| import io.mailtrap.model.response.webhooks.WebhookResponse; | ||
|
|
||
| public class WebhooksImpl extends ApiResource implements Webhooks { | ||
|
|
||
| public WebhooksImpl(final MailtrapConfig config) { | ||
| super(config); | ||
| this.apiHost = Constants.GENERAL_HOST; | ||
| } | ||
|
|
||
| @Override | ||
| public CreateWebhookResponse createWebhook(final long accountId, final CreateWebhookRequest request) { | ||
| return httpClient.post( | ||
| String.format(apiHost + "/api/accounts/%d/webhooks", accountId), | ||
| request, | ||
| new RequestData(), | ||
| CreateWebhookResponse.class | ||
| ); | ||
| } | ||
|
|
||
| @Override | ||
| public ListWebhooksResponse getAllWebhooks(final long accountId) { | ||
| return httpClient.get( | ||
| String.format(apiHost + "/api/accounts/%d/webhooks", accountId), | ||
| new RequestData(), | ||
| ListWebhooksResponse.class | ||
| ); | ||
| } | ||
|
|
||
| @Override | ||
| public WebhookResponse getWebhook(final long accountId, final long webhookId) { | ||
| return httpClient.get( | ||
| String.format(apiHost + "/api/accounts/%d/webhooks/%d", accountId, webhookId), | ||
| new RequestData(), | ||
| WebhookResponse.class | ||
| ); | ||
| } | ||
|
|
||
| @Override | ||
| public WebhookResponse updateWebhook(final long accountId, final long webhookId, final UpdateWebhookRequest request) { | ||
| return httpClient.patch( | ||
| String.format(apiHost + "/api/accounts/%d/webhooks/%d", accountId, webhookId), | ||
| request, | ||
| new RequestData(), | ||
| WebhookResponse.class | ||
| ); | ||
| } | ||
|
|
||
| @Override | ||
| public WebhookResponse deleteWebhook(final long accountId, final long webhookId) { | ||
| return httpClient.delete( | ||
| String.format(apiHost + "/api/accounts/%d/webhooks/%d", accountId, webhookId), | ||
| new RequestData(), | ||
| WebhookResponse.class | ||
| ); | ||
| } | ||
| } |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓