Skip to content

Commit 74e7f87

Browse files
committed
Renamed Inbox -> Inboxes; updated type for all IDs to long; Minor code readability improvements in DefaultMailtrapHttpClient
1 parent 0de405b commit 74e7f87

17 files changed

+64
-59
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public class MailtrapJavaSDKTest {
8989
// OR send email to the Mailtrap Sandbox
9090

9191
try {
92-
int inboxId = 1000001;
92+
long inboxId = 1000001L;
9393

9494
// Either instantiate a new client
9595
MailtrapClient sandboxClient = MailtrapClientFactory.createMailtrapClient(

src/main/java/io/mailtrap/api/AttachmentsImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ public AttachmentsImpl(MailtrapConfig config) {
2020
}
2121

2222
@Override
23-
public AttachmentResponse getSingleAttachment(long accountId, int inboxId, long messageId, long attachmentId) {
23+
public AttachmentResponse getSingleAttachment(long accountId, long inboxId, long messageId, long attachmentId) {
2424
return httpClient.get(
2525
String.format(apiHost + "/api/accounts/%s/inboxes/%s/messages/%s/attachments/%s", accountId, inboxId, messageId, attachmentId),
2626
new RequestData(),
2727
AttachmentResponse.class);
2828
}
2929

3030
@Override
31-
public List<AttachmentResponse> getAttachments(long accountId, int inboxId, long messageId, String attachmentType) {
31+
public List<AttachmentResponse> getAttachments(long accountId, long inboxId, long messageId, String attachmentType) {
3232
var queryParams = RequestData.buildQueryParams(
3333
entry("attachment_type", Optional.ofNullable(attachmentType)));
3434

src/main/java/io/mailtrap/api/InboxImpl.java renamed to src/main/java/io/mailtrap/api/InboxesImpl.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import io.mailtrap.Constants;
44
import io.mailtrap.CustomValidator;
5-
import io.mailtrap.api.abstractions.Inbox;
5+
import io.mailtrap.api.abstractions.Inboxes;
66
import io.mailtrap.api.abstractions.classes.ApiResourceWithValidation;
77
import io.mailtrap.config.MailtrapConfig;
88
import io.mailtrap.http.RequestData;
@@ -12,9 +12,9 @@
1212

1313
import java.util.List;
1414

15-
public class InboxImpl extends ApiResourceWithValidation implements Inbox {
15+
public class InboxesImpl extends ApiResourceWithValidation implements Inboxes {
1616

17-
public InboxImpl(MailtrapConfig config, CustomValidator validator) {
17+
public InboxesImpl(MailtrapConfig config, CustomValidator validator) {
1818
super(config, validator);
1919
this.apiHost = Constants.GENERAL_HOST;
2020
}
@@ -33,7 +33,7 @@ public InboxResponse createInbox(long accountId, long projectId, CreateInboxRequ
3333
}
3434

3535
@Override
36-
public InboxResponse getInboxAttributes(long accountId, int inboxId) {
36+
public InboxResponse getInboxAttributes(long accountId, long inboxId) {
3737
return httpClient.get(
3838
String.format(apiHost + "/api/accounts/%s/inboxes/%s", accountId, inboxId),
3939
new RequestData(),
@@ -42,7 +42,7 @@ public InboxResponse getInboxAttributes(long accountId, int inboxId) {
4242
}
4343

4444
@Override
45-
public InboxResponse deleteInbox(long accountId, int inboxId) {
45+
public InboxResponse deleteInbox(long accountId, long inboxId) {
4646
return httpClient.delete(
4747
String.format(apiHost + "/api/accounts/%s/inboxes/%s", accountId, inboxId),
4848
new RequestData(),
@@ -51,7 +51,7 @@ public InboxResponse deleteInbox(long accountId, int inboxId) {
5151
}
5252

5353
@Override
54-
public InboxResponse updateInbox(long accountId, int inboxId, UpdateInboxRequest request) {
54+
public InboxResponse updateInbox(long accountId, long inboxId, UpdateInboxRequest request) {
5555

5656
validateRequestBodyAndThrowException(request);
5757

@@ -64,7 +64,7 @@ public InboxResponse updateInbox(long accountId, int inboxId, UpdateInboxRequest
6464
}
6565

6666
@Override
67-
public InboxResponse cleanInbox(long accountId, int inboxId) {
67+
public InboxResponse cleanInbox(long accountId, long inboxId) {
6868
return httpClient.patch(
6969
String.format(apiHost + "/api/accounts/%s/inboxes/%s/clean", accountId, inboxId),
7070
null,
@@ -74,7 +74,7 @@ public InboxResponse cleanInbox(long accountId, int inboxId) {
7474
}
7575

7676
@Override
77-
public InboxResponse markAsRead(long accountId, int inboxId) {
77+
public InboxResponse markAsRead(long accountId, long inboxId) {
7878
return httpClient.patch(
7979
String.format(apiHost + "/api/accounts/%s/inboxes/%s/all_read", accountId, inboxId),
8080
null,
@@ -84,7 +84,7 @@ public InboxResponse markAsRead(long accountId, int inboxId) {
8484
}
8585

8686
@Override
87-
public InboxResponse resetCredentials(long accountId, int inboxId) {
87+
public InboxResponse resetCredentials(long accountId, long inboxId) {
8888
return httpClient.patch(
8989
String.format(apiHost + "/api/accounts/%s/inboxes/%s/reset_credentials", accountId, inboxId),
9090
null,
@@ -94,7 +94,7 @@ public InboxResponse resetCredentials(long accountId, int inboxId) {
9494
}
9595

9696
@Override
97-
public InboxResponse enableEmailAddress(long accountId, int inboxId) {
97+
public InboxResponse enableEmailAddress(long accountId, long inboxId) {
9898
return httpClient.patch(
9999
String.format(apiHost + "/api/accounts/%s/inboxes/%s/toggle_email_username", accountId, inboxId),
100100
null,
@@ -104,7 +104,7 @@ public InboxResponse enableEmailAddress(long accountId, int inboxId) {
104104
}
105105

106106
@Override
107-
public InboxResponse resetEmailAddresses(long accountId, int inboxId) {
107+
public InboxResponse resetEmailAddresses(long accountId, long inboxId) {
108108
return httpClient.patch(
109109
String.format(apiHost + "/api/accounts/%s/inboxes/%s/reset_email_username", accountId, inboxId),
110110
null,

src/main/java/io/mailtrap/api/TestingEmailsImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public TestingEmailsImpl(MailtrapConfig config, CustomValidator customValidator)
2020
}
2121

2222
@Override
23-
public SendResponse send(MailtrapMail mail, int inboxId) {
23+
public SendResponse send(MailtrapMail mail, long inboxId) {
2424
validateRequestBodyOrThrowException(mail);
2525
RequestData requestData = new RequestData();
2626
if (mail.getHeaders() != null) {

src/main/java/io/mailtrap/api/abstractions/Attachments.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public interface Attachments {
1919
* @param attachmentId - unique attachment ID
2020
* @return attachment details and download path
2121
*/
22-
AttachmentResponse getSingleAttachment(long accountId, int inboxId, long messageId, long attachmentId);
22+
AttachmentResponse getSingleAttachment(long accountId, long inboxId, long messageId, long attachmentId);
2323

2424
/**
2525
* Get message attachments by inboxId and messageId
@@ -30,6 +30,6 @@ public interface Attachments {
3030
* @param attachmentType - attachment type; optional query param
3131
* @return attachments with their details and download paths
3232
*/
33-
List<AttachmentResponse> getAttachments(long accountId, int inboxId, long messageId, @Nullable String attachmentType);
33+
List<AttachmentResponse> getAttachments(long accountId, long inboxId, long messageId, @Nullable String attachmentType);
3434

3535
}

src/main/java/io/mailtrap/api/abstractions/Inbox.java renamed to src/main/java/io/mailtrap/api/abstractions/Inboxes.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
import java.util.List;
88

99
/**
10-
* Interface representing the Mailtrap Testing API for interaction with inbox
10+
* Interface representing the Mailtrap Testing API for interaction with inboxes
1111
*/
12-
public interface Inbox {
12+
public interface Inboxes {
1313

1414
/**
1515
* Create an inbox in a project
@@ -28,7 +28,7 @@ public interface Inbox {
2828
* @param inboxId unique inbox ID
2929
* @return the attributes of the inbox
3030
*/
31-
InboxResponse getInboxAttributes(long accountId, int inboxId);
31+
InboxResponse getInboxAttributes(long accountId, long inboxId);
3232

3333
/**
3434
* Delete an inbox with all its emails
@@ -37,7 +37,7 @@ public interface Inbox {
3737
* @param inboxId unique inbox ID
3838
* @return the attributes of the deleted inbox
3939
*/
40-
InboxResponse deleteInbox(long accountId, int inboxId);
40+
InboxResponse deleteInbox(long accountId, long inboxId);
4141

4242
/**
4343
* Update inbox name, inbox email username
@@ -47,7 +47,7 @@ public interface Inbox {
4747
* @param request request data
4848
* @return the attributes of the updated inbox
4949
*/
50-
InboxResponse updateInbox(long accountId, int inboxId, UpdateInboxRequest request);
50+
InboxResponse updateInbox(long accountId, long inboxId, UpdateInboxRequest request);
5151

5252
/**
5353
* Delete all messages (emails) from inbox
@@ -56,7 +56,7 @@ public interface Inbox {
5656
* @param inboxId unique inbox ID
5757
* @return the attributes of the inbox. <b>permissions</b> returns the permissions of the token for the inbox.
5858
*/
59-
InboxResponse cleanInbox(long accountId, int inboxId);
59+
InboxResponse cleanInbox(long accountId, long inboxId);
6060

6161
/**
6262
* Mark all messages in the inbox as read
@@ -65,7 +65,7 @@ public interface Inbox {
6565
* @param inboxId unique inbox ID
6666
* @return the attributes of the inbox. <b>permissions</b> returns the permissions of the token for the inbox
6767
*/
68-
InboxResponse markAsRead(long accountId, int inboxId);
68+
InboxResponse markAsRead(long accountId, long inboxId);
6969

7070
/**
7171
* Reset SMTP credentials of the inbox
@@ -74,7 +74,7 @@ public interface Inbox {
7474
* @param inboxId unique inbox ID
7575
* @return the attributes of the inbox. <b>permissions</b> returns the permissions of the token for the inbox
7676
*/
77-
InboxResponse resetCredentials(long accountId, int inboxId);
77+
InboxResponse resetCredentials(long accountId, long inboxId);
7878

7979
/**
8080
* Turn the email address of the inbox on/off
@@ -83,7 +83,7 @@ public interface Inbox {
8383
* @param inboxId unique inbox ID
8484
* @return the attributes of the inbox. <b>permissions</b> returns the permissions of the token for the inbox
8585
*/
86-
InboxResponse enableEmailAddress(long accountId, int inboxId);
86+
InboxResponse enableEmailAddress(long accountId, long inboxId);
8787

8888
/**
8989
* Reset username of email address per inbox
@@ -92,7 +92,7 @@ public interface Inbox {
9292
* @param inboxId unique inbox ID
9393
* @return the attributes of the inbox. <b>permissions</b> returns the permissions of the token for the inbox
9494
*/
95-
InboxResponse resetEmailAddresses(long accountId, int inboxId);
95+
InboxResponse resetEmailAddresses(long accountId, long inboxId);
9696

9797
/**
9898
* Get a list of inboxes

src/main/java/io/mailtrap/api/abstractions/TestingEmails.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ public interface TestingEmails {
2020
* @throws HttpException If there is an HTTP-related error during the send operation.
2121
* @throws InvalidRequestBodyException If the request body is invalid.
2222
*/
23-
SendResponse send(MailtrapMail mail, int inboxId) throws HttpException, InvalidRequestBodyException;
23+
SendResponse send(MailtrapMail mail, long inboxId) throws HttpException, InvalidRequestBodyException;
2424
}

src/main/java/io/mailtrap/client/MailtrapClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public void switchToBulkSendingApi() {
7474
*
7575
* @param inboxId the inbox ID to use for testing
7676
*/
77-
public void switchToEmailTestingApi(Integer inboxId) {
77+
public void switchToEmailTestingApi(Long inboxId) {
7878
this.sendingContextHolder.setInboxId(inboxId);
7979
this.sendingContextHolder.setSandbox(true);
8080
this.sendingContextHolder.setBulk(false);

src/main/java/io/mailtrap/client/layers/MailtrapEmailTestingApi.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package io.mailtrap.client.layers;
22

33
import io.mailtrap.api.abstractions.Attachments;
4-
import io.mailtrap.api.abstractions.Inbox;
4+
import io.mailtrap.api.abstractions.Inboxes;
55
import io.mailtrap.api.abstractions.TestingEmails;
66
import lombok.Getter;
77
import lombok.RequiredArgsConstructor;
@@ -16,5 +16,5 @@
1616
public class MailtrapEmailTestingApi {
1717
private final TestingEmails emails;
1818
private final Attachments attachments;
19-
private final Inbox inbox;
19+
private final Inboxes inboxes;
2020
}

src/main/java/io/mailtrap/config/MailtrapConfig.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class MailtrapConfig {
4141
/**
4242
* Inbox ID. Should be used alongside with {@link #sandbox}, as Email Testing API requires inbox ID
4343
*/
44-
private final Integer inboxId;
44+
private final Long inboxId;
4545

4646
private MailtrapConfig(Builder builder) {
4747
if (builder.sandbox && builder.bulk) {
@@ -65,7 +65,7 @@ public static class Builder {
6565
private CustomHttpClient httpClient;
6666
private boolean sandbox;
6767
private boolean bulk;
68-
private Integer inboxId;
68+
private Long inboxId;
6969

7070
public Builder connectionTimeout(Duration connectionTimeout) {
7171
this.connectionTimeout = connectionTimeout;
@@ -92,7 +92,7 @@ public Builder bulk(boolean bulk) {
9292
return this;
9393
}
9494

95-
public Builder inboxId(Integer inboxId) {
95+
public Builder inboxId(Long inboxId) {
9696
this.inboxId = inboxId;
9797
return this;
9898
}

0 commit comments

Comments
 (0)