-
Notifications
You must be signed in to change notification settings - Fork 7
Add Sending domains API #81
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?
Conversation
📝 WalkthroughWalkthroughAdds Sending Domains support: new Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant SendingDomainsAPI as Mailtrap::SendingDomainsAPI
participant MailtrapAPI as mailtrap.io API
Client->>SendingDomainsAPI: create(sending_domain)
SendingDomainsAPI->>MailtrapAPI: POST /api/accounts/{account_id}/sending_domains
MailtrapAPI-->>SendingDomainsAPI: 200 OK (sending_domain JSON)
SendingDomainsAPI-->>Client: SendingDomain object
Client->>SendingDomainsAPI: list()
SendingDomainsAPI->>MailtrapAPI: GET /api/accounts/{account_id}/sending_domains
MailtrapAPI-->>SendingDomainsAPI: 200 OK [sending_domain...]
SendingDomainsAPI-->>Client: [SendingDomain objects]
Client->>SendingDomainsAPI: send_setup_instructions(id, email)
SendingDomainsAPI->>MailtrapAPI: POST /api/accounts/{account_id}/sending_domains/{id}/send_setup_instructions
MailtrapAPI-->>SendingDomainsAPI: 204 No Content
SendingDomainsAPI-->>Client: nil
Client->>SendingDomainsAPI: delete(id)
SendingDomainsAPI->>MailtrapAPI: DELETE /api/accounts/{account_id}/sending_domains/{id}
MailtrapAPI-->>SendingDomainsAPI: 204 No Content
SendingDomainsAPI-->>Client: nil
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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 |
examples/sending_domains_api.rb
Outdated
| # => #<struct Mailtrap::SendingDomain id=1, domain_name="proper.com"> | ||
|
|
||
| # Send setup email | ||
| sending_domains.clean(sending_domain.id, '[email protected]') |
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.
what is clean?
| # @attr_reader created_at [String] The creation timestamp | ||
| # @attr_reader updated_at [String] The last update timestamp | ||
| # | ||
| SendingDomain = Struct.new( |
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.
there are much more fields that our api returns
| keyword_init: true | ||
| ) do | ||
| # @return [Hash] The SendingDomain attributes as a hash | ||
| def to_h |
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.
rm
| class SendingDomainsAPI | ||
| include BaseAPI | ||
|
|
||
| self.supported_options = %i[domain_name] |
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.
minor. Domain name can be specified only on creation. I'd maybe considered specifying it explicitly when calling base_create.
| # @return nil | ||
| # @!macro api_errors | ||
| def send_setup_instructions(domain_id, email) | ||
| client.post("#{base_path}/#{domain_id}/send_setup_instructions", { email: email }) |
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.
handle the response
| # @param email [String] The email for instructions | ||
| # @return nil | ||
| # @!macro api_errors | ||
| def send_setup_instructions(domain_id, email) |
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.
lets use kwargs for email for consistency. see list(email: nil) in suppressions api
| end | ||
| end | ||
|
|
||
| describe '#to_h' do |
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.
rm
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: 4
🤖 Fix all issues with AI agents
In `@examples/sending_domains_api.rb`:
- Around line 23-25: The example calls the wrong method: replace the call to
sending_domains.clean with sending_domains.send_setup_instructions so it matches
the API spec; update the invocation that currently passes sending_domain.id and
'[email protected]' to call send_setup_instructions(sending_domain.id,
'[email protected]') and ensure the example comment remains accurate.
- Line 5: The example instantiates the wrong API class: replace the
instantiation of Mailtrap::InboxesAPI with Mailtrap::SendingDomainsAPI for the
sending_domains variable so it uses the correct client; update the line that
creates sending_domains (currently referencing Mailtrap::InboxesAPI) to use
Mailtrap::SendingDomainsAPI while keeping the account_id and client arguments
unchanged.
In
`@spec/fixtures/vcr_cassettes/Mailtrap_SendingDomainsAPI/_send_setup_instructions/returns_nil.yml`:
- Around line 6-8: The cassette contains a real developer email in the recorded
request body; replace the literal string "[email protected]" in
the fixture content
(spec/fixtures/vcr_cassettes/Mailtrap_SendingDomainsAPI/_send_setup_instructions/returns_nil.yml
— the body.string value) with an anonymized test address like "[email protected]"
to remove PII while preserving the fixture structure.
In
`@spec/fixtures/vcr_cassettes/Mailtrap_SendingDomainsAPI/_send_setup_instructions/when_sending_domain_does_not_exist/raises_not_found_error.yml`:
- Around line 6-8: The fixture contains a real email in the VCR cassette
body.string; update the value '{"email":"[email protected]"}'
to use a placeholder/test address (e.g. [email protected]) so the body.string
entry in the Mailtrap_SendingDomainsAPI cassette no longer exposes a real
developer email.
🧹 Nitpick comments (4)
lib/mailtrap/sending_domains_api.rb (1)
53-55: Consider validating the email parameter.The
♻️ Optional: Add email presence validation
def send_setup_instructions(domain_id, email) + raise ArgumentError, 'email is required' if email.nil? || email.to_s.strip.empty? + client.post("#{base_path}/#{domain_id}/send_setup_instructions", { email: email }) endspec/mailtrap/sending_domain_spec.rb (2)
33-42: Remove unusedprojectvariable.The
projectvariable is defined but never used in the test. The actual test usessending_domaindefined in the context block. This appears to be leftover code, possibly from copy-paste.🧹 Proposed fix to remove dead code
describe '#to_h' do subject(:hash) { sending_domain.to_h } - let(:project) do - described_class.new( - id: '123456', - domain_name: 'My Sending Domain', - dns_verified: false, - compliance_status: 'pending', - created_at: '2024-01-01T00:00:00Z', - updated_at: '2024-01-02T00:00:00Z' - ) - end - context 'when some attributes are nil' do
44-64: Consider adding test coverage forto_hwhen all attributes are present.The
#to_htests only cover the case when some attributes are nil. Consider adding a test case verifying that all attributes are included in the hash when none are nil.💡 Suggested additional test case
context 'when all attributes are present' do let(:sending_domain) do described_class.new( id: '123456', domain_name: 'My Sending Domain', dns_verified: false, compliance_status: 'pending', created_at: '2024-01-01T00:00:00Z', updated_at: '2024-01-02T00:00:00Z' ) end it 'returns a hash with all attributes' do expect(hash).to eq( id: '123456', domain_name: 'My Sending Domain', dns_verified: false, compliance_status: 'pending', created_at: '2024-01-01T00:00:00Z', updated_at: '2024-01-02T00:00:00Z' ) end endspec/mailtrap/sending_domains_api_spec.rb (1)
125-127: Test description doesn't match the expectation.The test is named
'returns deleted sending domain data'but it expectsnil. Consider renaming to accurately describe the behavior, such as'returns nil on successful deletion'.📝 Proposed fix
- it 'returns deleted sending domain data' do + it 'returns nil on successful deletion' do expect(delete).to be_nil end
| body: | ||
| encoding: UTF-8 | ||
| string: '{"email":"[email protected]"}' |
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.
Same privacy concern: consider anonymizing the email address.
As noted in the other cassette, replace the developer email with a test email like [email protected].
🤖 Prompt for AI Agents
In
`@spec/fixtures/vcr_cassettes/Mailtrap_SendingDomainsAPI/_send_setup_instructions/returns_nil.yml`
around lines 6 - 8, The cassette contains a real developer email in the recorded
request body; replace the literal string "[email protected]" in
the fixture content
(spec/fixtures/vcr_cassettes/Mailtrap_SendingDomainsAPI/_send_setup_instructions/returns_nil.yml
— the body.string value) with an anonymized test address like "[email protected]"
to remove PII while preserving the fixture structure.
| body: | ||
| encoding: UTF-8 | ||
| string: '{"email":"[email protected]"}' |
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.
Consider anonymizing the email address in test fixtures.
The request body contains what appears to be a real developer email address. For privacy and to avoid potential spam, consider replacing it with a test/placeholder email like [email protected].
🤖 Prompt for AI Agents
In
`@spec/fixtures/vcr_cassettes/Mailtrap_SendingDomainsAPI/_send_setup_instructions/when_sending_domain_does_not_exist/raises_not_found_error.yml`
around lines 6 - 8, The fixture contains a real email in the VCR cassette
body.string; update the value '{"email":"[email protected]"}'
to use a placeholder/test address (e.g. [email protected]) so the body.string
entry in the Mailtrap_SendingDomainsAPI cassette no longer exposes a real
developer email.
c5248e9 to
465d4f4
Compare
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
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: 4
🤖 Fix all issues with AI agents
In `@examples/sending_domains_api.rb`:
- Around line 23-25: Replace the real-looking example email passed to
sending_domains.send_setup_instructions (call site uses sending_domain.id and
'[email protected]') with a non-real placeholder such as '[email protected]' or
'[email protected]' so the example stays safe and generic; update the argument
to the send_setup_instructions call accordingly.
- Around line 15-17: Add a public update wrapper to SendingDomainsAPI so
examples calling sending_domains.update(...) don't raise NoMethodError:
implement a method named update in the SendingDomainsAPI class that accepts
domain_id and options and delegates to the existing base_update(domain_id,
options), matching other API operation wrappers.
In `@lib/mailtrap/sending_domain.rb`:
- Around line 4-25: The SendingDomain DTO (Struct named SendingDomain) omits API
fields and silently drops data; add :dns_records, :dns_verified_at, and
:permissions to the Struct.new(...) declaration (keeping keyword_init: true) so
incoming API responses map fully to the DTO, and ensure the existing to_h method
continues to return the compacted hash of all attributes.
In
`@spec/fixtures/vcr_cassettes/Mailtrap_SendingDomainsAPI/_get/when_sending_domain_does_not_exist/raises_not_found_error.yml`:
- Around line 5-70: The cassette contains sensitive account and trace/request
IDs (e.g. account "1111111" in the URI and X-Request-Id / X-Cloud-Trace-Context
/ Cf-Ray headers) — update your VCR configuration (e.g. in your VCR.configure
block in spec helper or spec/support/vcr.rb) to scrub these before recording:
add VCR.filter_sensitive_data('<ACCOUNT_ID>') { '1111111' } or a regex-based
replacement for account IDs in request URIs, and add filters or a before_record
hook to replace header values like X-Request-Id, X-Cloud-Trace-Context and
Cf-Ray with placeholders (e.g. '<X_REQUEST_ID>', '<TRACE_CONTEXT>', '<CF_RAY>');
re-run tests to regenerate the cassette with redacted values and commit the
updated fixture
(spec/fixtures/vcr_cassettes/Mailtrap_SendingDomainsAPI/_get/when_sending_domain_does_not_exist/raises_not_found_error.yml).
🧹 Nitpick comments (1)
spec/mailtrap/sending_domains_api_spec.rb (1)
9-27: Consider asserting additional mapped fields.Once the DTO includes
dns_recordsandpermissions, it would be valuable to assert these in the list mapping so regressions are caught early.
| # Data Transfer Object for Sending Domain | ||
| # @see https://docs.mailtrap.io/developers/management/sending-domains | ||
| # @attr_reader id [Integer] The sending domain ID | ||
| # @attr_reader domain_name [String] The sending domain name | ||
| # @attr_reader dns_verified [Boolean] Whether the DNS is verified | ||
| # @attr_reader compliance_status [String] The compliance status | ||
| # @attr_reader created_at [String] The creation timestamp | ||
| # @attr_reader updated_at [String] The last update timestamp | ||
| # | ||
| SendingDomain = Struct.new( | ||
| :id, | ||
| :domain_name, | ||
| :dns_verified, | ||
| :compliance_status, | ||
| :created_at, | ||
| :updated_at, | ||
| keyword_init: true | ||
| ) do | ||
| # @return [Hash] The SendingDomain attributes as a hash | ||
| def to_h | ||
| super.compact | ||
| end |
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.
🧩 Analysis chain
🌐 Web query:
Mailtrap Sending Domains API GET response fields documentation
💡 Result:
Mailtrap documents the GET Sending Domains response schema on the “Sending Domains” Management API page—expand “Show properties” under the 200 → Response object[] section to see the full list of fields returned for each sending domain object. [1]
If you need the schema in a machine-readable form (e.g., for client generation), Mailtrap also publishes their OpenAPI specifications and links to the public GitHub repository from the OpenAPI Specs page. [2]
Relevant docs pages:
- GET
https://mailtrap.io/api/accounts/{account_id}/sending_domains(response:object[]) [1] - GET
https://mailtrap.io/api/accounts/{account_id}/sending_domains/{sending_domain_id}(response:object) [1] - OpenAPI Specs (link to the OpenAPI repository) [2]
Sources: [1] [2]
🏁 Script executed:
# Search for fixtures or test files that might contain SendingDomain data
find . -type f \( -name "*fixture*" -o -name "*test*" -o -name "*.json" \) | head -20Repository: mailtrap/mailtrap-ruby
Length of output: 48
🏁 Script executed:
# Look for references to SendingDomain in the codebase to see how it's used
rg "SendingDomain" -t rb --context 3Repository: mailtrap/mailtrap-ruby
Length of output: 92
🏁 Script executed:
# Check if there are any API response examples or specs
find . -type f -name "*.rb" | xargs grep -l "dns_records\|permissions\|dns_verified_at" | head -10Repository: mailtrap/mailtrap-ruby
Length of output: 214
🏁 Script executed:
# Search for sending_domain related files
find . -type f -name "*sending_domain*"Repository: mailtrap/mailtrap-ruby
Length of output: 471
🏁 Script executed:
# Search for fixture files or test data directories
find . -type d -name "fixtures" -o -type d -name "spec" | head -10Repository: mailtrap/mailtrap-ruby
Length of output: 88
🏁 Script executed:
# Look for YAML or JSON files that might contain API response examples
find . -type f \( -name "*.yml" -o -name "*.yaml" -o -name "*.json" \) | grep -E "(fixture|spec|test)" | head -20Repository: mailtrap/mailtrap-ruby
Length of output: 2430
🏁 Script executed:
# Search for references to the specific fields mentioned in the review
rg "dns_records|permissions|dns_verified_at" --type yaml --type json --type rbRepository: mailtrap/mailtrap-ruby
Length of output: 92
🏁 Script executed:
# Check the actual file and see if there are any comments or references
cat -n lib/mailtrap/sending_domain.rbRepository: mailtrap/mailtrap-ruby
Length of output: 1067
🏁 Script executed:
# Read the fixture file to see what fields are actually returned by the API
cat spec/fixtures/vcr_cassettes/Mailtrap_SendingDomainsAPI/_create/maps_response_data_to_sending_domain_object.ymlRepository: mailtrap/mailtrap-ruby
Length of output: 3245
🏁 Script executed:
# Read the spec file to see how SendingDomain is used
cat spec/mailtrap/sending_domain_spec.rbRepository: mailtrap/mailtrap-ruby
Length of output: 1826
🏁 Script executed:
# Check the SendingDomainsAPI implementation to see how it maps data
cat spec/mailtrap/sending_domains_api_spec.rbRepository: mailtrap/mailtrap-ruby
Length of output: 4198
🏁 Script executed:
# Let's check the SendingDomainsAPI implementation to see how it maps the response
cat -n lib/mailtrap/sending_domains_api.rb | head -100Repository: mailtrap/mailtrap-ruby
Length of output: 2354
🏁 Script executed:
# Check if there's any mapping/conversion happening in the API layer
rg "SendingDomain" lib/ -A 5 -B 5 | head -100Repository: mailtrap/mailtrap-ruby
Length of output: 3611
DTO is missing API fields that cause data loss: dns_records, dns_verified_at, permissions.
The API response includes these fields, but the struct definition omits them. When API responses are mapped to the struct, these values are dropped silently. Add them to maintain full API scope.
🧩 Proposed fix
- # `@attr_reader` compliance_status [String] The compliance status
+ # `@attr_reader` compliance_status [String] The compliance status
+ # `@attr_reader` dns_records [Array<Hash>] DNS records
+ # `@attr_reader` permissions [Hash] Permissions (can_read, can_update, can_destroy)
+ # `@attr_reader` dns_verified_at [String] DNS verification timestamp
# `@attr_reader` created_at [String] The creation timestamp
# `@attr_reader` updated_at [String] The last update timestamp
#
SendingDomain = Struct.new(
:id,
:domain_name,
:dns_verified,
:compliance_status,
+ :dns_records,
+ :permissions,
+ :dns_verified_at,
:created_at,
:updated_at,
keyword_init: true
) do🤖 Prompt for AI Agents
In `@lib/mailtrap/sending_domain.rb` around lines 4 - 25, The SendingDomain DTO
(Struct named SendingDomain) omits API fields and silently drops data; add
:dns_records, :dns_verified_at, and :permissions to the Struct.new(...)
declaration (keeping keyword_init: true) so incoming API responses map fully to
the DTO, and ensure the existing to_h method continues to return the compacted
hash of all attributes.
| uri: https://mailtrap.io/api/accounts/1111111/sending_domains/-1 | ||
| body: | ||
| encoding: US-ASCII | ||
| string: '' | ||
| headers: | ||
| Accept-Encoding: | ||
| - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 | ||
| Accept: | ||
| - "*/*" | ||
| User-Agent: | ||
| - mailtrap-ruby (https://github.com/mailtrap/mailtrap-ruby) | ||
| Host: | ||
| - mailtrap.io | ||
| Authorization: | ||
| - Bearer <BEARER_TOKEN> | ||
| Content-Type: | ||
| - application/json | ||
| response: | ||
| status: | ||
| code: 404 | ||
| message: Not Found | ||
| headers: | ||
| Date: | ||
| - Sun, 04 Jan 2026 16:24:02 GMT | ||
| Content-Type: | ||
| - application/json; charset=utf-8 | ||
| Transfer-Encoding: | ||
| - chunked | ||
| Connection: | ||
| - keep-alive | ||
| Server: | ||
| - cloudflare | ||
| X-Frame-Options: | ||
| - SAMEORIGIN | ||
| X-Xss-Protection: | ||
| - 1; mode=block | ||
| X-Content-Type-Options: | ||
| - nosniff | ||
| X-Download-Options: | ||
| - noopen | ||
| X-Permitted-Cross-Domain-Policies: | ||
| - none | ||
| Referrer-Policy: | ||
| - strict-origin-when-cross-origin | ||
| Vary: | ||
| - Accept | ||
| X-Mailtrap-Version: | ||
| - v2 | ||
| X-Ratelimit-Limit: | ||
| - '150' | ||
| X-Ratelimit-Remaining: | ||
| - '148' | ||
| Cache-Control: | ||
| - no-cache | ||
| X-Request-Id: | ||
| - 0b7c9190-ce7f-4a83-b2c9-2b3c416747a5 | ||
| X-Runtime: | ||
| - '0.016330' | ||
| X-Cloud-Trace-Context: | ||
| - 6497608d8e4442a3cb0403a7a8635ef8;o=0 | ||
| Strict-Transport-Security: | ||
| - max-age=0 | ||
| Cf-Cache-Status: | ||
| - DYNAMIC | ||
| Cf-Ray: | ||
| - 9b8c1574b858e98a-FRA |
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.
Redact internal identifiers from the cassette.
Line 5 and Line 59–70 contain account and trace/request IDs that can be sensitive. Please scrub them via VCR filters to avoid leaking internal identifiers.
🛡️ Proposed redaction
- uri: https://mailtrap.io/api/accounts/1111111/sending_domains/-1
+ uri: https://mailtrap.io/api/accounts/<ACCOUNT_ID>/sending_domains/-1
...
- X-Request-Id:
- - 0b7c9190-ce7f-4a83-b2c9-2b3c416747a5
+ X-Request-Id:
+ - <REQUEST_ID>
...
- X-Cloud-Trace-Context:
- - 6497608d8e4442a3cb0403a7a8635ef8;o=0
+ X-Cloud-Trace-Context:
+ - <TRACE_CONTEXT>
...
- Cf-Ray:
- - 9b8c1574b858e98a-FRA
+ Cf-Ray:
+ - <CF_RAY>As per coding guidelines, please scrub potentially sensitive identifiers.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| uri: https://mailtrap.io/api/accounts/1111111/sending_domains/-1 | |
| body: | |
| encoding: US-ASCII | |
| string: '' | |
| headers: | |
| Accept-Encoding: | |
| - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 | |
| Accept: | |
| - "*/*" | |
| User-Agent: | |
| - mailtrap-ruby (https://github.com/mailtrap/mailtrap-ruby) | |
| Host: | |
| - mailtrap.io | |
| Authorization: | |
| - Bearer <BEARER_TOKEN> | |
| Content-Type: | |
| - application/json | |
| response: | |
| status: | |
| code: 404 | |
| message: Not Found | |
| headers: | |
| Date: | |
| - Sun, 04 Jan 2026 16:24:02 GMT | |
| Content-Type: | |
| - application/json; charset=utf-8 | |
| Transfer-Encoding: | |
| - chunked | |
| Connection: | |
| - keep-alive | |
| Server: | |
| - cloudflare | |
| X-Frame-Options: | |
| - SAMEORIGIN | |
| X-Xss-Protection: | |
| - 1; mode=block | |
| X-Content-Type-Options: | |
| - nosniff | |
| X-Download-Options: | |
| - noopen | |
| X-Permitted-Cross-Domain-Policies: | |
| - none | |
| Referrer-Policy: | |
| - strict-origin-when-cross-origin | |
| Vary: | |
| - Accept | |
| X-Mailtrap-Version: | |
| - v2 | |
| X-Ratelimit-Limit: | |
| - '150' | |
| X-Ratelimit-Remaining: | |
| - '148' | |
| Cache-Control: | |
| - no-cache | |
| X-Request-Id: | |
| - 0b7c9190-ce7f-4a83-b2c9-2b3c416747a5 | |
| X-Runtime: | |
| - '0.016330' | |
| X-Cloud-Trace-Context: | |
| - 6497608d8e4442a3cb0403a7a8635ef8;o=0 | |
| Strict-Transport-Security: | |
| - max-age=0 | |
| Cf-Cache-Status: | |
| - DYNAMIC | |
| Cf-Ray: | |
| - 9b8c1574b858e98a-FRA | |
| uri: https://mailtrap.io/api/accounts/<ACCOUNT_ID>/sending_domains/-1 | |
| body: | |
| encoding: US-ASCII | |
| string: '' | |
| headers: | |
| Accept-Encoding: | |
| - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 | |
| Accept: | |
| - "*/*" | |
| User-Agent: | |
| - mailtrap-ruby (https://github.com/mailtrap/mailtrap-ruby) | |
| Host: | |
| - mailtrap.io | |
| Authorization: | |
| - Bearer <BEARER_TOKEN> | |
| Content-Type: | |
| - application/json | |
| response: | |
| status: | |
| code: 404 | |
| message: Not Found | |
| headers: | |
| Date: | |
| - Sun, 04 Jan 2026 16:24:02 GMT | |
| Content-Type: | |
| - application/json; charset=utf-8 | |
| Transfer-Encoding: | |
| - chunked | |
| Connection: | |
| - keep-alive | |
| Server: | |
| - cloudflare | |
| X-Frame-Options: | |
| - SAMEORIGIN | |
| X-Xss-Protection: | |
| - 1; mode=block | |
| X-Content-Type-Options: | |
| - nosniff | |
| X-Download-Options: | |
| - noopen | |
| X-Permitted-Cross-Domain-Policies: | |
| - none | |
| Referrer-Policy: | |
| - strict-origin-when-cross-origin | |
| Vary: | |
| - Accept | |
| X-Mailtrap-Version: | |
| - v2 | |
| X-Ratelimit-Limit: | |
| - '150' | |
| X-Ratelimit-Remaining: | |
| - '148' | |
| Cache-Control: | |
| - no-cache | |
| X-Request-Id: | |
| - <REQUEST_ID> | |
| X-Runtime: | |
| - '0.016330' | |
| X-Cloud-Trace-Context: | |
| - <TRACE_CONTEXT> | |
| Strict-Transport-Security: | |
| - max-age=0 | |
| Cf-Cache-Status: | |
| - DYNAMIC | |
| Cf-Ray: | |
| - <CF_RAY> |
🤖 Prompt for AI Agents
In
`@spec/fixtures/vcr_cassettes/Mailtrap_SendingDomainsAPI/_get/when_sending_domain_does_not_exist/raises_not_found_error.yml`
around lines 5 - 70, The cassette contains sensitive account and trace/request
IDs (e.g. account "1111111" in the URI and X-Request-Id / X-Cloud-Trace-Context
/ Cf-Ray headers) — update your VCR configuration (e.g. in your VCR.configure
block in spec helper or spec/support/vcr.rb) to scrub these before recording:
add VCR.filter_sensitive_data('<ACCOUNT_ID>') { '1111111' } or a regex-based
replacement for account IDs in request URIs, and add filters or a before_record
hook to replace header values like X-Request-Id, X-Cloud-Trace-Context and
Cf-Ray with placeholders (e.g. '<X_REQUEST_ID>', '<TRACE_CONTEXT>', '<CF_RAY>');
re-run tests to regenerate the cassette with redacted values and commit the
updated fixture
(spec/fixtures/vcr_cassettes/Mailtrap_SendingDomainsAPI/_get/when_sending_domain_does_not_exist/raises_not_found_error.yml).
3b328ba to
aae72b7
Compare
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
🤖 Fix all issues with AI agents
In `@examples/sending_domains_api.rb`:
- Around line 15-17: Update the stale example comment after the call to
sending_domains.get so it reflects the actual created domain; replace
domain_name="proper.com" with domain_name="example.com" (or remove the example
output line) to match the created resource and avoid confusion—look for the
sending_domain variable and the sending_domains.get(sending_domain.id) call to
locate the line to change.
| # Get sending domain | ||
| sending_domain = sending_domains.get(sending_domain.id) | ||
| # => #<struct Mailtrap::SendingDomain id=1, domain_name="proper.com"> |
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.
Stale comment shows incorrect domain name.
The comment on line 17 indicates domain_name="proper.com", but the domain was created with "example.com" on line 8. This appears to be a leftover from a removed update operation and will confuse readers.
✏️ Proposed fix
# Get sending domain
sending_domain = sending_domains.get(sending_domain.id)
-# => #<struct Mailtrap::SendingDomain id=1, domain_name="proper.com">
+# => #<struct Mailtrap::SendingDomain id=1, domain_name="example.com">📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| # Get sending domain | |
| sending_domain = sending_domains.get(sending_domain.id) | |
| # => #<struct Mailtrap::SendingDomain id=1, domain_name="proper.com"> | |
| # Get sending domain | |
| sending_domain = sending_domains.get(sending_domain.id) | |
| # => #<struct Mailtrap::SendingDomain id=1, domain_name="example.com"> |
🤖 Prompt for AI Agents
In `@examples/sending_domains_api.rb` around lines 15 - 17, Update the stale
example comment after the call to sending_domains.get so it reflects the actual
created domain; replace domain_name="proper.com" with domain_name="example.com"
(or remove the example output line) to match the created resource and avoid
confusion—look for the sending_domain variable and the
sending_domains.get(sending_domain.id) call to locate the line to change.
Motivation
Adding Sending Domains API for Ruby SDK
Changes
Summary by CodeRabbit
New Features
Documentation
Tests
✏️ Tip: You can customize this high-level summary in your review settings.