Add Inbound Email API support - #66
Open
mklocek wants to merge 5 commits into
Open
Conversation
Jackson/Lombok request and response models for the Inbound Email API: folders, inboxes, messages (list/details + attachments), threads (summary/detail/messages), send result, and create/update/reply/forward request bodies. Reply and forward reuse Address and EmailAttachment from the send models.
Token-scoped InboundFolders/Inboxes/Messages/Threads interfaces and impls under /api/inbound (path ids as method params, last_id pagination, forward validated for at least one recipient), grouped by MailtrapInboundApi and exposed via client.inboundApi().
Add inbound threading fields (rfc_message_id, in_reply_to, references, thread_id) to email-log messages, inbound flags (inbound_enabled, inbound_verified) to sending domains, and the optional inbound_inbox_id to webhook request and response models. Add the inbound_receiving webhook type so inbound webhooks can be created and deserialized.
📝 WalkthroughWalkthroughAdded a public Inbound Email API for folders, inboxes, messages, and threads. Added request and response models, client integration, webhook and email-log fields, tests, fixtures, and Java examples. ChangesInbound Email API
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant MailtrapClient
participant InboundApi
participant InboundMessages
participant MailtrapAPI
MailtrapClient->>InboundApi: getInboundApi()
InboundApi->>InboundMessages: access messages resource
InboundMessages->>MailtrapAPI: list, reply, forward, or delete message
MailtrapAPI-->>InboundMessages: return typed response
InboundMessages-->>MailtrapClient: return result
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/main/java/io/mailtrap/api/inbound/InboundMessagesImpl.java`:
- Around line 55-73: Update InboundReplyRequest validation to require at least
one of text or html, then invoke validateRequestBodyAndThrowException(request)
at the start of both InboundMessagesImpl.reply and replyAll before posting.
Preserve the existing request and response handling.
In `@src/main/java/io/mailtrap/model/request/inbound/InboundForwardRequest.java`:
- Around line 31-33: Update the to field in InboundForwardRequest to annotate
its list elements with `@NotNull` and `@Valid`, ensuring every recipient Address is
non-null while preserving the existing non-empty list validation.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 8465a827-3f9a-4acf-b66c-6ae6b8d8dcd0
📒 Files selected for processing (71)
README.mdexamples/java/io/mailtrap/examples/inbound/InboundFoldersExample.javaexamples/java/io/mailtrap/examples/inbound/InboundInboxesExample.javaexamples/java/io/mailtrap/examples/inbound/InboundMessagesExample.javaexamples/java/io/mailtrap/examples/inbound/InboundThreadsExample.javasrc/main/java/io/mailtrap/api/inbound/InboundFolders.javasrc/main/java/io/mailtrap/api/inbound/InboundFoldersImpl.javasrc/main/java/io/mailtrap/api/inbound/InboundInboxes.javasrc/main/java/io/mailtrap/api/inbound/InboundInboxesImpl.javasrc/main/java/io/mailtrap/api/inbound/InboundMessages.javasrc/main/java/io/mailtrap/api/inbound/InboundMessagesImpl.javasrc/main/java/io/mailtrap/api/inbound/InboundThreads.javasrc/main/java/io/mailtrap/api/inbound/InboundThreadsImpl.javasrc/main/java/io/mailtrap/client/MailtrapClient.javasrc/main/java/io/mailtrap/client/api/MailtrapInboundApi.javasrc/main/java/io/mailtrap/factory/MailtrapClientFactory.javasrc/main/java/io/mailtrap/model/WebhookType.javasrc/main/java/io/mailtrap/model/request/inbound/CreateInboundFolderRequest.javasrc/main/java/io/mailtrap/model/request/inbound/CreateInboundInboxRequest.javasrc/main/java/io/mailtrap/model/request/inbound/InboundForwardRequest.javasrc/main/java/io/mailtrap/model/request/inbound/InboundReplyRequest.javasrc/main/java/io/mailtrap/model/request/inbound/UpdateInboundFolderRequest.javasrc/main/java/io/mailtrap/model/request/inbound/UpdateInboundInboxRequest.javasrc/main/java/io/mailtrap/model/request/webhooks/WebhookInput.javasrc/main/java/io/mailtrap/model/response/emaillogs/EmailLogMessage.javasrc/main/java/io/mailtrap/model/response/emaillogs/EmailLogMessageSummary.javasrc/main/java/io/mailtrap/model/response/inbound/InboundAttachment.javasrc/main/java/io/mailtrap/model/response/inbound/InboundFolder.javasrc/main/java/io/mailtrap/model/response/inbound/InboundInbox.javasrc/main/java/io/mailtrap/model/response/inbound/InboundMessage.javasrc/main/java/io/mailtrap/model/response/inbound/InboundMessageDirection.javasrc/main/java/io/mailtrap/model/response/inbound/InboundMessageVisibilityStatus.javasrc/main/java/io/mailtrap/model/response/inbound/InboundMessagesListResponse.javasrc/main/java/io/mailtrap/model/response/inbound/InboundSendResult.javasrc/main/java/io/mailtrap/model/response/inbound/InboundThread.javasrc/main/java/io/mailtrap/model/response/inbound/InboundThreadMessage.javasrc/main/java/io/mailtrap/model/response/inbound/InboundThreadsListResponse.javasrc/main/java/io/mailtrap/model/response/sendingdomains/SendingDomainsResponse.javasrc/main/java/io/mailtrap/model/response/webhooks/Webhook.javasrc/test/java/io/mailtrap/api/emaillogs/EmailLogsImplTest.javasrc/test/java/io/mailtrap/api/inbound/InboundFoldersImplTest.javasrc/test/java/io/mailtrap/api/inbound/InboundInboxesImplTest.javasrc/test/java/io/mailtrap/api/inbound/InboundMessagesImplTest.javasrc/test/java/io/mailtrap/api/inbound/InboundThreadsImplTest.javasrc/test/java/io/mailtrap/api/sendingdomains/SendingDomainsImplTest.javasrc/test/java/io/mailtrap/api/webhooks/WebhooksImplTest.javasrc/test/resources/api/emaillogs/getEmailLogMessageResponse.jsonsrc/test/resources/api/emaillogs/listEmailLogsResponse.jsonsrc/test/resources/api/inbound/createInboundFolderRequest.jsonsrc/test/resources/api/inbound/createInboundFolderResponse.jsonsrc/test/resources/api/inbound/createInboundInboxRequest.jsonsrc/test/resources/api/inbound/createInboundInboxResponse.jsonsrc/test/resources/api/inbound/forwardInboundMessageRequest.jsonsrc/test/resources/api/inbound/getInboundFolderResponse.jsonsrc/test/resources/api/inbound/getInboundInboxResponse.jsonsrc/test/resources/api/inbound/getInboundMessageResponse.jsonsrc/test/resources/api/inbound/getInboundThreadResponse.jsonsrc/test/resources/api/inbound/listInboundFoldersResponse.jsonsrc/test/resources/api/inbound/listInboundInboxesResponse.jsonsrc/test/resources/api/inbound/listInboundMessagesResponse.jsonsrc/test/resources/api/inbound/listInboundThreadsResponse.jsonsrc/test/resources/api/inbound/replyAllInboundMessageRequest.jsonsrc/test/resources/api/inbound/replyInboundMessageRequest.jsonsrc/test/resources/api/inbound/sendInboundMessageResponse.jsonsrc/test/resources/api/inbound/updateInboundFolderRequest.jsonsrc/test/resources/api/inbound/updateInboundFolderResponse.jsonsrc/test/resources/api/inbound/updateInboundInboxRequest.jsonsrc/test/resources/api/inbound/updateInboundInboxResponse.jsonsrc/test/resources/api/sending_domains/sendingDomainResponse.jsonsrc/test/resources/api/webhooks/createInboundWebhookRequest.jsonsrc/test/resources/api/webhooks/createInboundWebhookResponse.json
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds Inbound Email API support to the Java SDK, matching the released Node, Ruby, MCP, PHP, and Python SDKs. Exposed as
client.inboundApi()(token-scoped — noaccountIdrequired, mirroringgeneralApi()).client.inboundApi().folders():getList/getById/create/update/deleteclient.inboundApi().inboxes(): folder-scoped CRUD (createtakes optionaldomainId)client.inboundApi().messages():list(cursor vialastId) /get/delete+reply/replyAll/forward(send real email)client.inboundApi().threads():list/get/deleteAlso carries the other fields that ship with the Inbound Email API:
EmailLogMessage/EmailLogMessageSummary:rfcMessageId,inReplyTo,references,threadIdSendingDomainsResponse:inboundEnabled,inboundVerifiedinboundInboxIdonWebhook(response) andWebhookInput(create/update request), plus a newWebhookType.INBOUND_RECEIVING— optional, forinbound_receivingwebhooksNotes
/api/inbound/...; path ids (folder/inbox/message/thread) are method parameters, and the*Implclasses setapiHost = Constants.GENERAL_HOST.reply/replyAll/forwardreuseAddressandEmailAttachment;InboundForwardRequestrequires at least onetorecipient (validated via@NotEmpty).visibilityStatus→InboundMessageVisibilityStatus,direction→InboundMessageDirection, anddeliveryStatusreuses the email-logMessageStatus(same backenddelivery_statusfield).WebhookType.INBOUND_RECEIVINGwas previously missing; without it the SDK could not create inbound webhooks and would throw when deserializing one.Summary by CodeRabbit
New Features
Documentation