-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
1bdb7cf
Add coderabbit config
i7an 15644c3
Add Sending domains API
DagonWat b8d48db
Rename some test cases
DagonWat 465d4f4
Add new examples
DagonWat 867daa7
Remove PII data
DagonWat 87fcb29
Merge branch 'main' into MT-19854-sending-domains
DagonWat 7d66770
Remove wrong example
DagonWat 740c22d
Change default fields of example domain
DagonWat fa2117d
Add missing fields in Ruby SDK
DagonWat c3c6e47
Merge branch 'main' into MT-19854-sending-domains
DagonWat b9b21a9
Force Appraisal to use the same local path that setup-ruby created
i7an eb251ad
Fix kwargs topic on send setup request
DagonWat 3ed930b
Simplify parameters
i7an 72c3e00
Update CHANGELOG
i7an File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| - Add Sending Domains API | ||
|
|
||
| ## [2.6.0] - 2026-01-27 | ||
| - Add Inboxes API | ||
| - Add Projects API | ||
|
|
||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| require 'mailtrap' | ||
|
|
||
| account_id = 3229 | ||
| client = Mailtrap::Client.new(api_key: 'your-api-key') | ||
| sending_domains = Mailtrap::SendingDomainsAPI.new(account_id, client) | ||
|
|
||
| # Create new Sending Domain | ||
| sending_domain = sending_domains.create(domain_name: 'example.com') | ||
| # => #<struct Mailtrap::SendingDomain id=1, domain_name="example.com"> | ||
|
|
||
| # Get all Sending Domains | ||
| sending_domains.list | ||
| # => [#<struct Mailtrap::SendingDomain id=1, domain_name="example.com">] | ||
|
|
||
| # Get sending domain | ||
| sending_domain = sending_domains.get(sending_domain.id) | ||
| # => #<struct Mailtrap::SendingDomain id=1, domain_name="example.com"> | ||
|
|
||
| # Send setup email | ||
| sending_domains.send_setup_instructions(sending_domain.id, 'jonathan@mail.com') | ||
| # => nil | ||
|
|
||
| # Delete sending domain | ||
| sending_domains.delete(sending_domain.id) | ||
| # => nil | ||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| module Mailtrap | ||
| # 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 demo [Boolean] Whether the sending domain is a demo domain | ||
| # @attr_reader compliance_status [String] The compliance status of the sending domain | ||
| # @attr_reader dns_verified [Boolean] Whether the DNS records are verified | ||
| # @attr_reader dns_verified_at [String, nil] The timestamp when DNS was verified | ||
| # @attr_reader dns_records [Array] The DNS records for the sending domain | ||
| # @attr_reader open_tracking_enabled [Boolean] Whether open tracking is enabled | ||
| # @attr_reader click_tracking_enabled [Boolean] Whether click tracking is enabled | ||
| # @attr_reader auto_unsubscribe_link_enabled [Boolean] Whether auto unsubscribe link is enabled | ||
| # @attr_reader custom_domain_tracking_enabled [Boolean] Whether custom domain tracking is enabled | ||
| # @attr_reader health_alerts_enabled [Boolean] Whether health alerts are enabled | ||
| # @attr_reader critical_alerts_enabled [Boolean] Whether critical alerts are enabled | ||
| # @attr_reader alert_recipient_email [String, nil] The email address for alert recipients | ||
| # @attr_reader permissions [Hash] The permissions for the sending domain | ||
| # | ||
| SendingDomain = Struct.new( | ||
DagonWat marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| :id, | ||
| :domain_name, | ||
| :demo, | ||
| :compliance_status, | ||
| :dns_verified, | ||
| :dns_verified_at, | ||
| :dns_records, | ||
| :open_tracking_enabled, | ||
| :click_tracking_enabled, | ||
| :auto_unsubscribe_link_enabled, | ||
| :custom_domain_tracking_enabled, | ||
| :health_alerts_enabled, | ||
| :critical_alerts_enabled, | ||
| :alert_recipient_email, | ||
| :permissions, | ||
| :created_at, | ||
| :updated_at, | ||
| keyword_init: true | ||
| ) | ||
| end | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| require_relative 'base_api' | ||
| require_relative 'sending_domain' | ||
|
|
||
| module Mailtrap | ||
| class SendingDomainsAPI | ||
| include BaseAPI | ||
|
|
||
| self.supported_options = %i[domain_name] | ||
DagonWat marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| self.response_class = SendingDomain | ||
|
|
||
| # Lists all sending domains for the account | ||
| # @return [Array<SendingDomain>] Array of sending domains | ||
| # @!macro api_errors | ||
| def list | ||
| response = client.get(base_path) | ||
| response[:data].map { |item| handle_response(item) } | ||
| end | ||
|
|
||
| # Retrieves a specific sending domain | ||
| # @param domain_id [Integer] The sending domain ID | ||
| # @return [SendingDomain] Sending domain object | ||
| # @!macro api_errors | ||
| def get(domain_id) | ||
| base_get(domain_id) | ||
| end | ||
|
|
||
| # Creates a new sending domain | ||
| # @param [Hash] options The parameters to create | ||
| # @option options [String] :domain_name The sending domain name | ||
| # @return [SendingDomain] Created sending domain | ||
| # @!macro api_errors | ||
| # @raise [ArgumentError] If invalid options are provided | ||
| def create(options) | ||
| base_create(options) | ||
| end | ||
|
|
||
| # Deletes a sending domain | ||
| # @param domain_id [Integer] The sending domain ID | ||
| # @return nil | ||
| # @!macro api_errors | ||
| def delete(domain_id) | ||
| base_delete(domain_id) | ||
| end | ||
|
|
||
| # Email DNS configuration instructions for the sending domain | ||
| # @param domain_id [Integer] The sending domain ID | ||
| # @param email [String] The email for instructions | ||
| # @return nil | ||
| # @!macro api_errors | ||
| def send_setup_instructions(domain_id:, email:) | ||
| client.post("#{base_path}/#{domain_id}/send_setup_instructions", email:) | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def base_path | ||
| "/api/accounts/#{account_id}/sending_domains" | ||
| end | ||
|
|
||
| def wrap_request(options) | ||
| { sending_domain: options } | ||
| end | ||
| end | ||
| end | ||
80 changes: 80 additions & 0 deletions
80
...settes/Mailtrap_SendingDomainsAPI/_create/maps_response_data_to_sending_domain_object.yml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
78 changes: 78 additions & 0 deletions
78
.../Mailtrap_SendingDomainsAPI/_create/when_API_returns_an_error/raises_a_Mailtrap_Error.yml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.