Skip to content

Update sandboxes api#103

Open
IgorDobryn wants to merge 2 commits intomainfrom
MT-21830-sandboxes-api
Open

Update sandboxes api#103
IgorDobryn wants to merge 2 commits intomainfrom
MT-21830-sandboxes-api

Conversation

@IgorDobryn
Copy link
Copy Markdown
Contributor

@IgorDobryn IgorDobryn commented Apr 27, 2026

Motivation

Changes

  • Add handler for toggle_email_username endpoint
  • Add handler for reset_email_username

Summary by CodeRabbit

Release Notes

  • New Features
    • Added the ability to toggle email username state for inboxes
    • Added the ability to reset email username credentials for inboxes

@IgorDobryn IgorDobryn requested a review from Copilot April 27, 2026 13:53
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 27, 2026

📝 Walkthrough

Walkthrough

Two new public methods are added to InboxesAPI: toggle_email_username and reset_email_username. Both perform PATCH requests to inbox-scoped endpoints and return Inbox objects. The implementation includes comprehensive test coverage with VCR cassettes and example usage.

Changes

Cohort / File(s) Summary
API Implementation
lib/mailtrap/inboxes_api.rb
Added two new public methods: toggle_email_username(inbox_id) and reset_email_username(inbox_id), each performing a PATCH request and returning an Inbox object.
Example Script
examples/inboxes_api.rb
Updated to demonstrate the new toggle_email_username and reset_email_username methods called after credential reset and before inbox deletion.
Test Specifications
spec/mailtrap/inboxes_api_spec.rb
Added test cases for both new methods covering success responses and error handling (404 Not Found for non-existent inboxes).
VCR Cassette Fixtures
spec/fixtures/vcr_cassettes/Mailtrap_InboxesAPI/_toggle_email_username/*, spec/fixtures/vcr_cassettes/Mailtrap_InboxesAPI/_reset_email_username/*
Four new recorded API interaction fixtures capturing successful PATCH requests and 404 error responses for each new method.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • Add Inboxes API #80: Directly introduces the same two new inbox-scoped PATCH methods (toggle_email_username and reset_email_username) to the Mailtrap::InboxesAPI class with complete test coverage.

Suggested reviewers

  • i7an

Poem

🐰 Two new methods hop into place,
Toggle and reset with such grace!
Inbox usernames dance and spin,
While VCR cassettes record the win! ✨
Tests pass bright, from corner to ledge.

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (2 warnings, 1 inconclusive)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title 'Update sandboxes api' is misleading—the PR actually adds handlers for inbox email username operations (toggle and reset), not sandbox API functionality. Rename the title to accurately reflect the changes, such as 'Add inbox email username toggle and reset endpoints' or 'Add toggle_email_username and reset_email_username to InboxesAPI'.
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The description is incomplete—the Motivation section is empty, and while Changes are listed, they lack detail about what these endpoints do or why they were added. Fill in the Motivation section to explain why these endpoints are needed, and expand the Changes section with more context about the new functionality.
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch MT-21830-sandboxes-api

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@spec/fixtures/vcr_cassettes/Mailtrap_InboxesAPI/_reset_email_username/returns_Inbox_object.yml`:
- Around line 71-73: The cassette payload contains real account-identifying
fields: replace the values for "username" and "forward_from_email_address"
inside the JSON string (the value of the "string" field) with synthetic/redacted
values (e.g. "username":"redacted_user" and
"forward_from_email_address":"redacted@example.com") so the fixture no longer
contains PII; update any similar fields like "email_username" if needed and keep
the JSON structure intact.

In
`@spec/fixtures/vcr_cassettes/Mailtrap_InboxesAPI/_toggle_email_username/returns_Inbox_object.yml`:
- Around line 71-73: The recorded response in the fixture string contains real
identity fields ("username" and "forward_from_email_address"); update the
serialized JSON in the fixture (the string value containing "username":
"railsware" and "forward_from_email_address": "railsware@forward.mailtrap.info")
to use sanitized placeholders (e.g., "username":"REDACTED_USERNAME" and
"forward_from_email_address":"redacted@forward.mailtrap.info") so the cassette
no longer contains real PII while preserving the rest of the Inbox object
structure.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 25a3daf8-78d5-42c6-81da-a6c095cce9e9

📥 Commits

Reviewing files that changed from the base of the PR and between d7ed334 and ac8b24c.

📒 Files selected for processing (7)
  • examples/inboxes_api.rb
  • lib/mailtrap/inboxes_api.rb
  • spec/fixtures/vcr_cassettes/Mailtrap_InboxesAPI/_reset_email_username/returns_Inbox_object.yml
  • spec/fixtures/vcr_cassettes/Mailtrap_InboxesAPI/_reset_email_username/when_inbox_does_not_exist/raises_not_found_error.yml
  • spec/fixtures/vcr_cassettes/Mailtrap_InboxesAPI/_toggle_email_username/returns_Inbox_object.yml
  • spec/fixtures/vcr_cassettes/Mailtrap_InboxesAPI/_toggle_email_username/when_inbox_does_not_exist/raises_not_found_error.yml
  • spec/mailtrap/inboxes_api_spec.rb

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for two additional Inbox sandbox endpoints in the Ruby SDK and covers them with VCR-backed specs.

Changes:

  • Add toggle_email_username and reset_email_username methods to Mailtrap::InboxesAPI.
  • Add RSpec coverage (success + not-found cases) for both new endpoints.
  • Add example usage and VCR cassettes for the new requests.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
lib/mailtrap/inboxes_api.rb Adds two PATCH helpers for toggling/resetting the inbox email username feature.
spec/mailtrap/inboxes_api_spec.rb Adds specs validating returned Inbox attributes and 404 error behavior for the new endpoints.
examples/inboxes_api.rb Demonstrates calling the new API methods.
spec/fixtures/vcr_cassettes/Mailtrap_InboxesAPI/_toggle_email_username/when_inbox_does_not_exist/raises_not_found_error.yml Records 404 response for toggle endpoint.
spec/fixtures/vcr_cassettes/Mailtrap_InboxesAPI/_toggle_email_username/returns_Inbox_object.yml Records 200 response for toggle endpoint.
spec/fixtures/vcr_cassettes/Mailtrap_InboxesAPI/_reset_email_username/when_inbox_does_not_exist/raises_not_found_error.yml Records 404 response for reset endpoint.
spec/fixtures/vcr_cassettes/Mailtrap_InboxesAPI/_reset_email_username/returns_Inbox_object.yml Records 200 response for reset endpoint.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread examples/inboxes_api.rb
handle_response(response)
end

# Turn the email address of the inbox on/off
Copy link

Copilot AI Apr 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docstring says this toggles the inbox “email address”, but the endpoint/method name indicates it toggles the inbox email username feature (see email_username_enabled). Please adjust the wording to match the actual behavior to avoid confusing API consumers.

Suggested change
# Turn the email address of the inbox on/off
# Turn the email username of the inbox on/off

Copilot uses AI. Check for mistakes.
Comment thread lib/mailtrap/inboxes_api.rb
Comment thread spec/mailtrap/inboxes_api_spec.rb
Comment thread spec/mailtrap/inboxes_api_spec.rb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants