Class: Howitzer::MailgunApi::Response
- Inherits:
-
Object
- Object
- Howitzer::MailgunApi::Response
- Defined in:
- lib/howitzer/mailgun_api/response.rb
Overview
A MailgunApi::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
-
#body ⇒ Object
Returns the value of attribute body.
-
#code ⇒ Object
Returns the value of attribute code.
Instance Method Summary collapse
-
#initialize(response) ⇒ Response
constructor
A new instance of Response.
-
#to_h ⇒ Hash
Return a response as a Ruby Hash.
Constructor Details
#initialize(response) ⇒ Response
Returns a new instance of Response.
11 12 13 14 |
# File 'lib/howitzer/mailgun_api/response.rb', line 11 def initialize(response) @body = response.body @code = response.code end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
9 10 11 |
# File 'lib/howitzer/mailgun_api/response.rb', line 9 def body @body end |
#code ⇒ Object
Returns the value of attribute code.
9 10 11 |
# File 'lib/howitzer/mailgun_api/response.rb', line 9 def code @code end |
Instance Method Details
#to_h ⇒ Hash
Return a response as a Ruby Hash
20 21 22 23 24 |
# File 'lib/howitzer/mailgun_api/response.rb', line 20 def to_h JSON.parse(@body) rescue StandardError => e raise ParseError, e. end |