Class: Mailosaur::Analysis

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(conn, handle_http_error) ⇒ Analysis

Creates and initializes a new instance of the Analysis class.

Parameters:

  • conn

    client connection.



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

def conn
  @conn
end

Instance Method Details

#deliverability(email) ⇒ DeliverabilityReport

Perform a deliverability report

Perform deliverability test on the specified email

Parameters:

  • email

    The identifier of the email to be analyzed.

Returns:

  • (DeliverabilityReport)

    operation results.



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

def deliverability(email)
  response = conn.get "api/analysis/deliverability/#{email}"
  @handle_http_error.call(response) unless response.status == 200
  model = JSON.parse(response.body)
  Mailosaur::Models::DeliverabilityReport.new(model)
end

#spam(email) ⇒ SpamAnalysisResult

Perform a spam test

Perform spam testing on the specified email

Parameters:

  • email

    The identifier of the email to be analyzed.

Returns:

  • (SpamAnalysisResult)

    operation results.



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

def spam(email)
  response = conn.get "api/analysis/spam/#{email}"
  @handle_http_error.call(response) unless response.status == 200
  model = JSON.parse(response.body)
  Mailosaur::Models::SpamAnalysisResult.new(model)
end