Class: Mailosaur::Previews

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(conn, handle_http_error) ⇒ Previews

Creates and initializes a new instance of the Previews class.

Parameters:

  • client

    connection.



7
8
9
10
# File 'lib/Mailosaur/previews.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/previews.rb', line 13

def conn
  @conn
end

Instance Method Details

#list_email_clientsPreviewEmailClientListResult

List all email clients that can be used to generate email previews.

Returns a list of available email clients.

Returns:

  • (PreviewEmailClientListResult)

    operation results.



22
23
24
25
26
27
# File 'lib/Mailosaur/previews.rb', line 22

def list_email_clients
  response = conn.get 'api/previews/clients'
  @handle_http_error.call(response) unless response.status == 200
  model = JSON.parse(response.body)
  Mailosaur::Models::PreviewEmailClientListResult.new(model)
end