Module: EmailFuse::Emails::Attachments

Defined in:
lib/email_fuse/emails/attachments.rb

Overview

Module for sent email attachments API operations

Class Method Summary collapse

Class Method Details

.get(params = {}) ⇒ Hash

Retrieve a single attachment from a sent email

Examples:

EmailFuse::Emails::Attachments.get(
  id: "2a0c9ce0-3112-4728-976e-47ddcd16a318",
  email_id: "4ef9a417-02e9-4d39-ad75-9611e0fcc33c"
)

Parameters:

  • params (Hash) (defaults to: {})

    Parameters for retrieving the attachment

Options Hash (params):

  • :id (String)

    The attachment ID (required)

  • :email_id (String)

    The email ID (required)

Returns:

  • (Hash)

    The attachment object



20
21
22
23
24
25
26
# File 'lib/email_fuse/emails/attachments.rb', line 20

def get(params = {})
  attachment_id = params[:id]
  email_id = params[:email_id]

  path = "emails/#{email_id}/attachments/#{attachment_id}"
  EmailFuse::Request.new(path, {}, "get").perform
end

.list(params = {}) ⇒ Hash

List attachments from a sent email with optional pagination

Examples:

List all attachments

EmailFuse::Emails::Attachments.list(
  email_id: "4ef9a417-02e9-4d39-ad75-9611e0fcc33c"
)

List with custom limit

EmailFuse::Emails::Attachments.list(
  email_id: "4ef9a417-02e9-4d39-ad75-9611e0fcc33c",
  limit: 50
)

List with pagination

EmailFuse::Emails::Attachments.list(
  email_id: "4ef9a417-02e9-4d39-ad75-9611e0fcc33c",
  limit: 20,
  after: "attachment_id_123"
)

Parameters:

  • params (Hash) (defaults to: {})

    Parameters for listing attachments

Options Hash (params):

  • :email_id (String)

    The email ID (required)

  • :limit (Integer)

    Maximum number of attachments to return (1-100)

  • :after (String)

    Cursor for pagination (newer attachments)

  • :before (String)

    Cursor for pagination (older attachments)

Returns:

  • (Hash)

    List of attachments with pagination info



54
55
56
57
58
59
60
61
62
63
# File 'lib/email_fuse/emails/attachments.rb', line 54

def list(params = {})
  email_id = params[:email_id]
  base_path = "emails/#{email_id}/attachments"

  # Extract pagination parameters
  pagination_params = params.slice(:limit, :after, :before)

  path = EmailFuse::PaginationHelper.build_paginated_path(base_path, pagination_params)
  EmailFuse::Request.new(path, {}, "get").perform
end