Class: Hubscreen::Response

Inherits:
Object
  • Object
show all
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

Contact

Instance Attribute Summary collapse

Instance Method Summary collapse

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_hashObject

Returns the value of attribute raw_hash.



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

def raw_hash
  @raw_hash
end

#raw_responseObject

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

#contactObject

Type Cast Helpers



24
25
26
# File 'lib/hubscreen/response.rb', line 24

def contact
  Contact.new(self)
end

#pretty_responseObject

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