-
Notifications
You must be signed in to change notification settings - Fork 3
Updated imports and namings for Java SDK examples #6
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
base: main
Are you sure you want to change the base?
Updated imports and namings for Java SDK examples #6
Conversation
|
Warning Rate limit exceeded@vitalii-t has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 12 minutes and 49 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThese changes update multiple OpenAPI specification files to refactor Java client API method signatures, reorganize API surface paths, introduce new request classes, and add account-scoped parameter patterns. Changes span email, contacts, and account management APIs. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~75 minutes Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (3)
specs/contacts.openapi.yml (2)
1506-1515: Missing import statement forCreateUpdateContactListRequest.The code uses
CreateUpdateContactListRequestat line 1515, but the import statement is not included in this snippet. This will cause a compilation error.🔎 Proposed fix
import io.mailtrap.config.MailtrapConfig; import io.mailtrap.factory.MailtrapClientFactory; +import io.mailtrap.model.request.contactlists.CreateUpdateContactListRequest; var config = new MailtrapConfig.Builder().token("YOUR_API_KEY").build();
934-942: Fix Java method name for consistency with other endpoints.Line 942 uses
client.contactsApi().exports().get(...)but should usecontactExports()to match the pattern used elsewhere in the file (line 842:contactExports().createContactExport(...)). All other sub-API methods follow the naming conventioncontactsApi().<resourceType>()(e.g.,contactEvents(),contactImports(),contactLists(),contactFields()).specs/sandbox.openapi.yml (1)
3726-3736: Java HTML analysis example usesmessageIdwithout declaring itIn the Java sample for
/messages/{message_id}/analyze,messageIdis passed togetMessageHtmlAnalysis(accountId, inboxId, messageId)but is never declared in the snippet, unlike other nearby Java examples that define bothinboxIdandmessageId.Add a declaration, e.g.:
long inboxId = 12345L; +long messageId = 67890L; var htmlAnalysis = client.testingApi().messages() - .getMessageHtmlAnalysis(accountId, inboxId, messageId); + .getMessageHtmlAnalysis(accountId, inboxId, messageId);so the example is self‑contained and consistent with the other message‑level snippets.
🧹 Nitpick comments (4)
specs/sandbox.openapi.yml (1)
190-210: Java sandbox samples now passaccountIdbut never show how it’s definedAll updated Java examples under
client.testingApi().*now takeaccountId(and oftenprojectId/inboxId/messageId) explicitly, which matches the REST paths, but none of these snippets declareaccountId. That makes the samples non-compilable when copy‑pasted.Consider adding a short declaration (or a comment) in each snippet, e.g.:
long accountId = 12345L; // your Mailtrap account IDand similarly for
projectId,inboxId,messageId,attachmentIdwhere they are first introduced. This will align the Java samples with the more explicit PHP/Ruby examples and avoid confusion.Please double‑check the Java client docs or signatures to ensure these parameter orders (
accountId, inboxId, messageId, ...) match the latest SDK before updating all snippets.Also applies to: 310-323, 429-445, 547-568, 686-702, 843-865, 972-988, 1369-1385, 1488-1504, 1607-1623, 1726-1742, 1955-1970, 2539-2557, 2779-2803, 2991-3009, 3215-3235, 3558-3570, 3838-3850, 3996-4008, 4129-4141, 4264-4275, 4422-4434, 4667-4679, 4795-4806
specs/email-api.openapi.yml (1)
1177-1189: Java create‑template example: add imports and tidy the new request constructionThe switch to
CreateEmailTemplateRequest+EmailTemplatematches the new Java client model, but the snippet:
- Uses
CreateEmailTemplateRequestandEmailTemplatewithout showing their imports.- Has formatting that makes the nested constructor harder to read.
Consider something like:
import io.mailtrap.config.MailtrapConfig; import io.mailtrap.factory.MailtrapClientFactory; import io.mailtrap.model.request.emails.EmailTemplate; import io.mailtrap.model.request.emails.CreateEmailTemplateRequest; var config = new MailtrapConfig.Builder() .token("YOUR_API_TOKEN") .build(); var client = MailtrapClientFactory.createMailtrapClient(config); long accountId = 12345L; // your account ID var request = new CreateEmailTemplateRequest( new EmailTemplate( "Welcome Email", "onboarding", "Welcome to {{company_name}}!", "Welcome {{user_name}}!", "<h1>Welcome {{user_name}}!</h1>" ) ); var template = client.emailTemplatesApi() .emailTemplates() .createEmailTemplate(accountId, request);which is more copy‑pasteable for users.
Please verify the fully‑qualified class names and constructor parameter order for
EmailTemplateandCreateEmailTemplateRequestagainst the Java SDK.specs/general.openapi.yml (2)
173-180: Java general‑API samples: new method names look correct, but IDs are implicitly definedAcross these Java snippets you’ve:
- Switched to
MailtrapClientFactory.createMailtrapClient(config)andclient.generalApi()usage.- Updated methods to
getAllAccounts(),listUserAndInviteAccountAccesses(...),removeAccountAccess(...),getResources(accountId), andgetCurrentBillingCycleUsage(accountId).This aligns with the described Java SDK refactor. The only gap is that
accountId/accessIdare used but never introduced; a brief declaration per snippet (or a comment likelong accountId = 12345L;) would make these examples self‑contained and easier to copy.Please confirm the new method names and argument order (
accountIdvsaccessId) with the Java SDK to avoid drift between docs and client code.Also applies to: 272-280, 377-384, 634-641, 748-755
491-511: JavamanagePermissionsexample: missingListimport and minor clarity improvementThe
ManagePermissionsRequest+Permissionusage is good, but:
List.of(...)is used without showing an import forjava.util.List.- It may help to comment what
falsein thePermissionconstructor represents (e.g.,_destroyflag).You could make the snippet more explicit:
import java.util.List; import io.mailtrap.model.AccessLevel; import io.mailtrap.model.ResourceType; import io.mailtrap.model.request.permissions.ManagePermissionsRequest; import io.mailtrap.model.request.permissions.Permission; long accountId = 12345L; long accessId = 67890L; var request = new ManagePermissionsRequest( List.of( new Permission( "3281", ResourceType.ACCOUNT, AccessLevel.VIEWER, false // do not destroy; create or update ) ) ); client.generalApi() .permissions() .managePermissions(accessId, accountId, request);so users can paste it directly into a Java project.
Please verify the constructor signature for
Permissionand the ordering of parameters inmanagePermissionsagainst the Java client library.
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
specs/contacts.openapi.ymlspecs/email-api.openapi.ymlspecs/email-batch.openapi.ymlspecs/email-sending-bulk.openapi.ymlspecs/email-sending-transactional.openapi.ymlspecs/general.openapi.ymlspecs/sandbox.openapi.yml
🧰 Additional context used
📓 Path-based instructions (1)
specs/**/*.openapi.yml
📄 CodeRabbit inference engine (CLAUDE.md)
specs/**/*.openapi.yml: Base URLs must never be changed in OpenAPI specs. Usehttps://send.api.mailtrap.iofor transactional emails,https://bulk.api.mailtrap.iofor bulk emails, andhttps://mailtrap.iofor all other APIs
All documentation links in OpenAPI specs must be absolute URLs pointing to docs.mailtrap.io, not relative links or help.mailtrap.io
Update contact URLs in specinfoblocks to usehttps://docs.mailtrap.io, not help.mailtrap.io
Use GitBook markdown syntax in OpenAPI description fields, ensuring all blocks are properly closed:{% hint %}...{% endhint %}and{% tab %}...{% endtab %}
Tabs cannot be nested inside details blocks when using GitBook syntax in OpenAPI descriptions
Include code samples inx-codeSamplesin this priority order: Node.js, PHP, Python, Ruby, .NET, Java, cURL
Use official Mailtrap SDKs for language-specific code samples inx-codeSamples, with Node.js (mailtrap/mailtrap-nodejs), PHP (railsware/mailtrap-php), Python (railsware/mailtrap-python), and Ruby (railsware/mailtrap-ruby)
Use environment variables for API keys in code samples (e.g.,process.env.MAILTRAP_API_KEY)
Validate YAML syntax, OpenAPI 3.1 compliance, base URLs, contact URLs, GitBook blocks, links, and code samples before committing OpenAPI spec changes
Do not use emojis in specification content
Keep OpenAPI descriptions concise and developer-focused, with technical accuracy prioritized
Use custom OpenAPI extensions for GitBook navigation:x-page-title,x-page-icon,x-page-description,x-parent,x-codeSamples, andx-logo
Structure tags withx-page-title,x-page-description, andx-parentfor GitBook nested navigation in OpenAPI specs
Use official product naming: 'Email API/SMTP' (can shorten to 'Email API' or 'API/SMTP'), 'Email Sandbox' (can shorten to 'Sandbox'), 'Email Marketing' (can shorten to 'Marketing')
Files:
specs/email-sending-transactional.openapi.ymlspecs/email-api.openapi.ymlspecs/email-batch.openapi.ymlspecs/sandbox.openapi.ymlspecs/contacts.openapi.ymlspecs/general.openapi.ymlspecs/email-sending-bulk.openapi.yml
🧠 Learnings (8)
📓 Common learnings
Learnt from: CR
Repo: mailtrap/mailtrap-openapi PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-23T11:20:58.562Z
Learning: Applies to specs/**/*.openapi.yml : Use official Mailtrap SDKs for language-specific code samples in `x-codeSamples`, with Node.js (mailtrap/mailtrap-nodejs), PHP (railsware/mailtrap-php), Python (railsware/mailtrap-python), and Ruby (railsware/mailtrap-ruby)
Learnt from: CR
Repo: mailtrap/mailtrap-openapi PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-23T11:20:58.562Z
Learning: Applies to specs/**/*.openapi.yml : Use official product naming: 'Email API/SMTP' (can shorten to 'Email API' or 'API/SMTP'), 'Email Sandbox' (can shorten to 'Sandbox'), 'Email Marketing' (can shorten to 'Marketing')
📚 Learning: 2025-12-23T11:20:58.562Z
Learnt from: CR
Repo: mailtrap/mailtrap-openapi PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-23T11:20:58.562Z
Learning: Applies to specs/**/*.openapi.yml : Base URLs must never be changed in OpenAPI specs. Use `https://send.api.mailtrap.io` for transactional emails, `https://bulk.api.mailtrap.io` for bulk emails, and `https://mailtrap.io` for all other APIs
Applied to files:
specs/email-sending-transactional.openapi.ymlspecs/email-batch.openapi.ymlspecs/sandbox.openapi.ymlspecs/general.openapi.ymlspecs/email-sending-bulk.openapi.yml
📚 Learning: 2025-12-23T11:20:58.562Z
Learnt from: CR
Repo: mailtrap/mailtrap-openapi PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-23T11:20:58.562Z
Learning: Applies to specs/**/*.openapi.yml : Use official Mailtrap SDKs for language-specific code samples in `x-codeSamples`, with Node.js (mailtrap/mailtrap-nodejs), PHP (railsware/mailtrap-php), Python (railsware/mailtrap-python), and Ruby (railsware/mailtrap-ruby)
Applied to files:
specs/email-sending-transactional.openapi.ymlspecs/email-api.openapi.ymlspecs/email-batch.openapi.ymlspecs/sandbox.openapi.ymlspecs/contacts.openapi.ymlspecs/general.openapi.ymlspecs/email-sending-bulk.openapi.yml
📚 Learning: 2025-12-23T11:20:58.562Z
Learnt from: CR
Repo: mailtrap/mailtrap-openapi PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-23T11:20:58.562Z
Learning: Applies to specs/**/*.openapi.yml : Update contact URLs in spec `info` blocks to use `https://docs.mailtrap.io`, not help.mailtrap.io
Applied to files:
specs/email-sending-transactional.openapi.ymlspecs/sandbox.openapi.ymlspecs/contacts.openapi.ymlspecs/general.openapi.ymlspecs/email-sending-bulk.openapi.yml
📚 Learning: 2025-12-23T11:20:58.562Z
Learnt from: CR
Repo: mailtrap/mailtrap-openapi PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-23T11:20:58.562Z
Learning: Applies to specs/**/*.openapi.yml : Use official product naming: 'Email API/SMTP' (can shorten to 'Email API' or 'API/SMTP'), 'Email Sandbox' (can shorten to 'Sandbox'), 'Email Marketing' (can shorten to 'Marketing')
Applied to files:
specs/email-api.openapi.ymlspecs/sandbox.openapi.yml
📚 Learning: 2025-12-23T11:20:58.562Z
Learnt from: CR
Repo: mailtrap/mailtrap-openapi PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-23T11:20:58.562Z
Learning: Applies to specs/**/*.openapi.yml : Use environment variables for API keys in code samples (e.g., `process.env.MAILTRAP_API_KEY`)
Applied to files:
specs/sandbox.openapi.yml
📚 Learning: 2025-12-23T11:20:58.562Z
Learnt from: CR
Repo: mailtrap/mailtrap-openapi PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-23T11:20:58.562Z
Learning: Applies to specs/**/*.openapi.yml : All documentation links in OpenAPI specs must be absolute URLs pointing to docs.mailtrap.io, not relative links or help.mailtrap.io
Applied to files:
specs/sandbox.openapi.yml
📚 Learning: 2025-12-23T11:20:58.562Z
Learnt from: CR
Repo: mailtrap/mailtrap-openapi PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-23T11:20:58.562Z
Learning: Applies to specs/**/*.openapi.yml : Validate YAML syntax, OpenAPI 3.1 compliance, base URLs, contact URLs, GitBook blocks, links, and code samples before committing OpenAPI spec changes
Applied to files:
specs/sandbox.openapi.yml
🔇 Additional comments (20)
specs/email-sending-transactional.openapi.yml (1)
147-167: LGTM!The Java SDK example is well-structured with correct imports and the client instantiation is clean. The API method chain
client.sendingApi().emails().send(mail)follows the expected SDK pattern.specs/contacts.openapi.yml (15)
207-235: LGTM!The Java SDK example correctly imports the new
CreateContactRequestclass fromio.mailtrap.model.request.contactspackage and usesHashMapfor fields construction. The API call patternclient.contactsApi().contacts().createContact(accountId, request)is consistent with the new SDK structure.
514-526: LGTM!The update contact example correctly uses
Map.of()for immutable map creation and theUpdateContactRequestwrapper pattern. The API method signatureupdateContact(accountId, "contact_id_or_email", request)properly accepts the contact identifier as a string parameter.
623-632: LGTM!The delete contact example is clean and correctly uses the simplified pattern without unnecessary imports.
715-728: LGTM!The contact event creation example correctly imports
CreateContactEventRequestfrom thecontacteventspackage and uses the proper sub-API pathcontactsApi().contactEvents().createContactEvent(...).
827-842: LGTM!The contact export example properly imports the filter classes (
ContactExportFilter,ContactExportFilterOperator,CreateContactsExportRequest) and demonstrates the factory method patternContactExportFilter.listIds(...)for building filters.
1056-1067: LGTM!The import contacts example correctly uses the new request model classes from
io.mailtrap.model.request.contactimportspackage with properContactandImportContactsRequesttypes.
1163-1170: LGTM!The get contact import example is clean with the proper API call pattern.
1256-1264: LGTM!The contact lists retrieval example correctly uses
contactLists().findAll(accountId)method.
1340-1349: LGTM!The create contact list example properly imports and uses
CreateUpdateContactListRequest.
1431-1440: LGTM!The get contact list example is clean with proper type declaration for
listId.
1594-1603: LGTM!The delete contact list example is clean with proper type handling for
listId.
1670-1679: LGTM!The get all contact fields example is clean with proper API call pattern.
1760-1771: LGTM!The create contact field example correctly imports
ContactFieldDataTypeenum andCreateContactFieldRequest, demonstrating proper usage of the data type constant.
1884-1893: LGTM!The get contact field example is clean with proper type declaration.
1963-1972: LGTM!The update contact field example correctly uses
UpdateContactFieldRequestfor the update payload.specs/email-batch.openapi.yml (1)
205-242: LGTM!The Java SDK example has been correctly updated with the new package structure:
- Imports moved to
io.mailtrap.model.request.emailspackage- Type names are now more explicit (
BatchEmailBase,MailtrapBatchMail,MailtrapMail)- Builder pattern usage is consistent and correct
- The API call
client.sendingApi().emails().batchSend(batchMail)follows the expected SDK patternspecs/email-sending-bulk.openapi.yml (1)
170-197: LGTM!The Java SDK example correctly reflects the updated SDK structure:
- Imports moved to
io.mailtrap.model.request.emailspackage- Client instantiation is clean with bulk mode enabled via
.bulk(true)- The API method rename from
bulkApi()tobulkSendingApi()is more descriptive and consistent with the naming conventionThe base URL
https://bulk.api.mailtrap.iois correctly used for bulk sending as per the coding guidelines.specs/email-api.openapi.yml (2)
1059-1065: Java: updatedgetAllTemplatesusage looks consistent with new API surfaceUsing
client.emailTemplatesApi().emailTemplates().getAllTemplates(accountId)matches the described Java SDK refactor (emailTemplates API + renamed method). No functional issues spotted, aside from the usual missingaccountIddeclaration noted in the sandbox file review.Please confirm against the current Java SDK (package
io.mailtrap.*) thatemailTemplates().getAllTemplates(long accountId)is the correct signature.
828-853: Java suppressions example: additionalfilteredloop is fineThe added
filtered.forEachblock correctly demonstrates how to iterate over the filtered result set separately from the fullsuppressionslist. No issues with the structure of the sample.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.