Class: GraphResponse
- Inherits:
-
SDKComponent
- Object
- SDKComponent
- GraphResponse
- Defined in:
- lib/graph_response.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#error ⇒ Object
Returns the value of attribute error.
-
#paging ⇒ Object
Returns the value of attribute paging.
-
#request ⇒ Object
Returns the value of attribute request.
-
#response ⇒ Object
Returns the value of attribute response.
Instance Method Summary collapse
-
#initialize(response, request) ⇒ GraphResponse
constructor
A new instance of GraphResponse.
- #iterate(url) ⇒ Object
- #next ⇒ Object
- #previous ⇒ Object
Methods inherited from SDKComponent
Constructor Details
#initialize(response, request) ⇒ GraphResponse
Returns a new instance of GraphResponse.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/graph_response.rb', line 14 def initialize response, request @request = request @response = response if !response.is_a?(Hash) response = {"data" => response} end if response["data"].nil? @data = response else @data = response["data"] end if !response["error"].nil? @error = SDKException.new response["error"]["message"],response["error"]["code"],response["error"]["type"],request.effective_url end @paging = response["paging"] end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
10 11 12 |
# File 'lib/graph_response.rb', line 10 def data @data end |
#error ⇒ Object
Returns the value of attribute error.
11 12 13 |
# File 'lib/graph_response.rb', line 11 def error @error end |
#paging ⇒ Object
Returns the value of attribute paging.
12 13 14 |
# File 'lib/graph_response.rb', line 12 def paging @paging end |
#request ⇒ Object
Returns the value of attribute request.
8 9 10 |
# File 'lib/graph_response.rb', line 8 def request @request end |
#response ⇒ Object
Returns the value of attribute response.
9 10 11 |
# File 'lib/graph_response.rb', line 9 def response @response end |
Instance Method Details
#iterate(url) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/graph_response.rb', line 40 def iterate url if url url = URI(URI.encode url) params = Rack::Utils.parse_nested_query(url.query) GraphRequest.new(url.path, params).get_response end end |
#next ⇒ Object
32 33 34 |
# File 'lib/graph_response.rb', line 32 def next self.iterate @paging['next'] end |
#previous ⇒ Object
36 37 38 |
# File 'lib/graph_response.rb', line 36 def previous self.iterate @paging['previous'] end |