diff --git a/lib/mailtrap.rb b/lib/mailtrap.rb index 3b6af23..49f032c 100644 --- a/lib/mailtrap.rb +++ b/lib/mailtrap.rb @@ -11,6 +11,7 @@ require_relative 'mailtrap/contact_imports_api' require_relative 'mailtrap/suppressions_api' require_relative 'mailtrap/projects_api' +require_relative 'mailtrap/sandbox_messages_api' module Mailtrap # @!macro api_errors diff --git a/lib/mailtrap/client.rb b/lib/mailtrap/client.rb index 36b7c19..5065215 100644 --- a/lib/mailtrap/client.rb +++ b/lib/mailtrap/client.rb @@ -168,14 +168,16 @@ def send(mail) # Performs a GET request to the specified path # @param path [String] The request path # @param query_params [Hash] Query parameters to append to the URL (optional) + # @param custom_parser [Proc] custom parsing function for the response body (optional) # @return [Hash, nil] The JSON response # @!macro api_errors - def get(path, query_params = {}) + def get(path, query_params = {}, custom_parser: nil) perform_request( method: :get, host: general_api_host, path:, - query_params: + query_params:, + custom_parser: ) end @@ -243,7 +245,7 @@ def batch_request_path "/api/batch#{"/#{inbox_id}" if sandbox}" end - def perform_request(method:, host:, path:, query_params: {}, body: nil) + def perform_request(method:, host:, path:, query_params: {}, body: nil, custom_parser: nil) http_client = http_client_for(host) uri = URI::HTTPS.build(host:, path:) @@ -251,7 +253,7 @@ def perform_request(method:, host:, path:, query_params: {}, body: nil) request = setup_request(method, uri, body) response = http_client.request(request) - handle_response(response) + handle_response(response, custom_parser:) end def setup_request(method, uri_or_path, body = nil) @@ -276,10 +278,10 @@ def setup_request(method, uri_or_path, body = nil) request end - def handle_response(response) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength + def handle_response(response, custom_parser: nil) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength case response when Net::HTTPOK, Net::HTTPCreated - json_response(response.body) + custom_parser.nil? ? json_response(response.body) : custom_parser.call(response.body) when Net::HTTPNoContent nil when Net::HTTPBadRequest diff --git a/lib/mailtrap/sandbox_message.rb b/lib/mailtrap/sandbox_message.rb new file mode 100644 index 0000000..c5177c2 --- /dev/null +++ b/lib/mailtrap/sandbox_message.rb @@ -0,0 +1,59 @@ +# frozen_string_literal: true + +module Mailtrap + # Data Transfer Object for Sandbox Message + # @see https://docs.mailtrap.io/developers/email-sandbox/email-sandbox-api/messages + # @attr_reader id [Integer] The message ID + # @attr_reader inbox_id [Integer] The inbox ID + # @attr_reader subject [String] The message subject + # @attr_reader sent_at [String] The timestamp when the message was sent + # @attr_reader from_email [String] The sender's email address + # @attr_reader from_name [String] The sender's name + # @attr_reader to_email [String] The recipient's email address + # @attr_reader to_name [String] The recipient's name + # @attr_reader email_size [Integer] The size of the email in bytes + # @attr_reader is_read [Boolean] Whether the message has been read + # @attr_reader created_at [String] The timestamp when the message was created + # @attr_reader updated_at [String] The timestamp when the message was last updated + # @attr_reader html_body_size [Integer] The size of the HTML body in bytes + # @attr_reader text_body_size [Integer] The size of the text body in bytes + # @attr_reader human_size [String] The human-readable size of the email + # @attr_reader html_path [String] The path to the HTML version of the email + # @attr_reader txt_path [String] The path to the text version of the email + # @attr_reader raw_path [String] The path to the raw version of the email + # @attr_reader download_path [String] The path to download the email + # @attr_reader html_source_path [String] The path to the HTML source of the email + # @attr_reader blacklists_report_info [Boolean] Information about blacklists report + # @attr_reader smtp_information [Hash] Information about SMTP + # + SandboxMessage = Struct.new( + :id, + :inbox_id, + :subject, + :sent_at, + :from_email, + :from_name, + :to_email, + :to_name, + :email_size, + :is_read, + :created_at, + :updated_at, + :html_body_size, + :text_body_size, + :human_size, + :html_path, + :txt_path, + :raw_path, + :download_path, + :html_source_path, + :blacklists_report_info, + :smtp_information, + keyword_init: true + ) do + # @return [Hash] The SendingDomain attributes as a hash + def to_h + super.compact + end + end +end diff --git a/lib/mailtrap/sandbox_messages_api.rb b/lib/mailtrap/sandbox_messages_api.rb new file mode 100644 index 0000000..5296d69 --- /dev/null +++ b/lib/mailtrap/sandbox_messages_api.rb @@ -0,0 +1,154 @@ +# frozen_string_literal: true + +require_relative 'base_api' +require_relative 'sandbox_message' + +module Mailtrap + class SandboxMessagesAPI + include BaseAPI + + attr_reader :account_id, :inbox_id, :client + + self.supported_options = %i[is_read] + + self.response_class = SandboxMessage + + # @param inbox_id [Integer] The inbox ID + # @param account_id [Integer] The account ID + # @param client [Mailtrap::Client] The client instance + # @raise [ArgumentError] If account_id is nil + def initialize(inbox_id, account_id = ENV.fetch('MAILTRAP_ACCOUNT_ID'), client = Mailtrap::Client.new) + raise ArgumentError, 'account_id is required' if account_id.nil? + raise ArgumentError, 'inbox_id is required' if inbox_id.nil? + + @account_id = account_id + @inbox_id = inbox_id + @client = client + end + + # Retrieves a specific sandbox message from inbox + # @param message_id [Integer] The sandbox message ID + # @return [SandboxMessage] Sandbox message object + # @!macro api_errors + def get(message_id) + base_get(message_id) + end + + # Deletes a sandbox message + # @param message_id [Integer] The sandbox message ID + # @return [SandboxMessage] Deleted Sandbox message object + # @!macro api_errors + def delete(message_id) + base_delete(message_id) + end + + # Updates an existing sandbox message + # @param message_id [Integer] The sandbox message ID + # @param [Hash] options The parameters to update + # @return [SandboxMessage] Updated Sandbox message object + # @!macro api_errors + # @raise [ArgumentError] If invalid options are provided + def update(message_id, options) + base_update(message_id, options) + end + + # Lists all sandbox messages for the account, limited up to 30 at once + # @param search [String] Search query string. Matches subject, to_email, and to_name. + # @param last_id [Integer] If specified, a page of records before last_id is returned. + # Overrides page if both are given. + # @param page [Integer] Page number for paginated results. + # @return [Array] Array of sandbox message objects + # @!macro api_errors + def list(search: nil, last_id: nil, page: nil) + query_params = {} + query_params[:search] = search unless search.nil? + query_params[:last_id] = last_id unless last_id.nil? + query_params[:page] = page unless page.nil? + + base_list(query_params) + end + + # Forward message to an email address. + # @param message_id [Integer] The Sandbox message ID + # @param email [String] The email to forward sandbox message to + # @return [String] Forwarded message confirmation + # @!macro api_errors + def forward_message(message_id, email) + client.post("#{base_path}/#{message_id}/forward", { email: email }) + end + + # Get message spam score + # @param message_id [Integer] The Sandbox message ID + # @return [Hash] Spam report + # @!macro api_errors + def get_spam_score(message_id) + client.get("#{base_path}/#{message_id}/spam_report") + end + + # Get message HTML analysis + # @param message_id [Integer] The Sandbox message ID + # @return [Hash] brief HTML report + # @!macro api_errors + def get_html_analysis(message_id) + client.get("#{base_path}/#{message_id}/analyze") + end + + # Get text message + # @param message_id [Integer] The Sandbox message ID + # @return [String] text email body + # @!macro api_errors + def get_text_message(message_id) + client.get("#{base_path}/#{message_id}/body.txt", custom_parser: ->(response) { response }) + end + + # Get raw message + # @param message_id [Integer] The Sandbox message ID + # @return [String] raw email body + # @!macro api_errors + def get_raw_message(message_id) + client.get("#{base_path}/#{message_id}/body.raw", custom_parser: ->(response) { response }) + end + + # Get message source + # @param message_id [Integer] The Sandbox message ID + # @return [String] HTML source of a message. + # @!macro api_errors + def get_html_source(message_id) + client.get("#{base_path}/#{message_id}/body.htmlsource", custom_parser: ->(response) { response }) + end + + # Get formatted HTML email body. Not applicable for plain text emails. + # @param message_id [Integer] The Sandbox message ID + # @return [String] message body in html format. + # @!macro api_errors + def get_html_message(message_id) + client.get("#{base_path}/#{message_id}/body.html", custom_parser: ->(response) { response }) + end + + # Get mail headers + # @param message_id [Integer] The Sandbox message ID + # @return [Hash] mail headers of the message. + # @!macro api_errors + def get_message_as_eml(message_id) + client.get("#{base_path}/#{message_id}/body.eml", custom_parser: ->(response) { response }) + end + + # Get mail headers + # @param message_id [Integer] The Sandbox message ID + # @return [Hash] mail headers of the message. + # @!macro api_errors + def get_mail_headers(message_id) + client.get("#{base_path}/#{message_id}/mail_headers") + end + + private + + def base_path + "/api/accounts/#{account_id}/inboxes/#{inbox_id}/messages" + end + + def wrap_request(options) + { message: options } + end + end +end diff --git a/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_delete/returns_deleted_project_id.yml b/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_delete/returns_deleted_project_id.yml new file mode 100644 index 0000000..ddd243f --- /dev/null +++ b/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_delete/returns_deleted_project_id.yml @@ -0,0 +1,83 @@ +--- +http_interactions: +- request: + method: delete + uri: https://mailtrap.io/api/accounts/1111111/inboxes/4288340/messages/5273448410 + 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 + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Date: + - Tue, 30 Dec 2025 23:49:57 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Server: + - cloudflare + Vary: + - Accept + - Accept-Encoding + 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 + X-Mailtrap-Version: + - v2 + X-Ratelimit-Limit: + - '150' + X-Ratelimit-Remaining: + - '149' + Etag: + - W/"781e146f58e836ca6b8a2062e2e3c0f0" + Cache-Control: + - max-age=0, private, must-revalidate + X-Request-Id: + - 9aa3f424-5cbd-4a0d-975c-d9e21876b982 + X-Runtime: + - '0.040242' + X-Cloud-Trace-Context: + - 13d8470e2b14402e87da1ca8c8e328eb;o=0 + Strict-Transport-Security: + - max-age=0 + Cf-Cache-Status: + - DYNAMIC + Cf-Ray: + - 9b8ea2a62c14d366-FRA + Alt-Svc: + - h3=":443"; ma=86400 + body: + encoding: ASCII-8BIT + string: '{"id":5273448410,"inbox_id":4288340,"subject":"Hello from Mailtrap","sent_at":"2026-01-04T16:55:50.867Z","from_email":"reply@demomailtrap.co","from_name":"","to_email":"yahor.vaitsiakhouski@railsware.com","to_name":"","email_size":691,"is_read":true,"created_at":"2026-01-04T16:55:50.871Z","updated_at":"2026-01-04T23:24:26.317Z","template_id":0,"template_variables":null,"html_body_size":29,"text_body_size":20,"human_size":"691 + Bytes","html_path":"/api/testing_message_parts/QEVuQwFAEAAEGQjR4zBj6UG33mPU+7iLYIJibHfQmLEEl2ga65S+owaKeN%2FHzvFB5Tu91Fd6wM9R3XzZFr8GCQc%2F1PCUoXODfH1JT8IXq9ugoIoZmwNHwF6iSghUWZqmBoWjzGHR66M=/body.html","txt_path":"/api/testing_message_parts/QEVuQwFAEAAEGQjR4zBj6UG33mPU+7iLYIJibHfQmLEEl2ga65S+owaKeN%2FHzvFB5Tu91Fd6wM9R3XzZFr8GCQc%2F1PCUoXODfH1JT8IXq9ugoIoZmwNHwF6iSghUWZqmBoWjzGHR66M=/body.txt","raw_path":"/api/testing_message_parts/QEVuQwFAEAAEGQjR4zBj6UG33mPU+7iLYIJibHfQmLEEl2ga65S+owaKeN%2FHzvFB5Tu91Fd6wM9R3XzZFr8GCQc%2F1PCUoXODfH1JT8IXq9ugoIoZmwNHwF6iSghUWZqmBoWjzGHR66M=/body.raw","download_path":"/api/testing_message_parts/QEVuQwFAEAAEGQjR4zBj6UG33mPU+7iLYIJibHfQmLEEl2ga65S+owaKeN%2FHzvFB5Tu91Fd6wM9R3XzZFr8GCQc%2F1PCUoXODfH1JT8IXq9ugoIoZmwNHwF6iSghUWZqmBoWjzGHR66M=/body.eml","html_source_path":"/api/testing_message_parts/QEVuQwFAEAAEGQjR4zBj6UG33mPU+7iLYIJibHfQmLEEl2ga65S+owaKeN%2FHzvFB5Tu91Fd6wM9R3XzZFr8GCQc%2F1PCUoXODfH1JT8IXq9ugoIoZmwNHwF6iSghUWZqmBoWjzGHR66M=/body.htmlsource","blacklists_report_info":{"result":"success","domain":"demomailtrap.co","ip":"172.67.134.80","report":[{"name":"BACKSCATTERER","url":"http://www.backscatterer.org/index.php","in_black_list":false},{"name":"BARRACUDA","url":"http://barracudacentral.org/rbl","in_black_list":false},{"name":"Spamrbl + IMP-SPAM","url":"http://antispam.imp.ch/?lng=1","in_black_list":false},{"name":"Wormrbl + IMP-SPAM","url":"http://antispam.imp.ch/?lng=1","in_black_list":false},{"name":"LASHBACK","url":"http://blacklist.lashback.com/","in_black_list":false},{"name":"NIXSPAM","url":"https://www.heise.de/ix/NiX-Spam-DNSBL-and-blacklist-for-download-499637.html","in_black_list":false},{"name":"PSBL","url":"https://psbl.org/","in_black_list":false},{"name":"SORBS-SPAM","url":"http://www.sorbs.net/lookup.shtml","in_black_list":false},{"name":"SPAMCOP","url":"http://spamcop.net/bl.shtml","in_black_list":false},{"name":"TRUNCATE","url":"http://www.gbudb.com/truncate/index.jsp","in_black_list":false}]},"smtp_information":{"ok":false}}' + recorded_at: Tue, 30 Dec 2025 23:49:57 GMT +recorded_with: VCR 6.2.0 diff --git a/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_delete/when_project_does_not_exist/raises_not_found_error.yml b/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_delete/when_project_does_not_exist/raises_not_found_error.yml new file mode 100644 index 0000000..25d606f --- /dev/null +++ b/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_delete/when_project_does_not_exist/raises_not_found_error.yml @@ -0,0 +1,77 @@ +--- +http_interactions: +- request: + method: delete + uri: https://mailtrap.io/api/accounts/1111111/inboxes/4288340/messages/999999 + 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 + Content-Type: + - application/json + response: + status: + code: 404 + message: Not Found + headers: + Date: + - Tue, 30 Dec 2025 23:49:57 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: + - 94533df4-a387-466f-ad13-998569ab0c68 + X-Runtime: + - '0.018918' + X-Cloud-Trace-Context: + - ad3cf69341b0414ec6499302d224fac3;o=0 + Strict-Transport-Security: + - max-age=0 + Cf-Cache-Status: + - DYNAMIC + Cf-Ray: + - 9b8ea2a9db8b9755-FRA + Alt-Svc: + - h3=":443"; ma=86400 + body: + encoding: ASCII-8BIT + string: '{"error":"Not Found"}' + recorded_at: Tue, 30 Dec 2025 23:49:57 GMT +recorded_with: VCR 6.2.0 diff --git a/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_forward_message/returns_success.yml b/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_forward_message/returns_success.yml new file mode 100644 index 0000000..34df8ab --- /dev/null +++ b/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_forward_message/returns_success.yml @@ -0,0 +1,77 @@ +--- +http_interactions: +- request: + method: post + uri: https://mailtrap.io/api/accounts/1111111/inboxes/4288340/messages/5273448410/forward + body: + encoding: UTF-8 + string: '{"email":"example@railsware.com"}' + 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 + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Date: + - Tue, 30 Dec 2025 23:20:59 GMT + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '94' + 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: + - '149' + Cache-Control: + - no-cache + X-Request-Id: + - bc469cf6-d69c-4e16-97c6-0de0a1cad25f + X-Runtime: + - '0.029252' + X-Cloud-Trace-Context: + - aa184d8185a94b398bef5b820fac2484;o=0 + Strict-Transport-Security: + - max-age=0 + Cf-Cache-Status: + - DYNAMIC + Cf-Ray: + - 9b8e7839c9ca6447-FRA + Alt-Svc: + - h3=":443"; ma=86400 + body: + encoding: UTF-8 + string: '{"success":true,"message":"Your email message has been successfully forwarded"}' + recorded_at: Tue, 30 Dec 2025 23:20:59 GMT +recorded_with: VCR 6.2.0 diff --git a/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_forward_message/when_sandbox_message_does_not_exist/raises_not_found_error.yml b/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_forward_message/when_sandbox_message_does_not_exist/raises_not_found_error.yml new file mode 100644 index 0000000..ad64681 --- /dev/null +++ b/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_forward_message/when_sandbox_message_does_not_exist/raises_not_found_error.yml @@ -0,0 +1,77 @@ +--- +http_interactions: +- request: + method: post + uri: https://mailtrap.io/api/accounts/1111111/inboxes/4288340/messages/-1/forward + body: + encoding: UTF-8 + string: '{"email":"example@railsware.com"}' + 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 + Content-Type: + - application/json + response: + status: + code: 404 + message: Not Found + headers: + Date: + - Tue, 30 Dec 2025 23:28:12 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: + - '149' + Cache-Control: + - no-cache + X-Request-Id: + - 7c7591d3-a329-4e31-870b-28d80125f67c + X-Runtime: + - '0.020120' + X-Cloud-Trace-Context: + - 508771a205b74a09845360fd8c640792;o=0 + Strict-Transport-Security: + - max-age=0 + Cf-Cache-Status: + - DYNAMIC + Cf-Ray: + - 9b8e82ccdfda3a4a-FRA + Alt-Svc: + - h3=":443"; ma=86400 + body: + encoding: ASCII-8BIT + string: '{"error":"Not Found"}' + recorded_at: Tue, 30 Dec 2025 23:28:12 GMT +recorded_with: VCR 6.2.0 diff --git a/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_get/maps_response_data_to_SandboxMessage_object.yml b/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_get/maps_response_data_to_SandboxMessage_object.yml new file mode 100644 index 0000000..43756cc --- /dev/null +++ b/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_get/maps_response_data_to_SandboxMessage_object.yml @@ -0,0 +1,83 @@ +--- +http_interactions: +- request: + method: get + uri: https://mailtrap.io/api/accounts/1111111/inboxes/4288340/messages/5273448410 + 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 + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Date: + - Tue, 30 Dec 2025 23:10:48 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Server: + - cloudflare + Vary: + - Accept + - Accept-Encoding + 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 + X-Mailtrap-Version: + - v2 + X-Ratelimit-Limit: + - '150' + X-Ratelimit-Remaining: + - '149' + Etag: + - W/"b0c2be2795ed16c966127414d596d40a" + Cache-Control: + - max-age=0, private, must-revalidate + X-Request-Id: + - 2b35d260-3a20-41b7-b286-3e4977a65257 + X-Runtime: + - '0.026897' + X-Cloud-Trace-Context: + - 510e7cd5c00b45668e59e9839424f4a3;o=0 + Strict-Transport-Security: + - max-age=0 + Cf-Cache-Status: + - DYNAMIC + Cf-Ray: + - 9b8e695038936e15-FRA + Alt-Svc: + - h3=":443"; ma=86400 + body: + encoding: ASCII-8BIT + string: '{"id":5273448410,"inbox_id":4288340,"subject":"Hello from Mailtrap","sent_at":"2026-01-04T04:55:50.867-12:00","from_email":"reply@demomailtrap.co","from_name":"","to_email":"alex.b@railsware.com","to_name":"","email_size":691,"is_read":true,"created_at":"2026-01-04T04:55:50.871-12:00","updated_at":"2026-01-04T04:55:56.618-12:00","template_id":0,"template_variables":null,"html_body_size":29,"text_body_size":20,"human_size":"691 + Bytes","html_path":"/api/testing_message_parts/QEVuQwFAEABC6ODCerNYpR2yAx7xrEH6%2Ftn5yHfn6zIHYoQ9Ce0V5e9PB+Fy64WrVklr1BTc8WNmeft20TH7pytYbFWIzBx61dHgATF0KMjaFS1whA7iqWor%2FinVxeyLbZbskDsXojw=/body.html","txt_path":"/api/testing_message_parts/QEVuQwFAEABC6ODCerNYpR2yAx7xrEH6%2Ftn5yHfn6zIHYoQ9Ce0V5e9PB+Fy64WrVklr1BTc8WNmeft20TH7pytYbFWIzBx61dHgATF0KMjaFS1whA7iqWor%2FinVxeyLbZbskDsXojw=/body.txt","raw_path":"/api/testing_message_parts/QEVuQwFAEABC6ODCerNYpR2yAx7xrEH6%2Ftn5yHfn6zIHYoQ9Ce0V5e9PB+Fy64WrVklr1BTc8WNmeft20TH7pytYbFWIzBx61dHgATF0KMjaFS1whA7iqWor%2FinVxeyLbZbskDsXojw=/body.raw","download_path":"/api/testing_message_parts/QEVuQwFAEABC6ODCerNYpR2yAx7xrEH6%2Ftn5yHfn6zIHYoQ9Ce0V5e9PB+Fy64WrVklr1BTc8WNmeft20TH7pytYbFWIzBx61dHgATF0KMjaFS1whA7iqWor%2FinVxeyLbZbskDsXojw=/body.eml","html_source_path":"/api/testing_message_parts/QEVuQwFAEABC6ODCerNYpR2yAx7xrEH6%2Ftn5yHfn6zIHYoQ9Ce0V5e9PB+Fy64WrVklr1BTc8WNmeft20TH7pytYbFWIzBx61dHgATF0KMjaFS1whA7iqWor%2FinVxeyLbZbskDsXojw=/body.htmlsource","blacklists_report_info":{"result":"success","domain":"demomailtrap.co","ip":"172.67.134.80","report":[{"name":"BACKSCATTERER","url":"http://www.backscatterer.org/index.php","in_black_list":false},{"name":"BARRACUDA","url":"http://barracudacentral.org/rbl","in_black_list":false},{"name":"Spamrbl + IMP-SPAM","url":"http://antispam.imp.ch/?lng=1","in_black_list":false},{"name":"Wormrbl + IMP-SPAM","url":"http://antispam.imp.ch/?lng=1","in_black_list":false},{"name":"LASHBACK","url":"http://blacklist.lashback.com/","in_black_list":false},{"name":"NIXSPAM","url":"https://www.heise.de/ix/NiX-Spam-DNSBL-and-blacklist-for-download-499637.html","in_black_list":false},{"name":"PSBL","url":"https://psbl.org/","in_black_list":false},{"name":"SORBS-SPAM","url":"http://www.sorbs.net/lookup.shtml","in_black_list":false},{"name":"SPAMCOP","url":"http://spamcop.net/bl.shtml","in_black_list":false},{"name":"TRUNCATE","url":"http://www.gbudb.com/truncate/index.jsp","in_black_list":false}]},"smtp_information":{"ok":false}}' + recorded_at: Tue, 30 Dec 2025 23:10:48 GMT +recorded_with: VCR 6.2.0 diff --git a/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_get/when_SandboxMessage_does_not_exist/raises_not_found_error.yml b/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_get/when_SandboxMessage_does_not_exist/raises_not_found_error.yml new file mode 100644 index 0000000..dda73d2 --- /dev/null +++ b/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_get/when_SandboxMessage_does_not_exist/raises_not_found_error.yml @@ -0,0 +1,77 @@ +--- +http_interactions: +- request: + method: get + uri: https://mailtrap.io/api/accounts/1111111/inboxes/4288340/messages/999999 + 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 + Content-Type: + - application/json + response: + status: + code: 404 + message: Not Found + headers: + Date: + - Tue, 30 Dec 2025 23:10:49 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: + - be053f4b-d616-447b-96b4-55ac7ef0a8a2 + X-Runtime: + - '0.018730' + X-Cloud-Trace-Context: + - 3c7e6159448949d48ee1c93f93f9ca37;o=0 + Strict-Transport-Security: + - max-age=0 + Cf-Cache-Status: + - DYNAMIC + Cf-Ray: + - 9b8e6953997e33be-FRA + Alt-Svc: + - h3=":443"; ma=86400 + body: + encoding: ASCII-8BIT + string: '{"error":"Not Found"}' + recorded_at: Tue, 30 Dec 2025 23:10:49 GMT +recorded_with: VCR 6.2.0 diff --git a/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_get_html_analysis/returns_html_analysis.yml b/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_get_html_analysis/returns_html_analysis.yml new file mode 100644 index 0000000..2f68a50 --- /dev/null +++ b/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_get_html_analysis/returns_html_analysis.yml @@ -0,0 +1,79 @@ +--- +http_interactions: +- request: + method: get + uri: https://mailtrap.io/api/accounts/1111111/inboxes/4288340/messages/5273448410/analyze + 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 + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Date: + - Tue, 30 Dec 2025 23:31:29 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: + - '149' + Etag: + - W/"f5e927d227ad3441e41ef98dcef5fc5a" + Cache-Control: + - max-age=0, private, must-revalidate + X-Request-Id: + - b7076967-52d2-4652-b228-d4d89721da7b + X-Runtime: + - '0.020337' + X-Cloud-Trace-Context: + - 2d086d94d1424798ce140fd029d378f3;o=0 + Strict-Transport-Security: + - max-age=0 + Cf-Cache-Status: + - DYNAMIC + Cf-Ray: + - 9b8e8799cef2d34a-FRA + Alt-Svc: + - h3=":443"; ma=86400 + body: + encoding: ASCII-8BIT + string: '{"report":{"status":"success","errors":[]}}' + recorded_at: Tue, 30 Dec 2025 23:31:29 GMT +recorded_with: VCR 6.2.0 diff --git a/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_get_html_analysis/when_sandbox_message_does_not_exist/raises_not_found_error.yml b/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_get_html_analysis/when_sandbox_message_does_not_exist/raises_not_found_error.yml new file mode 100644 index 0000000..e17e0a8 --- /dev/null +++ b/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_get_html_analysis/when_sandbox_message_does_not_exist/raises_not_found_error.yml @@ -0,0 +1,77 @@ +--- +http_interactions: +- request: + method: get + uri: https://mailtrap.io/api/accounts/1111111/inboxes/4288340/messages/-1/analyze + 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 + Content-Type: + - application/json + response: + status: + code: 404 + message: Not Found + headers: + Date: + - Tue, 30 Dec 2025 23:31:29 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: + - 392d1117-2fcc-48af-a188-7b13386993d4 + X-Runtime: + - '0.019055' + X-Cloud-Trace-Context: + - 06a2d858e84a4265c0691117d55c739d;o=0 + Strict-Transport-Security: + - max-age=0 + Cf-Cache-Status: + - DYNAMIC + Cf-Ray: + - 9b8e879b993971ac-FRA + Alt-Svc: + - h3=":443"; ma=86400 + body: + encoding: ASCII-8BIT + string: '{"error":"Not Found"}' + recorded_at: Tue, 30 Dec 2025 23:31:29 GMT +recorded_with: VCR 6.2.0 diff --git a/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_get_html_message/returns_html_message.yml b/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_get_html_message/returns_html_message.yml new file mode 100644 index 0000000..c33bffa --- /dev/null +++ b/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_get_html_message/returns_html_message.yml @@ -0,0 +1,77 @@ +--- +http_interactions: +- request: + method: get + uri: https://mailtrap.io/api/accounts/1111111/inboxes/4288340/messages/5273448410/body.html + 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 + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Date: + - Tue, 30 Dec 2025 23:46:52 GMT + Content-Type: + - text/html; 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 + X-Mailtrap-Version: + - v2 + X-Ratelimit-Limit: + - '150' + X-Ratelimit-Remaining: + - '149' + Etag: + - W/"c3f79838405704ab71f19d8c5c5cf80e" + Cache-Control: + - max-age=0, private, must-revalidate + X-Request-Id: + - 367d3510-1733-4eec-94a2-49ef3b3cdd5c + X-Runtime: + - '0.024095' + X-Cloud-Trace-Context: + - c13553c8163348f18c44f21b26d90cc4;o=0 + Strict-Transport-Security: + - max-age=0 + Cf-Cache-Status: + - DYNAMIC + Cf-Ray: + - 9b8e9e210a95d2e3-FRA + Alt-Svc: + - h3=":443"; ma=86400 + body: + encoding: ASCII-8BIT + string: "

Welcome to Mailtrap!

" + recorded_at: Tue, 30 Dec 2025 23:46:52 GMT +recorded_with: VCR 6.2.0 diff --git a/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_get_html_message/when_sandbox_message_does_not_exist/raises_not_found_error.yml b/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_get_html_message/when_sandbox_message_does_not_exist/raises_not_found_error.yml new file mode 100644 index 0000000..5f002b7 --- /dev/null +++ b/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_get_html_message/when_sandbox_message_does_not_exist/raises_not_found_error.yml @@ -0,0 +1,75 @@ +--- +http_interactions: +- request: + method: get + uri: https://mailtrap.io/api/accounts/1111111/inboxes/4288340/messages/-1/body.html + 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 + Content-Type: + - application/json + response: + status: + code: 404 + message: Not Found + headers: + Date: + - Tue, 30 Dec 2025 23:46:52 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 + X-Mailtrap-Version: + - v2 + X-Ratelimit-Limit: + - '150' + X-Ratelimit-Remaining: + - '148' + Cache-Control: + - no-cache + X-Request-Id: + - df4931f4-bc51-4a8d-82da-9c09feb8d663 + X-Runtime: + - '0.014718' + X-Cloud-Trace-Context: + - f7bec6872dbf47678f24f8dbb844c532;o=0 + Strict-Transport-Security: + - max-age=0 + Cf-Cache-Status: + - DYNAMIC + Cf-Ray: + - 9b8e9e240c2ed9d2-FRA + Alt-Svc: + - h3=":443"; ma=86400 + body: + encoding: ASCII-8BIT + string: '{"error":"Not Found"}' + recorded_at: Tue, 30 Dec 2025 23:46:52 GMT +recorded_with: VCR 6.2.0 diff --git a/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_get_html_source/returns_html_source_message.yml b/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_get_html_source/returns_html_source_message.yml new file mode 100644 index 0000000..771f66f --- /dev/null +++ b/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_get_html_source/returns_html_source_message.yml @@ -0,0 +1,77 @@ +--- +http_interactions: +- request: + method: get + uri: https://mailtrap.io/api/accounts/1111111/inboxes/4288340/messages/5273448410/body.htmlsource + 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 + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Date: + - Tue, 30 Dec 2025 23:46:02 GMT + Content-Type: + - text/html; 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 + X-Mailtrap-Version: + - v2 + X-Ratelimit-Limit: + - '150' + X-Ratelimit-Remaining: + - '149' + Etag: + - W/"c3f79838405704ab71f19d8c5c5cf80e" + Cache-Control: + - max-age=0, private, must-revalidate + X-Request-Id: + - 51d8ed87-60d2-4de7-96ea-f46faa26b5ef + X-Runtime: + - '0.022586' + X-Cloud-Trace-Context: + - 65ec8a9b9f9b4f8e86181c7cb6a1e5b3;o=0 + Strict-Transport-Security: + - max-age=0 + Cf-Cache-Status: + - DYNAMIC + Cf-Ray: + - 9b8e9ceb1fa93826-FRA + Alt-Svc: + - h3=":443"; ma=86400 + body: + encoding: ASCII-8BIT + string: "

Welcome to Mailtrap!

" + recorded_at: Tue, 30 Dec 2025 23:46:02 GMT +recorded_with: VCR 6.2.0 diff --git a/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_get_html_source/when_sandbox_message_does_not_exist/raises_not_found_error.yml b/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_get_html_source/when_sandbox_message_does_not_exist/raises_not_found_error.yml new file mode 100644 index 0000000..a2cf1bb --- /dev/null +++ b/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_get_html_source/when_sandbox_message_does_not_exist/raises_not_found_error.yml @@ -0,0 +1,75 @@ +--- +http_interactions: +- request: + method: get + uri: https://mailtrap.io/api/accounts/1111111/inboxes/4288340/messages/-1/body.htmlsource + 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 + Content-Type: + - application/json + response: + status: + code: 404 + message: Not Found + headers: + Date: + - Tue, 30 Dec 2025 23:46:16 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 + X-Mailtrap-Version: + - v2 + X-Ratelimit-Limit: + - '150' + X-Ratelimit-Remaining: + - '149' + Cache-Control: + - no-cache + X-Request-Id: + - ce1c500b-5721-4ef6-8542-90ab13647e02 + X-Runtime: + - '0.018667' + X-Cloud-Trace-Context: + - cba4c588b41e422dceb33f2711ecf5e0;o=0 + Strict-Transport-Security: + - max-age=0 + Cf-Cache-Status: + - DYNAMIC + Cf-Ray: + - 9b8e9d438d3837f0-FRA + Alt-Svc: + - h3=":443"; ma=86400 + body: + encoding: ASCII-8BIT + string: '{"error":"Not Found"}' + recorded_at: Tue, 30 Dec 2025 23:46:16 GMT +recorded_with: VCR 6.2.0 diff --git a/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_get_mail_headers/returns_headers.yml b/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_get_mail_headers/returns_headers.yml new file mode 100644 index 0000000..2da57c0 --- /dev/null +++ b/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_get_mail_headers/returns_headers.yml @@ -0,0 +1,82 @@ +--- +http_interactions: +- request: + method: get + uri: https://mailtrap.io/api/accounts/1111111/inboxes/4288340/messages/5273448410/mail_headers + 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 + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Date: + - Tue, 30 Dec 2025 23:49:09 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: + - '149' + Etag: + - W/"59bc68b8c69b8c87e66f53b460c2ee8d" + Cache-Control: + - max-age=0, private, must-revalidate + X-Request-Id: + - b564cf78-b604-4ef1-b3e2-54ae13671701 + X-Runtime: + - '0.022971' + X-Cloud-Trace-Context: + - eb5d47ac1bbf4feac5b877514362948f;o=0 + Strict-Transport-Security: + - max-age=0 + Cf-Cache-Status: + - DYNAMIC + Cf-Ray: + - 9b8ea17b8a69ac6b-FRA + Alt-Svc: + - h3=":443"; ma=86400 + body: + encoding: ASCII-8BIT + string: '{"headers":{"date":"Tue, 30 Dec 2025 16:55:50 +0000","from":"reply@demomailtrap.co","to":"yahor.vaitsiakhouski@railsware.com","subject":"Hello + from Mailtrap","mime_version":"1.0","content_type":"multipart/alternative; + boundary=123","bcc":"not + available for your plan"}}' + recorded_at: Tue, 30 Dec 2025 23:49:09 GMT +recorded_with: VCR 6.2.0 diff --git a/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_get_mail_headers/when_sandbox_message_does_not_exist/raises_not_found_error.yml b/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_get_mail_headers/when_sandbox_message_does_not_exist/raises_not_found_error.yml new file mode 100644 index 0000000..77e670c --- /dev/null +++ b/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_get_mail_headers/when_sandbox_message_does_not_exist/raises_not_found_error.yml @@ -0,0 +1,77 @@ +--- +http_interactions: +- request: + method: get + uri: https://mailtrap.io/api/accounts/1111111/inboxes/4288340/messages/-1/mail_headers + 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 + Content-Type: + - application/json + response: + status: + code: 404 + message: Not Found + headers: + Date: + - Tue, 30 Dec 2025 23:49:09 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: + - 9b0e13f9-426f-443a-9be7-09b9a82428a3 + X-Runtime: + - '0.019187' + X-Cloud-Trace-Context: + - a8673dba9ecc459ec798d7cbbb94b1a6;o=0 + Strict-Transport-Security: + - max-age=0 + Cf-Cache-Status: + - DYNAMIC + Cf-Ray: + - 9b8ea17e8ac32be5-FRA + Alt-Svc: + - h3=":443"; ma=86400 + body: + encoding: ASCII-8BIT + string: '{"error":"Not Found"}' + recorded_at: Tue, 30 Dec 2025 23:49:09 GMT +recorded_with: VCR 6.2.0 diff --git a/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_get_message_as_eml/returns_html_message.yml b/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_get_message_as_eml/returns_html_message.yml new file mode 100644 index 0000000..2c75e6f --- /dev/null +++ b/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_get_message_as_eml/returns_html_message.yml @@ -0,0 +1,87 @@ +--- +http_interactions: +- request: + method: get + uri: https://mailtrap.io/api/accounts/1111111/inboxes/4288340/messages/5273448410/body.eml + 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 + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Date: + - Tue, 30 Dec 2025 23:48:06 GMT + Content-Type: + - message/rfc822 + Content-Length: + - '691' + 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 + Content-Disposition: + - attachment; filename="Hello from Mailtrap.eml"; filename*=UTF-8''Hello%20from%20Mailtrap.eml + Content-Transfer-Encoding: + - binary + X-Mailtrap-Version: + - v2 + X-Ratelimit-Limit: + - '150' + X-Ratelimit-Remaining: + - '149' + Etag: + - W/"26112163b7041555e048aa32da30ec37" + Cache-Control: + - max-age=0, private, must-revalidate + X-Request-Id: + - 6083269b-f04a-42eb-9915-1aedc9c18ac8 + X-Runtime: + - '0.037645' + X-Cloud-Trace-Context: + - 63e02802d7dd4d45c9b8965152f5a168;o=0 + Strict-Transport-Security: + - max-age=0 + Cf-Cache-Status: + - DYNAMIC + Cf-Ray: + - 9b8e9fef6ff15d8c-FRA + Alt-Svc: + - h3=":443"; ma=86400 + body: + encoding: UTF-8 + string: "MIME-Version: 1.0\r\nDate: Tue, 30 Dec 2025 16:55:50 +0000\r\nTo: yahor.vaitsiakhouski@railsware.com\r\nSubject: + Hello from Mailtrap\r\nFrom: reply@demomailtrap.co\r\nContent-Type: multipart/alternative;\r\n + boundary=4f9d09de93fe15363facbecec5c2941a90a45766953c87ed7b377c1d02ad\r\n\r\n--4f9d09de93fe15363facbecec5c2941a90a45766953c87ed7b377c1d02ad\r\nContent-Transfer-Encoding: + quoted-printable\r\nContent-Type: text/plain; charset=UTF-8\r\n\r\nWelcome + to Mailtrap!\r\n--4f9d09de93fe15363facbecec5c2941a90a45766953c87ed7b377c1d02ad\r\nContent-Transfer-Encoding: + quoted-printable\r\nContent-Type: text/html; charset=UTF-8\r\n\r\n

Welcome + to Mailtrap!

\r\n--4f9d09de93fe15363facbecec5c2941a90a45766953c87ed7b377c1d02ad--\r\n" + recorded_at: Tue, 30 Dec 2025 23:48:06 GMT +recorded_with: VCR 6.2.0 diff --git a/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_get_message_as_eml/when_sandbox_message_does_not_exist/raises_not_found_error.yml b/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_get_message_as_eml/when_sandbox_message_does_not_exist/raises_not_found_error.yml new file mode 100644 index 0000000..0f3bf32 --- /dev/null +++ b/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_get_message_as_eml/when_sandbox_message_does_not_exist/raises_not_found_error.yml @@ -0,0 +1,75 @@ +--- +http_interactions: +- request: + method: get + uri: https://mailtrap.io/api/accounts/1111111/inboxes/4288340/messages/-1/body.eml + 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 + Content-Type: + - application/json + response: + status: + code: 404 + message: Not Found + headers: + Date: + - Tue, 30 Dec 2025 23:48:06 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 + X-Mailtrap-Version: + - v2 + X-Ratelimit-Limit: + - '150' + X-Ratelimit-Remaining: + - '148' + Cache-Control: + - no-cache + X-Request-Id: + - 3e59b458-4793-406e-bd43-d4bba93b6665 + X-Runtime: + - '0.018622' + X-Cloud-Trace-Context: + - 35858ffd0f024525c14ab2c29a977571;o=0 + Strict-Transport-Security: + - max-age=0 + Cf-Cache-Status: + - DYNAMIC + Cf-Ray: + - 9b8e9ff32ace0ac2-FRA + Alt-Svc: + - h3=":443"; ma=86400 + body: + encoding: ASCII-8BIT + string: '{"error":"Not Found"}' + recorded_at: Tue, 30 Dec 2025 23:48:06 GMT +recorded_with: VCR 6.2.0 diff --git a/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_get_raw_message/returns_raw_message.yml b/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_get_raw_message/returns_raw_message.yml new file mode 100644 index 0000000..778c505 --- /dev/null +++ b/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_get_raw_message/returns_raw_message.yml @@ -0,0 +1,83 @@ +--- +http_interactions: +- request: + method: get + uri: https://mailtrap.io/api/accounts/1111111/inboxes/4288340/messages/5273448410/body.raw + 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 + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Date: + - Tue, 30 Dec 2025 23:44:31 GMT + Content-Type: + - text/plain; 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 + X-Mailtrap-Version: + - v2 + X-Ratelimit-Limit: + - '150' + X-Ratelimit-Remaining: + - '149' + Etag: + - W/"26112163b7041555e048aa32da30ec37" + Cache-Control: + - max-age=0, private, must-revalidate + X-Request-Id: + - a5393869-6bc3-4759-a3f9-adce4a6b419c + X-Runtime: + - '0.017244' + X-Cloud-Trace-Context: + - 7f93ca1107c94ded8122a967f45446ad;o=0 + Strict-Transport-Security: + - max-age=0 + Cf-Cache-Status: + - DYNAMIC + Cf-Ray: + - 9b8e9ab47a269bdc-FRA + Alt-Svc: + - h3=":443"; ma=86400 + body: + encoding: ASCII-8BIT + string: "MIME-Version: 1.0\r\nDate: Tue, 30 Dec 2025 16:55:50 +0000\r\nTo: yahor.vaitsiakhouski@railsware.com\r\nSubject: + Hello from Mailtrap\r\nFrom: reply@demomailtrap.co\r\nContent-Type: multipart/alternative;\r\n + boundary=4f9d09de93fe15363facbecec5c2941a90a45766953c87ed7b377c1d02ad\r\n\r\n--4f9d09de93fe15363facbecec5c2941a90a45766953c87ed7b377c1d02ad\r\nContent-Transfer-Encoding: + quoted-printable\r\nContent-Type: text/plain; charset=UTF-8\r\n\r\nWelcome + to Mailtrap!\r\n--4f9d09de93fe15363facbecec5c2941a90a45766953c87ed7b377c1d02ad\r\nContent-Transfer-Encoding: + quoted-printable\r\nContent-Type: text/html; charset=UTF-8\r\n\r\n

Welcome + to Mailtrap!

\r\n--4f9d09de93fe15363facbecec5c2941a90a45766953c87ed7b377c1d02ad--\r\n" + recorded_at: Tue, 30 Dec 2025 23:44:31 GMT +recorded_with: VCR 6.2.0 diff --git a/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_get_raw_message/when_sandbox_message_does_not_exist/raises_not_found_error.yml b/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_get_raw_message/when_sandbox_message_does_not_exist/raises_not_found_error.yml new file mode 100644 index 0000000..da8e14e --- /dev/null +++ b/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_get_raw_message/when_sandbox_message_does_not_exist/raises_not_found_error.yml @@ -0,0 +1,75 @@ +--- +http_interactions: +- request: + method: get + uri: https://mailtrap.io/api/accounts/1111111/inboxes/4288340/messages/-1/body.raw + 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 + Content-Type: + - application/json + response: + status: + code: 404 + message: Not Found + headers: + Date: + - Tue, 30 Dec 2025 23:44:32 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 + X-Mailtrap-Version: + - v2 + X-Ratelimit-Limit: + - '150' + X-Ratelimit-Remaining: + - '148' + Cache-Control: + - no-cache + X-Request-Id: + - b5440b04-954d-4735-8543-8ed9334549c7 + X-Runtime: + - '0.017779' + X-Cloud-Trace-Context: + - 711b45a926614fd0cc4e20a54059c812;o=0 + Strict-Transport-Security: + - max-age=0 + Cf-Cache-Status: + - DYNAMIC + Cf-Ray: + - 9b8e9ab76ce2a8cb-FRA + Alt-Svc: + - h3=":443"; ma=86400 + body: + encoding: ASCII-8BIT + string: '{"error":"Not Found"}' + recorded_at: Tue, 30 Dec 2025 23:44:32 GMT +recorded_with: VCR 6.2.0 diff --git a/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_get_spam_score/returns_report.yml b/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_get_spam_score/returns_report.yml new file mode 100644 index 0000000..b1a2f22 --- /dev/null +++ b/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_get_spam_score/returns_report.yml @@ -0,0 +1,81 @@ +--- +http_interactions: +- request: + method: get + uri: https://mailtrap.io/api/accounts/1111111/inboxes/4288340/messages/5273448410/spam_report + 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 + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Date: + - Tue, 30 Dec 2025 23:28:27 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: + - '149' + Etag: + - W/"2692ba0984dfdc915b8948db13a9624c" + Cache-Control: + - max-age=0, private, must-revalidate + X-Request-Id: + - 4fe65b60-1cd0-49e3-b6e4-0f5c129fa498 + X-Runtime: + - '0.018114' + X-Cloud-Trace-Context: + - 47a9ec3877674d6086538b033851d6fc;o=0 + Strict-Transport-Security: + - max-age=0 + Cf-Cache-Status: + - DYNAMIC + Cf-Ray: + - 9b8e832c1b3e3a4a-FRA + Alt-Svc: + - h3=":443"; ma=86400 + body: + encoding: ASCII-8BIT + string: '{"report":{"ResponseCode":0,"ResponseMessage":"EX_OK","ResponseVersion":"1.1","Score":0.1,"Spam":false,"Threshold":5.0,"Details":[{"Pts":"0.1","RuleName":"MISSING_MID","Description":"Missing + Message-Id: header"},{"Pts":"0.0","RuleName":"HTML_MESSAGE","Description":"BODY: + HTML included in message"}]}}' + recorded_at: Tue, 30 Dec 2025 23:28:27 GMT +recorded_with: VCR 6.2.0 diff --git a/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_get_spam_score/when_sandbox_message_does_not_exist/raises_not_found_error.yml b/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_get_spam_score/when_sandbox_message_does_not_exist/raises_not_found_error.yml new file mode 100644 index 0000000..b272295 --- /dev/null +++ b/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_get_spam_score/when_sandbox_message_does_not_exist/raises_not_found_error.yml @@ -0,0 +1,77 @@ +--- +http_interactions: +- request: + method: get + uri: https://mailtrap.io/api/accounts/1111111/inboxes/4288340/messages/-1/spam_report + 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 + Content-Type: + - application/json + response: + status: + code: 404 + message: Not Found + headers: + Date: + - Tue, 30 Dec 2025 23:28:27 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: + - 10fe63b0-d3d0-49ca-b1c4-d84f51a70ecc + X-Runtime: + - '0.021012' + X-Cloud-Trace-Context: + - 3a10ee688a1446cfcbf775f4481d66a0;o=3 + Strict-Transport-Security: + - max-age=0 + Cf-Cache-Status: + - DYNAMIC + Cf-Ray: + - 9b8e832d4c0065b4-FRA + Alt-Svc: + - h3=":443"; ma=86400 + body: + encoding: ASCII-8BIT + string: '{"error":"Not Found"}' + recorded_at: Tue, 30 Dec 2025 23:28:27 GMT +recorded_with: VCR 6.2.0 diff --git a/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_get_text_message/returns_text_message.yml b/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_get_text_message/returns_text_message.yml new file mode 100644 index 0000000..4c1909e --- /dev/null +++ b/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_get_text_message/returns_text_message.yml @@ -0,0 +1,77 @@ +--- +http_interactions: +- request: + method: get + uri: https://mailtrap.io/api/accounts/1111111/inboxes/4288340/messages/5273448410/body.txt + 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 + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Date: + - Tue, 30 Dec 2025 23:41:19 GMT + Content-Type: + - text/plain; 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 + X-Mailtrap-Version: + - v2 + X-Ratelimit-Limit: + - '150' + X-Ratelimit-Remaining: + - '149' + Etag: + - W/"da32e36a1365f2f4a2220e139293ee5c" + Cache-Control: + - max-age=0, private, must-revalidate + X-Request-Id: + - dc59bf9e-8d10-4688-8c5a-af357bed352f + X-Runtime: + - '0.019055' + X-Cloud-Trace-Context: + - 8ae6ee1c06cd4b8f87ec3ee29a31f615;o=0 + Strict-Transport-Security: + - max-age=0 + Cf-Cache-Status: + - DYNAMIC + Cf-Ray: + - 9b8e9606dcf01c1c-FRA + Alt-Svc: + - h3=":443"; ma=86400 + body: + encoding: ASCII-8BIT + string: Welcome to Mailtrap! + recorded_at: Tue, 30 Dec 2025 23:41:19 GMT +recorded_with: VCR 6.2.0 diff --git a/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_get_text_message/when_sandbox_message_does_not_exist/raises_not_found_error.yml b/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_get_text_message/when_sandbox_message_does_not_exist/raises_not_found_error.yml new file mode 100644 index 0000000..c56ecaa --- /dev/null +++ b/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_get_text_message/when_sandbox_message_does_not_exist/raises_not_found_error.yml @@ -0,0 +1,75 @@ +--- +http_interactions: +- request: + method: get + uri: https://mailtrap.io/api/accounts/1111111/inboxes/4288340/messages/-1/body.txt + 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 + Content-Type: + - application/json + response: + status: + code: 404 + message: Not Found + headers: + Date: + - Tue, 30 Dec 2025 23:41:20 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 + X-Mailtrap-Version: + - v2 + X-Ratelimit-Limit: + - '150' + X-Ratelimit-Remaining: + - '149' + Cache-Control: + - no-cache + X-Request-Id: + - 2a154ca7-a39f-4c94-aa35-608b566a727f + X-Runtime: + - '0.019361' + X-Cloud-Trace-Context: + - 04f8621982364f1acc4ed3bc169ebd17;o=0 + Strict-Transport-Security: + - max-age=0 + Cf-Cache-Status: + - DYNAMIC + Cf-Ray: + - 9b8e9608ccf41e26-FRA + Alt-Svc: + - h3=":443"; ma=86400 + body: + encoding: ASCII-8BIT + string: '{"error":"Not Found"}' + recorded_at: Tue, 30 Dec 2025 23:41:20 GMT +recorded_with: VCR 6.2.0 diff --git a/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_list/maps_response_data_to_SandboxMessage_objects.yml b/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_list/maps_response_data_to_SandboxMessage_objects.yml new file mode 100644 index 0000000..f96420b --- /dev/null +++ b/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_list/maps_response_data_to_SandboxMessage_objects.yml @@ -0,0 +1,99 @@ +--- +http_interactions: +- request: + method: get + uri: https://mailtrap.io/api/accounts/1111111/inboxes/4288340/messages + 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 + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Date: + - Tue, 30 Dec 2025 23:19:15 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Server: + - cloudflare + Vary: + - Accept + - Accept-Encoding + 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 + X-Mailtrap-Version: + - v2 + X-Ratelimit-Limit: + - '150' + X-Ratelimit-Remaining: + - '149' + Etag: + - W/"780b6707b982a758920281aedb156276" + Cache-Control: + - max-age=0, private, must-revalidate + X-Request-Id: + - 8e231226-882e-43ee-b3e9-92c4175731a5 + X-Runtime: + - '0.020142' + X-Cloud-Trace-Context: + - 3a464e2774ea4f4dcc852bde1dc7edce;o=0 + Strict-Transport-Security: + - max-age=0 + Cf-Cache-Status: + - DYNAMIC + Cf-Ray: + - 9b8e75aeda013837-FRA + Alt-Svc: + - h3=":443"; ma=86400 + body: + encoding: ASCII-8BIT + string: '[{"id":5273671945,"inbox_id":4288340,"subject":"Hello from Mailtrap","sent_at":"2026-01-04T11:17:56.575-12:00","from_email":"reply@demomailtrap.co","from_name":"","to_email":"alex.d@railsware.com","to_name":"","email_size":677,"is_read":false,"created_at":"2026-01-04T11:17:56.579-12:00","updated_at":"2026-01-04T11:17:56.797-12:00","template_id":0,"template_variables":null,"html_body_size":29,"text_body_size":20,"human_size":"677 + Bytes","html_path":"/api/testing_message_parts/QEVuQwFAEAD6SO5PqWHlAWWad6MRonhtsuZxmCo4xzuFGE0LxKt6KDddCoGCmfx8kJdAWyxONzRlvqhB5mnkHxhicF6lbIh6dxpbBW8fNKU4wFjIE2F2d6+IvRnXDgBVNvWDZ+PIEjg=/body.html","txt_path":"/api/testing_message_parts/QEVuQwFAEAD6SO5PqWHlAWWad6MRonhtsuZxmCo4xzuFGE0LxKt6KDddCoGCmfx8kJdAWyxONzRlvqhB5mnkHxhicF6lbIh6dxpbBW8fNKU4wFjIE2F2d6+IvRnXDgBVNvWDZ+PIEjg=/body.txt","raw_path":"/api/testing_message_parts/QEVuQwFAEAD6SO5PqWHlAWWad6MRonhtsuZxmCo4xzuFGE0LxKt6KDddCoGCmfx8kJdAWyxONzRlvqhB5mnkHxhicF6lbIh6dxpbBW8fNKU4wFjIE2F2d6+IvRnXDgBVNvWDZ+PIEjg=/body.raw","download_path":"/api/testing_message_parts/QEVuQwFAEAD6SO5PqWHlAWWad6MRonhtsuZxmCo4xzuFGE0LxKt6KDddCoGCmfx8kJdAWyxONzRlvqhB5mnkHxhicF6lbIh6dxpbBW8fNKU4wFjIE2F2d6+IvRnXDgBVNvWDZ+PIEjg=/body.eml","html_source_path":"/api/testing_message_parts/QEVuQwFAEAD6SO5PqWHlAWWad6MRonhtsuZxmCo4xzuFGE0LxKt6KDddCoGCmfx8kJdAWyxONzRlvqhB5mnkHxhicF6lbIh6dxpbBW8fNKU4wFjIE2F2d6+IvRnXDgBVNvWDZ+PIEjg=/body.htmlsource","blacklists_report_info":{"result":"success","domain":"demomailtrap.co","ip":"104.21.25.146","report":[{"name":"BACKSCATTERER","url":"http://www.backscatterer.org/index.php","in_black_list":false},{"name":"BARRACUDA","url":"http://barracudacentral.org/rbl","in_black_list":false},{"name":"Spamrbl + IMP-SPAM","url":"http://antispam.imp.ch/?lng=1","in_black_list":false},{"name":"Wormrbl + IMP-SPAM","url":"http://antispam.imp.ch/?lng=1","in_black_list":false},{"name":"LASHBACK","url":"http://blacklist.lashback.com/","in_black_list":false},{"name":"NIXSPAM","url":"https://www.heise.de/ix/NiX-Spam-DNSBL-and-blacklist-for-download-499637.html","in_black_list":false},{"name":"PSBL","url":"https://psbl.org/","in_black_list":false},{"name":"SORBS-SPAM","url":"http://www.sorbs.net/lookup.shtml","in_black_list":false},{"name":"SPAMCOP","url":"http://spamcop.net/bl.shtml","in_black_list":false},{"name":"TRUNCATE","url":"http://www.gbudb.com/truncate/index.jsp","in_black_list":false}]},"smtp_information":{"ok":false}},{"id":5273671571,"inbox_id":4288340,"subject":"Hello + from Mailtrap","sent_at":"2026-01-04T11:17:40.025-12:00","from_email":"reply@demomailtrap.co","from_name":"","to_email":"alex.d@railsware.com","to_name":"","email_size":677,"is_read":false,"created_at":"2026-01-04T11:17:40.029-12:00","updated_at":"2026-01-04T11:17:40.208-12:00","template_id":0,"template_variables":null,"html_body_size":29,"text_body_size":20,"human_size":"677 + Bytes","html_path":"/api/testing_message_parts/QEVuQwFAEAAwMccBahxwpCSHvGNpOmK54J4cObh1DdN9Wixmdbc%2FzsVUvM0ac986GgLvzHzXUmQG0Dp+qyvCjLu62542pDz7ORIh4XQlmVjD7Ey0bN1IPtRIYPQgHXf+ldLmjrn1eEw=/body.html","txt_path":"/api/testing_message_parts/QEVuQwFAEAAwMccBahxwpCSHvGNpOmK54J4cObh1DdN9Wixmdbc%2FzsVUvM0ac986GgLvzHzXUmQG0Dp+qyvCjLu62542pDz7ORIh4XQlmVjD7Ey0bN1IPtRIYPQgHXf+ldLmjrn1eEw=/body.txt","raw_path":"/api/testing_message_parts/QEVuQwFAEAAwMccBahxwpCSHvGNpOmK54J4cObh1DdN9Wixmdbc%2FzsVUvM0ac986GgLvzHzXUmQG0Dp+qyvCjLu62542pDz7ORIh4XQlmVjD7Ey0bN1IPtRIYPQgHXf+ldLmjrn1eEw=/body.raw","download_path":"/api/testing_message_parts/QEVuQwFAEAAwMccBahxwpCSHvGNpOmK54J4cObh1DdN9Wixmdbc%2FzsVUvM0ac986GgLvzHzXUmQG0Dp+qyvCjLu62542pDz7ORIh4XQlmVjD7Ey0bN1IPtRIYPQgHXf+ldLmjrn1eEw=/body.eml","html_source_path":"/api/testing_message_parts/QEVuQwFAEAAwMccBahxwpCSHvGNpOmK54J4cObh1DdN9Wixmdbc%2FzsVUvM0ac986GgLvzHzXUmQG0Dp+qyvCjLu62542pDz7ORIh4XQlmVjD7Ey0bN1IPtRIYPQgHXf+ldLmjrn1eEw=/body.htmlsource","blacklists_report_info":{"result":"success","domain":"demomailtrap.co","ip":"104.21.25.146","report":[{"name":"BACKSCATTERER","url":"http://www.backscatterer.org/index.php","in_black_list":false},{"name":"BARRACUDA","url":"http://barracudacentral.org/rbl","in_black_list":false},{"name":"Spamrbl + IMP-SPAM","url":"http://antispam.imp.ch/?lng=1","in_black_list":false},{"name":"Wormrbl + IMP-SPAM","url":"http://antispam.imp.ch/?lng=1","in_black_list":false},{"name":"LASHBACK","url":"http://blacklist.lashback.com/","in_black_list":false},{"name":"NIXSPAM","url":"https://www.heise.de/ix/NiX-Spam-DNSBL-and-blacklist-for-download-499637.html","in_black_list":false},{"name":"PSBL","url":"https://psbl.org/","in_black_list":false},{"name":"SORBS-SPAM","url":"http://www.sorbs.net/lookup.shtml","in_black_list":false},{"name":"SPAMCOP","url":"http://spamcop.net/bl.shtml","in_black_list":false},{"name":"TRUNCATE","url":"http://www.gbudb.com/truncate/index.jsp","in_black_list":false}]},"smtp_information":{"ok":false}},{"id":5273658235,"inbox_id":4288340,"subject":"Hello + from Mailtrap","sent_at":"2026-01-04T11:08:05.870-12:00","from_email":"reply@demomailtrap.co","from_name":"","to_email":"yahor.vaitsiakhouski@railsware.com","to_name":"","email_size":691,"is_read":false,"created_at":"2026-01-04T11:08:05.873-12:00","updated_at":"2026-01-04T11:08:06.345-12:00","template_id":0,"template_variables":null,"html_body_size":29,"text_body_size":20,"human_size":"691 + Bytes","html_path":"/api/testing_message_parts/QEVuQwFAEADzXxlMx6oGhd49S3sbPDtQlIFa+JkL9GlSCs099IOk4p7bFncj2N14yQqRK9nMKUL7gpZJGtnVlsafmG5+jPD4rxbbzlc2vb0z+aa%2Fy9f2Nk6HwN3WHGDcjmYUl%2F5Crxw=/body.html","txt_path":"/api/testing_message_parts/QEVuQwFAEADzXxlMx6oGhd49S3sbPDtQlIFa+JkL9GlSCs099IOk4p7bFncj2N14yQqRK9nMKUL7gpZJGtnVlsafmG5+jPD4rxbbzlc2vb0z+aa%2Fy9f2Nk6HwN3WHGDcjmYUl%2F5Crxw=/body.txt","raw_path":"/api/testing_message_parts/QEVuQwFAEADzXxlMx6oGhd49S3sbPDtQlIFa+JkL9GlSCs099IOk4p7bFncj2N14yQqRK9nMKUL7gpZJGtnVlsafmG5+jPD4rxbbzlc2vb0z+aa%2Fy9f2Nk6HwN3WHGDcjmYUl%2F5Crxw=/body.raw","download_path":"/api/testing_message_parts/QEVuQwFAEADzXxlMx6oGhd49S3sbPDtQlIFa+JkL9GlSCs099IOk4p7bFncj2N14yQqRK9nMKUL7gpZJGtnVlsafmG5+jPD4rxbbzlc2vb0z+aa%2Fy9f2Nk6HwN3WHGDcjmYUl%2F5Crxw=/body.eml","html_source_path":"/api/testing_message_parts/QEVuQwFAEADzXxlMx6oGhd49S3sbPDtQlIFa+JkL9GlSCs099IOk4p7bFncj2N14yQqRK9nMKUL7gpZJGtnVlsafmG5+jPD4rxbbzlc2vb0z+aa%2Fy9f2Nk6HwN3WHGDcjmYUl%2F5Crxw=/body.htmlsource","blacklists_report_info":{"result":"success","domain":"demomailtrap.co","ip":"172.67.134.80","report":[{"name":"BACKSCATTERER","url":"http://www.backscatterer.org/index.php","in_black_list":false},{"name":"BARRACUDA","url":"http://barracudacentral.org/rbl","in_black_list":false},{"name":"Spamrbl + IMP-SPAM","url":"http://antispam.imp.ch/?lng=1","in_black_list":false},{"name":"Wormrbl + IMP-SPAM","url":"http://antispam.imp.ch/?lng=1","in_black_list":false},{"name":"LASHBACK","url":"http://blacklist.lashback.com/","in_black_list":false},{"name":"NIXSPAM","url":"https://www.heise.de/ix/NiX-Spam-DNSBL-and-blacklist-for-download-499637.html","in_black_list":false},{"name":"PSBL","url":"https://psbl.org/","in_black_list":false},{"name":"SORBS-SPAM","url":"http://www.sorbs.net/lookup.shtml","in_black_list":false},{"name":"SPAMCOP","url":"http://spamcop.net/bl.shtml","in_black_list":false},{"name":"TRUNCATE","url":"http://www.gbudb.com/truncate/index.jsp","in_black_list":false}]},"smtp_information":{"ok":false}},{"id":5273657771,"inbox_id":4288340,"subject":"Hello + from Mailtrap","sent_at":"2026-01-04T11:07:53.393-12:00","from_email":"reply@demomailtrap.co","from_name":"","to_email":"yahor.vaitsiakhouski@railsware.com","to_name":"","email_size":691,"is_read":false,"created_at":"2026-01-04T11:07:53.397-12:00","updated_at":"2026-01-04T11:07:53.612-12:00","template_id":0,"template_variables":null,"html_body_size":29,"text_body_size":20,"human_size":"691 + Bytes","html_path":"/api/testing_message_parts/QEVuQwFAEAAqoDt60NsiAXoLrG16ONWmcbgh2hw4uGu4grMhCKyE2CXwABujAnbZtUeXqcYstYAclCc3HylSziZMYHBV7+eQMNE5IRlzXi235EMbbn6NuxxjEfCG8zqmD6ey9Xg+Z94=/body.html","txt_path":"/api/testing_message_parts/QEVuQwFAEAAqoDt60NsiAXoLrG16ONWmcbgh2hw4uGu4grMhCKyE2CXwABujAnbZtUeXqcYstYAclCc3HylSziZMYHBV7+eQMNE5IRlzXi235EMbbn6NuxxjEfCG8zqmD6ey9Xg+Z94=/body.txt","raw_path":"/api/testing_message_parts/QEVuQwFAEAAqoDt60NsiAXoLrG16ONWmcbgh2hw4uGu4grMhCKyE2CXwABujAnbZtUeXqcYstYAclCc3HylSziZMYHBV7+eQMNE5IRlzXi235EMbbn6NuxxjEfCG8zqmD6ey9Xg+Z94=/body.raw","download_path":"/api/testing_message_parts/QEVuQwFAEAAqoDt60NsiAXoLrG16ONWmcbgh2hw4uGu4grMhCKyE2CXwABujAnbZtUeXqcYstYAclCc3HylSziZMYHBV7+eQMNE5IRlzXi235EMbbn6NuxxjEfCG8zqmD6ey9Xg+Z94=/body.eml","html_source_path":"/api/testing_message_parts/QEVuQwFAEAAqoDt60NsiAXoLrG16ONWmcbgh2hw4uGu4grMhCKyE2CXwABujAnbZtUeXqcYstYAclCc3HylSziZMYHBV7+eQMNE5IRlzXi235EMbbn6NuxxjEfCG8zqmD6ey9Xg+Z94=/body.htmlsource","blacklists_report_info":{"result":"success","domain":"demomailtrap.co","ip":"104.21.25.146","report":[{"name":"BACKSCATTERER","url":"http://www.backscatterer.org/index.php","in_black_list":false},{"name":"BARRACUDA","url":"http://barracudacentral.org/rbl","in_black_list":false},{"name":"Spamrbl + IMP-SPAM","url":"http://antispam.imp.ch/?lng=1","in_black_list":false},{"name":"Wormrbl + IMP-SPAM","url":"http://antispam.imp.ch/?lng=1","in_black_list":false},{"name":"LASHBACK","url":"http://blacklist.lashback.com/","in_black_list":false},{"name":"NIXSPAM","url":"https://www.heise.de/ix/NiX-Spam-DNSBL-and-blacklist-for-download-499637.html","in_black_list":false},{"name":"PSBL","url":"https://psbl.org/","in_black_list":false},{"name":"SORBS-SPAM","url":"http://www.sorbs.net/lookup.shtml","in_black_list":false},{"name":"SPAMCOP","url":"http://spamcop.net/bl.shtml","in_black_list":false},{"name":"TRUNCATE","url":"http://www.gbudb.com/truncate/index.jsp","in_black_list":false}]},"smtp_information":{"ok":false}},{"id":5273448410,"inbox_id":4288340,"subject":"Hello + from Mailtrap","sent_at":"2026-01-04T04:55:50.867-12:00","from_email":"reply@demomailtrap.co","from_name":"","to_email":"yahor.vaitsiakhouski@railsware.com","to_name":"","email_size":691,"is_read":true,"created_at":"2026-01-04T04:55:50.871-12:00","updated_at":"2026-01-04T04:55:56.618-12:00","template_id":0,"template_variables":null,"html_body_size":29,"text_body_size":20,"human_size":"691 + Bytes","html_path":"/api/testing_message_parts/QEVuQwFAEADJFlRJY9SMP%2FJOaaQmlrkWyfvriLU6Qgs6g%2Fv8C+YRSp1FNTDZpwmdfYTuUfOdG5AHZU0cPVO7VdEB8C04npl4N78Oh+3jI9RMsyxc2hNlqm9OsvqX+drrnNQNBrNp1GE=/body.html","txt_path":"/api/testing_message_parts/QEVuQwFAEADJFlRJY9SMP%2FJOaaQmlrkWyfvriLU6Qgs6g%2Fv8C+YRSp1FNTDZpwmdfYTuUfOdG5AHZU0cPVO7VdEB8C04npl4N78Oh+3jI9RMsyxc2hNlqm9OsvqX+drrnNQNBrNp1GE=/body.txt","raw_path":"/api/testing_message_parts/QEVuQwFAEADJFlRJY9SMP%2FJOaaQmlrkWyfvriLU6Qgs6g%2Fv8C+YRSp1FNTDZpwmdfYTuUfOdG5AHZU0cPVO7VdEB8C04npl4N78Oh+3jI9RMsyxc2hNlqm9OsvqX+drrnNQNBrNp1GE=/body.raw","download_path":"/api/testing_message_parts/QEVuQwFAEADJFlRJY9SMP%2FJOaaQmlrkWyfvriLU6Qgs6g%2Fv8C+YRSp1FNTDZpwmdfYTuUfOdG5AHZU0cPVO7VdEB8C04npl4N78Oh+3jI9RMsyxc2hNlqm9OsvqX+drrnNQNBrNp1GE=/body.eml","html_source_path":"/api/testing_message_parts/QEVuQwFAEADJFlRJY9SMP%2FJOaaQmlrkWyfvriLU6Qgs6g%2Fv8C+YRSp1FNTDZpwmdfYTuUfOdG5AHZU0cPVO7VdEB8C04npl4N78Oh+3jI9RMsyxc2hNlqm9OsvqX+drrnNQNBrNp1GE=/body.htmlsource","blacklists_report_info":{"result":"success","domain":"demomailtrap.co","ip":"172.67.134.80","report":[{"name":"BACKSCATTERER","url":"http://www.backscatterer.org/index.php","in_black_list":false},{"name":"BARRACUDA","url":"http://barracudacentral.org/rbl","in_black_list":false},{"name":"Spamrbl + IMP-SPAM","url":"http://antispam.imp.ch/?lng=1","in_black_list":false},{"name":"Wormrbl + IMP-SPAM","url":"http://antispam.imp.ch/?lng=1","in_black_list":false},{"name":"LASHBACK","url":"http://blacklist.lashback.com/","in_black_list":false},{"name":"NIXSPAM","url":"https://www.heise.de/ix/NiX-Spam-DNSBL-and-blacklist-for-download-499637.html","in_black_list":false},{"name":"PSBL","url":"https://psbl.org/","in_black_list":false},{"name":"SORBS-SPAM","url":"http://www.sorbs.net/lookup.shtml","in_black_list":false},{"name":"SPAMCOP","url":"http://spamcop.net/bl.shtml","in_black_list":false},{"name":"TRUNCATE","url":"http://www.gbudb.com/truncate/index.jsp","in_black_list":false}]},"smtp_information":{"ok":false}}]' + recorded_at: Tue, 30 Dec 2025 23:19:15 GMT +recorded_with: VCR 6.2.0 diff --git a/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_list/when_api_key_is_incorrect/raises_authorization_error.yml b/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_list/when_api_key_is_incorrect/raises_authorization_error.yml new file mode 100644 index 0000000..a5810b5 --- /dev/null +++ b/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_list/when_api_key_is_incorrect/raises_authorization_error.yml @@ -0,0 +1,79 @@ +--- +http_interactions: +- request: + method: get + uri: https://mailtrap.io/api/accounts/1111111/inboxes/4288340/messages + 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 + Content-Type: + - application/json + response: + status: + code: 401 + message: Unauthorized + headers: + Date: + - Tue, 30 Dec 2025 23:19:16 GMT + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '31' + 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 + Www-Authenticate: + - Token realm="Application" + Vary: + - Accept + X-Mailtrap-Version: + - v2 + X-Ratelimit-Limit: + - '150' + X-Ratelimit-Remaining: + - '149' + Cache-Control: + - no-cache + X-Request-Id: + - 82cd7713-0701-4a95-a253-2ed9d6a76530 + X-Runtime: + - '0.007857' + X-Cloud-Trace-Context: + - ae93f0bfa36a4b36884f677e03212fab;o=0 + Strict-Transport-Security: + - max-age=0 + Cf-Cache-Status: + - DYNAMIC + Cf-Ray: + - 9b8e75b48aced9d0-FRA + Alt-Svc: + - h3=":443"; ma=86400 + body: + encoding: UTF-8 + string: '{"error":"Incorrect API token"}' + recorded_at: Tue, 30 Dec 2025 23:19:16 GMT +recorded_with: VCR 6.2.0 diff --git a/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_list/with_parameters/maps_response_data_to_SandboxMessage_objects.yml b/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_list/with_parameters/maps_response_data_to_SandboxMessage_objects.yml new file mode 100644 index 0000000..b4cf354 --- /dev/null +++ b/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_list/with_parameters/maps_response_data_to_SandboxMessage_objects.yml @@ -0,0 +1,83 @@ +--- +http_interactions: +- request: + method: get + uri: https://mailtrap.io/api/accounts/1111111/inboxes/4288340/messages?last_id=5273671943&search=alex.d + 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 + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Date: + - Tue, 30 Dec 2025 23:19:15 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Server: + - cloudflare + Vary: + - Accept + - Accept-Encoding + 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 + X-Mailtrap-Version: + - v2 + X-Ratelimit-Limit: + - '150' + X-Ratelimit-Remaining: + - '148' + Etag: + - W/"ea92f147657f0d3cac88c32c5aa0b446" + Cache-Control: + - max-age=0, private, must-revalidate + X-Request-Id: + - 4c776b0c-417b-47f1-a9bc-282bf451587f + X-Runtime: + - '0.022604' + X-Cloud-Trace-Context: + - 9f05486e7635464bc7d565a09ef723d5;o=0 + Strict-Transport-Security: + - max-age=0 + Cf-Cache-Status: + - DYNAMIC + Cf-Ray: + - 9b8e75b1ddc0d9d0-FRA + Alt-Svc: + - h3=":443"; ma=86400 + body: + encoding: ASCII-8BIT + string: '[{"id":5273671571,"inbox_id":4288340,"subject":"Hello from Mailtrap","sent_at":"2026-01-04T11:17:40.025-12:00","from_email":"reply@demomailtrap.co","from_name":"","to_email":"alex.d@railsware.com","to_name":"","email_size":677,"is_read":false,"created_at":"2026-01-04T11:17:40.029-12:00","updated_at":"2026-01-04T11:17:40.208-12:00","template_id":0,"template_variables":null,"html_body_size":29,"text_body_size":20,"human_size":"677 + Bytes","html_path":"/api/testing_message_parts/QEVuQwFAEAAwMccBahxwpCSHvGNpOmK54J4cObh1DdN9Wixmdbc%2FzsVUvM0ac986GgLvzHzXUmQG0Dp+qyvCjLu62542pDz7ORIh4XQlmVjD7Ey0bN1IPtRIYPQgHXf+ldLmjrn1eEw=/body.html","txt_path":"/api/testing_message_parts/QEVuQwFAEAAwMccBahxwpCSHvGNpOmK54J4cObh1DdN9Wixmdbc%2FzsVUvM0ac986GgLvzHzXUmQG0Dp+qyvCjLu62542pDz7ORIh4XQlmVjD7Ey0bN1IPtRIYPQgHXf+ldLmjrn1eEw=/body.txt","raw_path":"/api/testing_message_parts/QEVuQwFAEAAwMccBahxwpCSHvGNpOmK54J4cObh1DdN9Wixmdbc%2FzsVUvM0ac986GgLvzHzXUmQG0Dp+qyvCjLu62542pDz7ORIh4XQlmVjD7Ey0bN1IPtRIYPQgHXf+ldLmjrn1eEw=/body.raw","download_path":"/api/testing_message_parts/QEVuQwFAEAAwMccBahxwpCSHvGNpOmK54J4cObh1DdN9Wixmdbc%2FzsVUvM0ac986GgLvzHzXUmQG0Dp+qyvCjLu62542pDz7ORIh4XQlmVjD7Ey0bN1IPtRIYPQgHXf+ldLmjrn1eEw=/body.eml","html_source_path":"/api/testing_message_parts/QEVuQwFAEAAwMccBahxwpCSHvGNpOmK54J4cObh1DdN9Wixmdbc%2FzsVUvM0ac986GgLvzHzXUmQG0Dp+qyvCjLu62542pDz7ORIh4XQlmVjD7Ey0bN1IPtRIYPQgHXf+ldLmjrn1eEw=/body.htmlsource","blacklists_report_info":{"result":"success","domain":"demomailtrap.co","ip":"104.21.25.146","report":[{"name":"BACKSCATTERER","url":"http://www.backscatterer.org/index.php","in_black_list":false},{"name":"BARRACUDA","url":"http://barracudacentral.org/rbl","in_black_list":false},{"name":"Spamrbl + IMP-SPAM","url":"http://antispam.imp.ch/?lng=1","in_black_list":false},{"name":"Wormrbl + IMP-SPAM","url":"http://antispam.imp.ch/?lng=1","in_black_list":false},{"name":"LASHBACK","url":"http://blacklist.lashback.com/","in_black_list":false},{"name":"NIXSPAM","url":"https://www.heise.de/ix/NiX-Spam-DNSBL-and-blacklist-for-download-499637.html","in_black_list":false},{"name":"PSBL","url":"https://psbl.org/","in_black_list":false},{"name":"SORBS-SPAM","url":"http://www.sorbs.net/lookup.shtml","in_black_list":false},{"name":"SPAMCOP","url":"http://spamcop.net/bl.shtml","in_black_list":false},{"name":"TRUNCATE","url":"http://www.gbudb.com/truncate/index.jsp","in_black_list":false}]},"smtp_information":{"ok":false}}]' + recorded_at: Tue, 30 Dec 2025 23:19:15 GMT +recorded_with: VCR 6.2.0 diff --git a/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_list/with_parameters/when_last_id_includes_more_messages/maps_response_data_to_SandboxMessage_objects.yml b/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_list/with_parameters/when_last_id_includes_more_messages/maps_response_data_to_SandboxMessage_objects.yml new file mode 100644 index 0000000..dfb0c38 --- /dev/null +++ b/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_list/with_parameters/when_last_id_includes_more_messages/maps_response_data_to_SandboxMessage_objects.yml @@ -0,0 +1,87 @@ +--- +http_interactions: +- request: + method: get + uri: https://mailtrap.io/api/accounts/1111111/inboxes/4288340/messages?last_id=5273671999&search=alex.d + 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 + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Date: + - Tue, 30 Dec 2025 23:19:15 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Server: + - cloudflare + Vary: + - Accept + - Accept-Encoding + 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 + X-Mailtrap-Version: + - v2 + X-Ratelimit-Limit: + - '150' + X-Ratelimit-Remaining: + - '147' + Etag: + - W/"910193a80c4774d1d1d5d8706b39d11c" + Cache-Control: + - max-age=0, private, must-revalidate + X-Request-Id: + - 91616e6d-971e-4d91-b59e-45c53a2fb300 + X-Runtime: + - '0.024907' + X-Cloud-Trace-Context: + - 4b5e08255a284107c564af75dbc8def1;o=0 + Strict-Transport-Security: + - max-age=0 + Cf-Cache-Status: + - DYNAMIC + Cf-Ray: + - 9b8e75b34cda1ce4-FRA + Alt-Svc: + - h3=":443"; ma=86400 + body: + encoding: ASCII-8BIT + string: '[{"id":5273671945,"inbox_id":4288340,"subject":"Hello from Mailtrap","sent_at":"2026-01-04T11:17:56.575-12:00","from_email":"reply@demomailtrap.co","from_name":"","to_email":"alex.d@railsware.com","to_name":"","email_size":677,"is_read":false,"created_at":"2026-01-04T11:17:56.579-12:00","updated_at":"2026-01-04T11:17:56.797-12:00","template_id":0,"template_variables":null,"html_body_size":29,"text_body_size":20,"human_size":"677 + Bytes","html_path":"/api/testing_message_parts/QEVuQwFAEAD6SO5PqWHlAWWad6MRonhtsuZxmCo4xzuFGE0LxKt6KDddCoGCmfx8kJdAWyxONzRlvqhB5mnkHxhicF6lbIh6dxpbBW8fNKU4wFjIE2F2d6+IvRnXDgBVNvWDZ+PIEjg=/body.html","txt_path":"/api/testing_message_parts/QEVuQwFAEAD6SO5PqWHlAWWad6MRonhtsuZxmCo4xzuFGE0LxKt6KDddCoGCmfx8kJdAWyxONzRlvqhB5mnkHxhicF6lbIh6dxpbBW8fNKU4wFjIE2F2d6+IvRnXDgBVNvWDZ+PIEjg=/body.txt","raw_path":"/api/testing_message_parts/QEVuQwFAEAD6SO5PqWHlAWWad6MRonhtsuZxmCo4xzuFGE0LxKt6KDddCoGCmfx8kJdAWyxONzRlvqhB5mnkHxhicF6lbIh6dxpbBW8fNKU4wFjIE2F2d6+IvRnXDgBVNvWDZ+PIEjg=/body.raw","download_path":"/api/testing_message_parts/QEVuQwFAEAD6SO5PqWHlAWWad6MRonhtsuZxmCo4xzuFGE0LxKt6KDddCoGCmfx8kJdAWyxONzRlvqhB5mnkHxhicF6lbIh6dxpbBW8fNKU4wFjIE2F2d6+IvRnXDgBVNvWDZ+PIEjg=/body.eml","html_source_path":"/api/testing_message_parts/QEVuQwFAEAD6SO5PqWHlAWWad6MRonhtsuZxmCo4xzuFGE0LxKt6KDddCoGCmfx8kJdAWyxONzRlvqhB5mnkHxhicF6lbIh6dxpbBW8fNKU4wFjIE2F2d6+IvRnXDgBVNvWDZ+PIEjg=/body.htmlsource","blacklists_report_info":{"result":"success","domain":"demomailtrap.co","ip":"104.21.25.146","report":[{"name":"BACKSCATTERER","url":"http://www.backscatterer.org/index.php","in_black_list":false},{"name":"BARRACUDA","url":"http://barracudacentral.org/rbl","in_black_list":false},{"name":"Spamrbl + IMP-SPAM","url":"http://antispam.imp.ch/?lng=1","in_black_list":false},{"name":"Wormrbl + IMP-SPAM","url":"http://antispam.imp.ch/?lng=1","in_black_list":false},{"name":"LASHBACK","url":"http://blacklist.lashback.com/","in_black_list":false},{"name":"NIXSPAM","url":"https://www.heise.de/ix/NiX-Spam-DNSBL-and-blacklist-for-download-499637.html","in_black_list":false},{"name":"PSBL","url":"https://psbl.org/","in_black_list":false},{"name":"SORBS-SPAM","url":"http://www.sorbs.net/lookup.shtml","in_black_list":false},{"name":"SPAMCOP","url":"http://spamcop.net/bl.shtml","in_black_list":false},{"name":"TRUNCATE","url":"http://www.gbudb.com/truncate/index.jsp","in_black_list":false}]},"smtp_information":{"ok":false}},{"id":5273671571,"inbox_id":4288340,"subject":"Hello + from Mailtrap","sent_at":"2026-01-04T11:17:40.025-12:00","from_email":"reply@demomailtrap.co","from_name":"","to_email":"alex.d@railsware.com","to_name":"","email_size":677,"is_read":false,"created_at":"2026-01-04T11:17:40.029-12:00","updated_at":"2026-01-04T11:17:40.208-12:00","template_id":0,"template_variables":null,"html_body_size":29,"text_body_size":20,"human_size":"677 + Bytes","html_path":"/api/testing_message_parts/QEVuQwFAEAAwMccBahxwpCSHvGNpOmK54J4cObh1DdN9Wixmdbc%2FzsVUvM0ac986GgLvzHzXUmQG0Dp+qyvCjLu62542pDz7ORIh4XQlmVjD7Ey0bN1IPtRIYPQgHXf+ldLmjrn1eEw=/body.html","txt_path":"/api/testing_message_parts/QEVuQwFAEAAwMccBahxwpCSHvGNpOmK54J4cObh1DdN9Wixmdbc%2FzsVUvM0ac986GgLvzHzXUmQG0Dp+qyvCjLu62542pDz7ORIh4XQlmVjD7Ey0bN1IPtRIYPQgHXf+ldLmjrn1eEw=/body.txt","raw_path":"/api/testing_message_parts/QEVuQwFAEAAwMccBahxwpCSHvGNpOmK54J4cObh1DdN9Wixmdbc%2FzsVUvM0ac986GgLvzHzXUmQG0Dp+qyvCjLu62542pDz7ORIh4XQlmVjD7Ey0bN1IPtRIYPQgHXf+ldLmjrn1eEw=/body.raw","download_path":"/api/testing_message_parts/QEVuQwFAEAAwMccBahxwpCSHvGNpOmK54J4cObh1DdN9Wixmdbc%2FzsVUvM0ac986GgLvzHzXUmQG0Dp+qyvCjLu62542pDz7ORIh4XQlmVjD7Ey0bN1IPtRIYPQgHXf+ldLmjrn1eEw=/body.eml","html_source_path":"/api/testing_message_parts/QEVuQwFAEAAwMccBahxwpCSHvGNpOmK54J4cObh1DdN9Wixmdbc%2FzsVUvM0ac986GgLvzHzXUmQG0Dp+qyvCjLu62542pDz7ORIh4XQlmVjD7Ey0bN1IPtRIYPQgHXf+ldLmjrn1eEw=/body.htmlsource","blacklists_report_info":{"result":"success","domain":"demomailtrap.co","ip":"104.21.25.146","report":[{"name":"BACKSCATTERER","url":"http://www.backscatterer.org/index.php","in_black_list":false},{"name":"BARRACUDA","url":"http://barracudacentral.org/rbl","in_black_list":false},{"name":"Spamrbl + IMP-SPAM","url":"http://antispam.imp.ch/?lng=1","in_black_list":false},{"name":"Wormrbl + IMP-SPAM","url":"http://antispam.imp.ch/?lng=1","in_black_list":false},{"name":"LASHBACK","url":"http://blacklist.lashback.com/","in_black_list":false},{"name":"NIXSPAM","url":"https://www.heise.de/ix/NiX-Spam-DNSBL-and-blacklist-for-download-499637.html","in_black_list":false},{"name":"PSBL","url":"https://psbl.org/","in_black_list":false},{"name":"SORBS-SPAM","url":"http://www.sorbs.net/lookup.shtml","in_black_list":false},{"name":"SPAMCOP","url":"http://spamcop.net/bl.shtml","in_black_list":false},{"name":"TRUNCATE","url":"http://www.gbudb.com/truncate/index.jsp","in_black_list":false}]},"smtp_information":{"ok":false}}]' + recorded_at: Tue, 30 Dec 2025 23:19:15 GMT +recorded_with: VCR 6.2.0 diff --git a/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_update/maps_response_data_to_SandboxMessage_object.yml b/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_update/maps_response_data_to_SandboxMessage_object.yml new file mode 100644 index 0000000..4bf0115 --- /dev/null +++ b/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_update/maps_response_data_to_SandboxMessage_object.yml @@ -0,0 +1,83 @@ +--- +http_interactions: +- request: + method: patch + uri: https://mailtrap.io/api/accounts/1111111/inboxes/4288340/messages/5273448410 + body: + encoding: UTF-8 + string: '{"message":{"is_read":true}}' + 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 + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Date: + - Tue, 30 Dec 2025 23:10:51 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Server: + - cloudflare + Vary: + - Accept + - Accept-Encoding + 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 + X-Mailtrap-Version: + - v2 + X-Ratelimit-Limit: + - '150' + X-Ratelimit-Remaining: + - '149' + Etag: + - W/"b0c2be2795ed16c966127414d596d40a" + Cache-Control: + - max-age=0, private, must-revalidate + X-Request-Id: + - 2c841501-9945-46c1-905d-ca9d16e228c3 + X-Runtime: + - '0.021912' + X-Cloud-Trace-Context: + - 79d506ae3ff14f7d8f1973ddb28035b7;o=3 + Strict-Transport-Security: + - max-age=0 + Cf-Cache-Status: + - DYNAMIC + Cf-Ray: + - 9b8e695eed624d4f-FRA + Alt-Svc: + - h3=":443"; ma=86400 + body: + encoding: ASCII-8BIT + string: '{"id":5273448410,"inbox_id":4288340,"subject":"Hello from Mailtrap","sent_at":"2026-01-04T04:55:50.867-12:00","from_email":"reply@demomailtrap.co","from_name":"","to_email":"alex.b@railsware.com","to_name":"","email_size":691,"is_read":true,"created_at":"2026-01-04T04:55:50.871-12:00","updated_at":"2026-01-04T04:55:56.618-12:00","template_id":0,"template_variables":null,"html_body_size":29,"text_body_size":20,"human_size":"691 + Bytes","html_path":"/api/testing_message_parts/QEVuQwFAEABC6ODCerNYpR2yAx7xrEH6%2Ftn5yHfn6zIHYoQ9Ce0V5e9PB+Fy64WrVklr1BTc8WNmeft20TH7pytYbFWIzBx61dHgATF0KMjaFS1whA7iqWor%2FinVxeyLbZbskDsXojw=/body.html","txt_path":"/api/testing_message_parts/QEVuQwFAEABC6ODCerNYpR2yAx7xrEH6%2Ftn5yHfn6zIHYoQ9Ce0V5e9PB+Fy64WrVklr1BTc8WNmeft20TH7pytYbFWIzBx61dHgATF0KMjaFS1whA7iqWor%2FinVxeyLbZbskDsXojw=/body.txt","raw_path":"/api/testing_message_parts/QEVuQwFAEABC6ODCerNYpR2yAx7xrEH6%2Ftn5yHfn6zIHYoQ9Ce0V5e9PB+Fy64WrVklr1BTc8WNmeft20TH7pytYbFWIzBx61dHgATF0KMjaFS1whA7iqWor%2FinVxeyLbZbskDsXojw=/body.raw","download_path":"/api/testing_message_parts/QEVuQwFAEABC6ODCerNYpR2yAx7xrEH6%2Ftn5yHfn6zIHYoQ9Ce0V5e9PB+Fy64WrVklr1BTc8WNmeft20TH7pytYbFWIzBx61dHgATF0KMjaFS1whA7iqWor%2FinVxeyLbZbskDsXojw=/body.eml","html_source_path":"/api/testing_message_parts/QEVuQwFAEABC6ODCerNYpR2yAx7xrEH6%2Ftn5yHfn6zIHYoQ9Ce0V5e9PB+Fy64WrVklr1BTc8WNmeft20TH7pytYbFWIzBx61dHgATF0KMjaFS1whA7iqWor%2FinVxeyLbZbskDsXojw=/body.htmlsource","blacklists_report_info":{"result":"success","domain":"demomailtrap.co","ip":"172.67.134.80","report":[{"name":"BACKSCATTERER","url":"http://www.backscatterer.org/index.php","in_black_list":false},{"name":"BARRACUDA","url":"http://barracudacentral.org/rbl","in_black_list":false},{"name":"Spamrbl + IMP-SPAM","url":"http://antispam.imp.ch/?lng=1","in_black_list":false},{"name":"Wormrbl + IMP-SPAM","url":"http://antispam.imp.ch/?lng=1","in_black_list":false},{"name":"LASHBACK","url":"http://blacklist.lashback.com/","in_black_list":false},{"name":"NIXSPAM","url":"https://www.heise.de/ix/NiX-Spam-DNSBL-and-blacklist-for-download-499637.html","in_black_list":false},{"name":"PSBL","url":"https://psbl.org/","in_black_list":false},{"name":"SORBS-SPAM","url":"http://www.sorbs.net/lookup.shtml","in_black_list":false},{"name":"SPAMCOP","url":"http://spamcop.net/bl.shtml","in_black_list":false},{"name":"TRUNCATE","url":"http://www.gbudb.com/truncate/index.jsp","in_black_list":false}]},"smtp_information":{"ok":false}}' + recorded_at: Tue, 30 Dec 2025 23:10:51 GMT +recorded_with: VCR 6.2.0 diff --git a/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_update/when_SandboxMessage_does_not_exist/raises_not_found_error.yml b/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_update/when_SandboxMessage_does_not_exist/raises_not_found_error.yml new file mode 100644 index 0000000..fef34b0 --- /dev/null +++ b/spec/fixtures/vcr_cassettes/Mailtrap_SandboxMessagesAPI/_update/when_SandboxMessage_does_not_exist/raises_not_found_error.yml @@ -0,0 +1,77 @@ +--- +http_interactions: +- request: + method: patch + uri: https://mailtrap.io/api/accounts/1111111/inboxes/4288340/messages/999999 + body: + encoding: UTF-8 + string: '{"message":{"is_read":true}}' + 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 + Content-Type: + - application/json + response: + status: + code: 404 + message: Not Found + headers: + Date: + - Tue, 30 Dec 2025 23:10:51 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: + - c9d3fea7-e9e5-4582-ba6f-c3f6d4459b26 + X-Runtime: + - '0.043187' + X-Cloud-Trace-Context: + - 1e16d177ca1b43c284d879f367c32997;o=0 + Strict-Transport-Security: + - max-age=0 + Cf-Cache-Status: + - DYNAMIC + Cf-Ray: + - 9b8e69627cdb6e15-FRA + Alt-Svc: + - h3=":443"; ma=86400 + body: + encoding: ASCII-8BIT + string: '{"error":"Not Found"}' + recorded_at: Tue, 30 Dec 2025 23:10:51 GMT +recorded_with: VCR 6.2.0 diff --git a/spec/mailtrap/sandbox_message_spec.rb b/spec/mailtrap/sandbox_message_spec.rb new file mode 100644 index 0000000..6c816a5 --- /dev/null +++ b/spec/mailtrap/sandbox_message_spec.rb @@ -0,0 +1,126 @@ +# frozen_string_literal: true + +RSpec.describe Mailtrap::SandboxMessage do + subject(:sandbox_message) { described_class.new(attributes) } + + let(:attributes) do + { + id: 123_456, + inbox_id: 789_012, + subject: 'Test Subject', + sent_at: '2024-06-01T12:00:00Z', + from_email: 'example@mail.com', + from_name: 'Example Sender', + to_email: 'to@mail.com', + to_name: 'Example Recipient', + email_size: 2048, + is_read: false, + created_at: '2024-06-01T12:00:00Z', + updated_at: '2024-06-01T12:30:00Z', + html_body_size: 1024, + text_body_size: 512, + human_size: '2 KB', + html_path: 'path/to/html', + txt_path: 'path/to/txt', + raw_path: 'path/to/raw', + download_path: 'path/to/download', + html_source_path: 'path/to/html_source', + blacklists_report_info: true, + smtp_information: { + ok: true, + data: { + mail_from_addr: 'john@mailtrap.io', + client_ip: '193.62.62.184' + } + } + } + end + + describe '#initialize' do + it 'creates a sandbox_message with all attributes' do + expect(sandbox_message).to match_struct( + id: 123_456, + inbox_id: 789_012, + subject: 'Test Subject', + sent_at: '2024-06-01T12:00:00Z', + from_email: 'example@mail.com', + from_name: 'Example Sender', + to_email: 'to@mail.com', + to_name: 'Example Recipient', + email_size: 2048, + is_read: false, + created_at: '2024-06-01T12:00:00Z', + updated_at: '2024-06-01T12:30:00Z', + html_body_size: 1024, + text_body_size: 512, + human_size: '2 KB', + html_path: 'path/to/html', + txt_path: 'path/to/txt', + raw_path: 'path/to/raw', + download_path: 'path/to/download', + html_source_path: 'path/to/html_source', + blacklists_report_info: true, + smtp_information: { + ok: true, + data: { + mail_from_addr: 'john@mailtrap.io', + client_ip: '193.62.62.184' + } + } + ) + end + end + + describe '#to_h' do + subject(:hash) { sandbox_message.to_h } + + it 'returns a hash with all attributes' do + expect(hash).to eq( + id: 123_456, + inbox_id: 789_012, + subject: 'Test Subject', + sent_at: '2024-06-01T12:00:00Z', + from_email: 'example@mail.com', + from_name: 'Example Sender', + to_email: 'to@mail.com', + to_name: 'Example Recipient', + email_size: 2048, + is_read: false, + created_at: '2024-06-01T12:00:00Z', + updated_at: '2024-06-01T12:30:00Z', + html_body_size: 1024, + text_body_size: 512, + human_size: '2 KB', + html_path: 'path/to/html', + txt_path: 'path/to/txt', + raw_path: 'path/to/raw', + download_path: 'path/to/download', + html_source_path: 'path/to/html_source', + blacklists_report_info: true, + smtp_information: { + ok: true, + data: { + mail_from_addr: 'john@mailtrap.io', + client_ip: '193.62.62.184' + } + } + ) + end + + context 'when some attributes are nil' do + let(:sandbox_message) do + described_class.new( + id: 123_456, + inbox_id: 789_012 + ) + end + + it 'returns a hash with only non-nil attributes' do + expect(hash).to eq( + id: 123_456, + inbox_id: 789_012 + ) + end + end + end +end diff --git a/spec/mailtrap/sandbox_messages_api_spec.rb b/spec/mailtrap/sandbox_messages_api_spec.rb new file mode 100644 index 0000000..2c7c1aa --- /dev/null +++ b/spec/mailtrap/sandbox_messages_api_spec.rb @@ -0,0 +1,407 @@ +# frozen_string_literal: true + +RSpec.describe Mailtrap::SandboxMessagesAPI, :vcr do + subject(:sandbox_messages_api) { described_class.new(inbox_id, account_id, client) } + + let(:account_id) { ENV.fetch('MAILTRAP_ACCOUNT_ID', 1_111_111) } + let(:client) { Mailtrap::Client.new(api_key: ENV.fetch('MAILTRAP_API_KEY', 'local-api-key')) } + let(:inbox_id) { ENV.fetch('MAILTRAP_INBOX_ID', 4_288_340) } + + describe '#get' do + subject(:get) { sandbox_messages_api.get(sandbox_message_id) } + + let(:sandbox_message_id) { 5_273_448_410 } + + it 'maps response data to SandboxMessage object' do + expect(get).to be_a(Mailtrap::SandboxMessage) + + expect(get).to have_attributes( + id: 5_273_448_410, + inbox_id: 4_288_340, + subject: 'Hello from Mailtrap', + sent_at: '2026-01-04T04:55:50.867-12:00', + from_email: 'reply@demomailtrap.co', + from_name: '', + to_email: 'alex.b@railsware.com', + to_name: '', + email_size: 691, + is_read: true, + created_at: '2026-01-04T04:55:50.871-12:00', + updated_at: '2026-01-04T04:55:56.618-12:00', + html_body_size: 29, + text_body_size: 20, + human_size: '691 Bytes', + blacklists_report_info: { + result: 'success', + domain: 'demomailtrap.co', + ip: '172.67.134.80', + report: [ + { name: 'BACKSCATTERER', url: 'http://www.backscatterer.org/index.php', in_black_list: false }, + { name: 'BARRACUDA', url: 'http://barracudacentral.org/rbl', in_black_list: false }, + { name: 'Spamrbl IMP-SPAM', url: 'http://antispam.imp.ch/?lng=1', in_black_list: false }, + { name: 'Wormrbl IMP-SPAM', url: 'http://antispam.imp.ch/?lng=1', in_black_list: false }, + { name: 'LASHBACK', url: 'http://blacklist.lashback.com/', in_black_list: false }, + { name: 'NIXSPAM', url: 'https://www.heise.de/ix/NiX-Spam-DNSBL-and-blacklist-for-download-499637.html', + in_black_list: false }, + { name: 'PSBL', url: 'https://psbl.org/', in_black_list: false }, + { name: 'SORBS-SPAM', url: 'http://www.sorbs.net/lookup.shtml', in_black_list: false }, + { name: 'SPAMCOP', url: 'http://spamcop.net/bl.shtml', in_black_list: false }, + { name: 'TRUNCATE', url: 'http://www.gbudb.com/truncate/index.jsp', in_black_list: false } + ] + }, + smtp_information: { ok: false } + ) + end + + context 'when SandboxMessage does not exist' do + let(:sandbox_message_id) { 999_999 } + + it 'raises not found error' do + expect { get }.to raise_error do |error| + expect(error).to be_a(Mailtrap::Error) + expect(error.message).to include('Not Found') + expect(error.messages.any? { |msg| msg.include?('Not Found') }).to be true + end + end + end + end + + describe '#update' do + subject(:update) { sandbox_messages_api.update(sandbox_message_id, **request) } + + let(:sandbox_message_id) { 5_273_448_410 } + let(:request) do + { + is_read: true + } + end + + it 'maps response data to SandboxMessage object' do + expect(update).to be_a(Mailtrap::SandboxMessage) + expect(update).to have_attributes( + is_read: true + ) + end + + context 'when SandboxMessage does not exist' do + let(:sandbox_message_id) { 999_999 } + + it 'raises not found error' do + expect { update }.to raise_error do |error| + expect(error).to be_a(Mailtrap::Error) + expect(error.message).to include('Not Found') + expect(error.messages.any? { |msg| msg.include?('Not Found') }).to be true + end + end + end + end + + describe '#list' do + subject(:list) { sandbox_messages_api.list } + + it 'maps response data to SandboxMessage objects' do + expect(list).to all(be_a(Mailtrap::SandboxMessage)) + expect(list.size).to eq(5) + end + + context 'with parameters' do + subject(:list) { sandbox_messages_api.list(search: 'alex.d', last_id:) } + + let(:last_id) { 5_273_671_943 } + + it 'maps response data to SandboxMessage objects' do + expect(list).to all(be_a(Mailtrap::SandboxMessage)) + expect(list.size).to eq(1) + end + + context 'when last_id includes more messages' do + let(:last_id) { 5_273_671_999 } + + it 'maps response data to SandboxMessage objects' do + expect(list).to all(be_a(Mailtrap::SandboxMessage)) + expect(list.size).to eq(2) + end + end + end + + context 'when api key is incorrect' do + let(:client) { Mailtrap::Client.new(api_key: 'incorrect-api-key') } + + it 'raises authorization error' do + expect { list }.to raise_error do |error| + expect(error).to be_a(Mailtrap::AuthorizationError) + expect(error.message).to include('Incorrect API token') + expect(error.messages.any? { |msg| msg.include?('Incorrect API token') }).to be true + end + end + end + end + + describe '#forward_message' do + subject(:forward_message) do + sandbox_messages_api.forward_message(sandbox_message_id, 'example@railsware.com') + end + + let(:sandbox_message_id) { 5_273_448_410 } + + it 'returns success' do + expect(forward_message).to eq({ message: 'Your email message has been successfully forwarded', + success: true }) + end + + context 'when sandbox message does not exist' do + let(:sandbox_message_id) { -1 } + + it 'raises not found error' do + expect { forward_message }.to raise_error do |error| + expect(error).to be_a(Mailtrap::Error) + expect(error.message).to include('Not Found') + expect(error.messages.any? { |msg| msg.include?('Not Found') }).to be true + end + end + end + end + + describe '#get_spam_score' do + subject(:get_spam_score) do + sandbox_messages_api.get_spam_score(sandbox_message_id) + end + + let(:sandbox_message_id) { 5_273_448_410 } + + it 'returns report' do + expect(get_spam_score).to eq( + { report: + { ResponseCode: 0, + ResponseMessage: 'EX_OK', + ResponseVersion: '1.1', + Score: 0.1, + Spam: false, + Threshold: 5.0, + Details: [ + { Pts: '0.1', RuleName: 'MISSING_MID', Description: 'Missing Message-Id: header' }, + { Pts: '0.0', RuleName: 'HTML_MESSAGE', Description: 'BODY: HTML included in message' } + ] } } + ) + end + + context 'when sandbox message does not exist' do + let(:sandbox_message_id) { -1 } + + it 'raises not found error' do + expect { get_spam_score }.to raise_error do |error| + expect(error).to be_a(Mailtrap::Error) + expect(error.message).to include('Not Found') + expect(error.messages.any? { |msg| msg.include?('Not Found') }).to be true + end + end + end + end + + describe '#get_html_analysis' do + subject(:get_html_analysis) do + sandbox_messages_api.get_html_analysis(sandbox_message_id) + end + + let(:sandbox_message_id) { 5_273_448_410 } + + it 'returns html analysis' do + expect(get_html_analysis).to eq({ report: { status: 'success', errors: [] } }) + end + + context 'when sandbox message does not exist' do + let(:sandbox_message_id) { -1 } + + it 'raises not found error' do + expect { get_html_analysis }.to raise_error do |error| + expect(error).to be_a(Mailtrap::Error) + expect(error.message).to include('Not Found') + expect(error.messages.any? { |msg| msg.include?('Not Found') }).to be true + end + end + end + end + + describe '#get_text_message' do + subject(:get_text_message) do + sandbox_messages_api.get_text_message(sandbox_message_id) + end + + let(:sandbox_message_id) { 5_273_448_410 } + + it 'returns text message' do + expect(get_text_message).to eq('Welcome to Mailtrap!') + end + + context 'when sandbox message does not exist' do + let(:sandbox_message_id) { -1 } + + it 'raises not found error' do + expect { get_text_message }.to raise_error do |error| + expect(error).to be_a(Mailtrap::Error) + expect(error.message).to include('Not Found') + expect(error.messages.any? { |msg| msg.include?('Not Found') }).to be true + end + end + end + end + + describe '#get_raw_message' do + subject(:get_raw_message) do + sandbox_messages_api.get_raw_message(sandbox_message_id) + end + + let(:sandbox_message_id) { 5_273_448_410 } + + it 'returns raw message' do + expect(get_raw_message).to include('Welcome to Mailtrap!') + expect(get_raw_message).to include('MIME-Version: 1.0') + expect(get_raw_message).to include('Subject: Hello from Mailtrap') + end + + context 'when sandbox message does not exist' do + let(:sandbox_message_id) { -1 } + + it 'raises not found error' do + expect { get_raw_message }.to raise_error do |error| + expect(error).to be_a(Mailtrap::Error) + expect(error.message).to include('Not Found') + expect(error.messages.any? { |msg| msg.include?('Not Found') }).to be true + end + end + end + end + + describe '#get_html_source' do + subject(:get_html_source) do + sandbox_messages_api.get_html_source(sandbox_message_id) + end + + let(:sandbox_message_id) { 5_273_448_410 } + + it 'returns html source message' do + expect(get_html_source).to eq('

Welcome to Mailtrap!

') + end + + context 'when sandbox message does not exist' do + let(:sandbox_message_id) { -1 } + + it 'raises not found error' do + expect { get_html_source }.to raise_error do |error| + expect(error).to be_a(Mailtrap::Error) + expect(error.message).to include('Not Found') + expect(error.messages.any? { |msg| msg.include?('Not Found') }).to be true + end + end + end + end + + describe '#get_html_message' do + subject(:get_html_message) do + sandbox_messages_api.get_html_message(sandbox_message_id) + end + + let(:sandbox_message_id) { 5_273_448_410 } + + it 'returns html message' do + expect(get_html_message).to eq('

Welcome to Mailtrap!

') + end + + context 'when sandbox message does not exist' do + let(:sandbox_message_id) { -1 } + + it 'raises not found error' do + expect { get_html_message }.to raise_error do |error| + expect(error).to be_a(Mailtrap::Error) + expect(error.message).to include('Not Found') + expect(error.messages.any? { |msg| msg.include?('Not Found') }).to be true + end + end + end + end + + describe '#get_message_as_eml' do + subject(:get_message_as_eml) do + sandbox_messages_api.get_message_as_eml(sandbox_message_id) + end + + let(:sandbox_message_id) { 5_273_448_410 } + + it 'returns html message' do + expect(get_message_as_eml).to include('Welcome to Mailtrap!') + expect(get_message_as_eml).to include('MIME-Version: 1.0') + expect(get_message_as_eml).to include('Subject: Hello from Mailtrap') + end + + context 'when sandbox message does not exist' do + let(:sandbox_message_id) { -1 } + + it 'raises not found error' do + expect { get_message_as_eml }.to raise_error do |error| + expect(error).to be_a(Mailtrap::Error) + expect(error.message).to include('Not Found') + expect(error.messages.any? { |msg| msg.include?('Not Found') }).to be true + end + end + end + end + + describe '#get_mail_headers' do + subject(:get_mail_headers) do + sandbox_messages_api.get_mail_headers(sandbox_message_id) + end + + let(:sandbox_message_id) { 5_273_448_410 } + + it 'returns headers' do + expect(get_mail_headers).to eq( + { + headers: + { + date: 'Tue, 30 Dec 2025 16:55:50 +0000', + from: 'reply@demomailtrap.co', + to: 'yahor.vaitsiakhouski@railsware.com', + subject: 'Hello from Mailtrap', + mime_version: '1.0', + content_type: 'multipart/alternative; boundary=123', + bcc: 'not available for your plan' + } + } + ) + end + + context 'when sandbox message does not exist' do + let(:sandbox_message_id) { -1 } + + it 'raises not found error' do + expect { get_mail_headers }.to raise_error do |error| + expect(error).to be_a(Mailtrap::Error) + expect(error.message).to include('Not Found') + expect(error.messages.any? { |msg| msg.include?('Not Found') }).to be true + end + end + end + end + + describe '#delete' do + subject(:delete) { sandbox_messages_api.delete(sandbox_message_id) } + + let(:sandbox_message_id) { 5_273_448_410 } + + it 'returns deleted project id' do + expect(delete[:id]).to eq(sandbox_message_id) + end + + context 'when project does not exist' do + let(:sandbox_message_id) { 999_999 } + + it 'raises not found error' do + expect { delete }.to raise_error do |error| + expect(error).to be_a(Mailtrap::Error) + expect(error.message).to include('Not Found') + expect(error.messages.any? { |msg| msg.include?('Not Found') }).to be true + end + end + end + end +end