Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .coderabbit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
language: en
reviews:
path_instructions:
- path: "spec/fixtures/vcr_cassettes/**/*.yml"
instructions: |
Act as a data privacy officer. Carefully read all the vcr cassettes
with recorded HTTP interactions and try to identify sensitive data that
could potentially be recorded. It can be anything from PII to
credentials. Ignore obvious placeholder values.
1 change: 1 addition & 0 deletions lib/mailtrap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
require_relative 'mailtrap/suppressions_api'
require_relative 'mailtrap/projects_api'
require_relative 'mailtrap/inboxes_api'
require_relative 'mailtrap/sandbox_attachments_api'

module Mailtrap
# @!macro api_errors
Expand Down
39 changes: 39 additions & 0 deletions lib/mailtrap/sandbox_attachment.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# frozen_string_literal: true

module Mailtrap
# Data Transfer Object for SandboxAttachment
# @see https://docs.mailtrap.io/developers/email-sandbox/email-sandbox-api/attachments
# @attr_reader id [Integer] The project ID
# @attr_reader message_id [Integer] The message ID
# @attr_reader filename [String] The attachment filename
# @attr_reader attachment_type [String] The attachment type
# @attr_reader content_type [String] The attachment content type
# @attr_reader content_id [String] The attachment content ID
# @attr_reader transfer_encoding [String] The attachment transfer encoding
# @attr_reader attachment_size [Integer] The attachment size in bytes
# @attr_reader created_at [String] The attachment creation timestamp
# @attr_reader updated_at [String] The attachment update timestamp
# @attr_reader attachment_human_size [String] The attachment size in human-readable format
# @attr_reader download_path [String] The attachment download path
#
SandboxAttachment = Struct.new(
:id,
:message_id,
:filename,
:attachment_type,
:content_type,
:content_id,
:transfer_encoding,
:attachment_size,
:created_at,
:updated_at,
:attachment_human_size,
:download_path,
keyword_init: true
) do
# @return [Hash] The Project attributes as a hash
def to_h
super.compact
Comment on lines +4 to +36
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Fix docstrings that reference “project” instead of attachment.

The DTO docs mention “project” for id and to_h, which conflicts with the attachment model.

✏️ Suggested docstring correction
-  # `@attr_reader` id [Integer] The project ID
+  # `@attr_reader` id [Integer] The attachment ID
@@
-    # `@return` [Hash] The Project attributes as a hash
+    # `@return` [Hash] The attachment attributes as a hash
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# Data Transfer Object for SandboxAttachment
# @see https://docs.mailtrap.io/developers/email-sandbox/email-sandbox-api/attachments
# @attr_reader id [Integer] The project ID
# @attr_reader message_id [Integer] The message ID
# @attr_reader filename [String] The attachment filename
# @attr_reader attachment_type [String] The attachment type
# @attr_reader content_type [String] The attachment content type
# @attr_reader content_id [String] The attachment content ID
# @attr_reader transfer_encoding [String] The attachment transfer encoding
# @attr_reader attachment_size [Integer] The attachment size in bytes
# @attr_reader created_at [String] The attachment creation timestamp
# @attr_reader updated_at [String] The attachment update timestamp
# @attr_reader attachment_human_size [String] The attachment size in human-readable format
# @attr_reader download_path [String] The attachment download path
#
SandboxAttachment = Struct.new(
:id,
:message_id,
:filename,
:attachment_type,
:content_type,
:content_id,
:transfer_encoding,
:attachment_size,
:created_at,
:updated_at,
:attachment_human_size,
:download_path,
keyword_init: true
) do
# @return [Hash] The Project attributes as a hash
def to_h
super.compact
# Data Transfer Object for SandboxAttachment
# `@see` https://docs.mailtrap.io/developers/email-sandbox/email-sandbox-api/attachments
# `@attr_reader` id [Integer] The attachment ID
# `@attr_reader` message_id [Integer] The message ID
# `@attr_reader` filename [String] The attachment filename
# `@attr_reader` attachment_type [String] The attachment type
# `@attr_reader` content_type [String] The attachment content type
# `@attr_reader` content_id [String] The attachment content ID
# `@attr_reader` transfer_encoding [String] The attachment transfer encoding
# `@attr_reader` attachment_size [Integer] The attachment size in bytes
# `@attr_reader` created_at [String] The attachment creation timestamp
# `@attr_reader` updated_at [String] The attachment update timestamp
# `@attr_reader` attachment_human_size [String] The attachment size in human-readable format
# `@attr_reader` download_path [String] The attachment download path
#
SandboxAttachment = Struct.new(
:id,
:message_id,
:filename,
:attachment_type,
:content_type,
:content_id,
:transfer_encoding,
:attachment_size,
:created_at,
:updated_at,
:attachment_human_size,
:download_path,
keyword_init: true
) do
# `@return` [Hash] The attachment attributes as a hash
def to_h
super.compact
🤖 Prompt for AI Agents
In `@lib/mailtrap/sandbox_attachment.rb` around lines 4 - 36, The docstrings for
the SandboxAttachment Struct incorrectly refer to "project" (e.g. "@attr_reader
id [Integer] The project ID" and the "Project attributes" in the to_h comment);
update those descriptions to reference "attachment" instead (e.g. "The
attachment ID" and "The Attachment attributes as a hash") so they accurately
describe SandboxAttachment and its to_h method; locate the comments around the
SandboxAttachment definition and the to_h docstring and replace
"project"/"Project" with "attachment"/"Attachment".

end
end
end
41 changes: 41 additions & 0 deletions lib/mailtrap/sandbox_attachments_api.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# frozen_string_literal: true

require_relative 'base_api'
require_relative 'sandbox_attachment'

module Mailtrap
class SandboxAttachmentsAPI
include BaseAPI

self.response_class = SandboxAttachment

# Retrieves a specific sandbox attachment
# @param inbox_id [Integer] The inbox ID
# @param sandbox_message_id [Integer] The sandbox message ID
# @param sandbox_attachment_id [Integer] The sandbox attachment ID
# @return [SandboxAttachment] Sandbox attachment object
# @!macro api_errors
def get(inbox_id, sandbox_message_id, sandbox_attachment_id)
response = client.get(
"#{base_path}/inboxes/#{inbox_id}/messages/#{sandbox_message_id}/attachments/#{sandbox_attachment_id}"
)
handle_response(response)
end

# Lists all sandbox messages for the account, limited up to 30 at once
# @param inbox_id [Integer] The inbox ID
# @param sandbox_message_id [Integer] The sandbox message ID
# @return [Array<SandboxAttachment>] Array of sandbox message objects
# @!macro api_errors
def list(inbox_id, sandbox_message_id)
response = client.get("#{base_path}/inboxes/#{inbox_id}/messages/#{sandbox_message_id}/attachments")
response.map { |item| handle_response(item) }
Comment on lines +25 to +32
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Correct docstring to reference attachments (not messages).

Line 25 says “sandbox messages” but this method lists attachments.

✏️ Proposed fix
-    # Lists all sandbox messages for the account, limited up to 30 at once
+    # Lists all sandbox attachments for the account, limited up to 30 at once
🤖 Prompt for AI Agents
In `@lib/mailtrap/sandbox_attachments_api.rb` around lines 25 - 32, The method
list(inbox_id, sandbox_message_id) has an incorrect summary saying it lists
"sandbox messages" — change the docstring to correctly state it lists sandbox
attachments (e.g., "Lists all sandbox attachments for the account, limited up to
30 at once"), and ensure any param/return commentary refers to attachments where
appropriate; update the comment above the list method in
lib/mailtrap/sandbox_attachments_api.rb so it accurately describes the behavior
of
client.get("#{base_path}/inboxes/#{inbox_id}/messages/#{sandbox_message_id}/attachments")
and the returned Array<SandboxAttachment] objects handled by handle_response.

end

private

def base_path
"/api/accounts/#{account_id}"
end
end
end

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading