Class: Mailosaur::Files

Inherits:
Object
  • Object
show all
Defined in:
lib/Mailosaur/files.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(conn, handle_http_error) ⇒ Files

Creates and initializes a new instance of the Files class.

Parameters:

  • client

    connection.



7
8
9
10
# File 'lib/Mailosaur/files.rb', line 7

def initialize(conn, handle_http_error)
  @conn = conn
  @handle_http_error = handle_http_error
end

Instance Attribute Details

#connConnection (readonly)

Returns the client connection.

Returns:

  • (Connection)

    the client connection.



13
14
15
# File 'lib/Mailosaur/files.rb', line 13

def conn
  @conn
end

Instance Method Details

#get_attachment(id) ⇒ NOT_IMPLEMENTED

Download an attachment

Downloads a single attachment. Simply supply the unique identifier for the required attachment.

Parameters:

  • id

    The identifier of the attachment to be downloaded.

Returns:

  • (NOT_IMPLEMENTED)

    operation results.



25
26
27
28
29
# File 'lib/Mailosaur/files.rb', line 25

def get_attachment(id)
  response = conn.get "api/files/attachments/#{id}"
  @handle_http_error.call(response) unless response.status == 200
  response.body
end

#get_email(id) ⇒ NOT_IMPLEMENTED

Download EML

Downloads an EML file representing the specified email. Simply supply the unique identifier for the required email.

Parameters:

  • id

    The identifier of the email to be downloaded.

Returns:

  • (NOT_IMPLEMENTED)

    operation results.



41
42
43
44
45
# File 'lib/Mailosaur/files.rb', line 41

def get_email(id)
  response = conn.get "api/files/email/#{id}"
  @handle_http_error.call(response) unless response.status == 200
  response.body
end

#get_preview(id) ⇒ NOT_IMPLEMENTED

Download an email preview

Downloads a screenshot of your email rendered in a real email client. Simply supply the unique identifier for the required preview.

Parameters:

  • id

    The identifier of the email preview to be downloaded.

Returns:

  • (NOT_IMPLEMENTED)

    operation results.



57
58
59
60
61
# File 'lib/Mailosaur/files.rb', line 57

def get_preview(id)
  response = conn.get "api/files/previews/#{id}"
  @handle_http_error.call(response) unless response.status == 200
  response.body
end