Class: Hubscreen::Response
- Inherits:
-
Object
- Object
- Hubscreen::Response
- Defined in:
- lib/hubscreen/response.rb
Overview
Hubscreen::Response
Parent Class for all Hubscreen response objects. Designed for direct access to the response either through the “raw_hash” which is the hash representation of the JSON response or the “raw_response” which is the OpenStruct representation
By default all APIRequests will return a Response object. To disable this, set Hubscreen.configure(encapsulate_response: false)
Direct Known Subclasses
Instance Attribute Summary collapse
-
#raw_hash ⇒ Object
Returns the value of attribute raw_hash.
-
#raw_response ⇒ Object
Returns the value of attribute raw_response.
Instance Method Summary collapse
-
#contact ⇒ Object
Type Cast Helpers.
-
#initialize(response_json_hash) ⇒ Response
constructor
A new instance of Response.
-
#pretty_response ⇒ Object
Prints out the raw response in formatted JSON.
Constructor Details
#initialize(response_json_hash) ⇒ Response
Returns a new instance of Response.
12 13 14 15 |
# File 'lib/hubscreen/response.rb', line 12 def initialize(response_json_hash) @raw_hash = response_json_hash @raw_response = RecursiveOpenStruct.new(response_json_hash) end |
Instance Attribute Details
#raw_hash ⇒ Object
Returns the value of attribute raw_hash.
10 11 12 |
# File 'lib/hubscreen/response.rb', line 10 def raw_hash @raw_hash end |
#raw_response ⇒ Object
Returns the value of attribute raw_response.
10 11 12 |
# File 'lib/hubscreen/response.rb', line 10 def raw_response @raw_response end |
Instance Method Details
#contact ⇒ Object
Type Cast Helpers
24 25 26 |
# File 'lib/hubscreen/response.rb', line 24 def contact Contact.new(self) end |
#pretty_response ⇒ Object
Prints out the raw response in formatted JSON. This method is primarily used to aid in debugging
19 20 21 |
# File 'lib/hubscreen/response.rb', line 19 def pretty_response JSON.pretty_generate(@raw_hash) end |