Class: Orchestrate::API::ResponseBody
- Inherits:
-
Object
- Object
- Orchestrate::API::ResponseBody
- Defined in:
- lib/orchestrate_api/response.rb
Overview
Decodes body from json into a hash; provides the original body content via the ‘content’ method.
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Error code from the orchestrate.io api.
-
#content ⇒ Object
readonly
Original response body from HTTParty.
-
#count ⇒ Object
readonly
Set for list, search, get_events, and get_graph results.
-
#message ⇒ Object
readonly
Error message from the orchestrate.io api.
-
#next ⇒ Object
readonly
Set for list results.
-
#results ⇒ Object
readonly
Set for all results.
-
#to_hash ⇒ Object
readonly
The json response body converted to a hash.
-
#total_count ⇒ Object
readonly
Set for search results.
Instance Method Summary collapse
-
#initialize(body) ⇒ ResponseBody
constructor
Initialize instance variables, based on response body contents.
- #result_keys ⇒ Object
Constructor Details
#initialize(body) ⇒ ResponseBody
Initialize instance variables, based on response body contents.
90 91 92 93 94 |
# File 'lib/orchestrate_api/response.rb', line 90 def initialize(body) @content = body @to_hash = body.blank? ? {} : ActiveSupport::JSON.decode(body) to_hash.each { |k,v| instance_variable_set "@#{k}", v } end |
Instance Attribute Details
#code ⇒ Object (readonly)
Error code from the orchestrate.io api.
87 88 89 |
# File 'lib/orchestrate_api/response.rb', line 87 def code @code end |
#content ⇒ Object (readonly)
Original response body from HTTParty.
66 67 68 |
# File 'lib/orchestrate_api/response.rb', line 66 def content @content end |
#count ⇒ Object (readonly)
Set for list, search, get_events, and get_graph results.
75 76 77 |
# File 'lib/orchestrate_api/response.rb', line 75 def count @count end |
#message ⇒ Object (readonly)
Error message from the orchestrate.io api.
84 85 86 |
# File 'lib/orchestrate_api/response.rb', line 84 def @message end |
#next ⇒ Object (readonly)
Set for list results.
81 82 83 |
# File 'lib/orchestrate_api/response.rb', line 81 def next @next end |
#results ⇒ Object (readonly)
Set for all results.
72 73 74 |
# File 'lib/orchestrate_api/response.rb', line 72 def results @results end |
#to_hash ⇒ Object (readonly)
The json response body converted to a hash.
69 70 71 |
# File 'lib/orchestrate_api/response.rb', line 69 def to_hash @to_hash end |
#total_count ⇒ Object (readonly)
Set for search results.
78 79 80 |
# File 'lib/orchestrate_api/response.rb', line 78 def total_count @total_count end |
Instance Method Details
#result_keys ⇒ Object
96 97 98 |
# File 'lib/orchestrate_api/response.rb', line 96 def result_keys results.map { |result| result['path']['key'] } if results end |