Class: Mailgun::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/howitzer/mailgun/response.rb

Overview

A Mailgun::Response object is instantiated for each response generated by the Client request. The Response object supports deserialization of the JSON result.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Response


13
14
15
16
# File 'lib/howitzer/mailgun/response.rb', line 13

def initialize(response)
  @body = response.body
  @code = response.code
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body


10
11
12
# File 'lib/howitzer/mailgun/response.rb', line 10

def body
  @body
end

#codeObject

Returns the value of attribute code


11
12
13
# File 'lib/howitzer/mailgun/response.rb', line 11

def code
  @code
end

Instance Method Details

#to_hHash

Return response as Ruby Hash


22
23
24
25
26
# File 'lib/howitzer/mailgun/response.rb', line 22

def to_h
  JSON.parse(@body)
rescue Exception => e
  log.error Howitzer::ParseError, e.message
end