Class: Orchestrate::API::CollectionResponse
- Defined in:
- lib/orchestrate/api/response.rb
Overview
A generic response for a collection of entities (K/V, Refs, Events, Search)
Instance Attribute Summary collapse
-
#aggregates ⇒ Array
readonly
The aggregate items in the response.
-
#count ⇒ Integer
readonly
The number of items in this response.
-
#next_link ⇒ String
readonly
The location for the next page of results.
-
#prev_link ⇒ String
readonly
The location for the previous page of results.
-
#results ⇒ Array
readonly
The items in the response.
-
#total_count ⇒ Integer?
readonly
If provided, the number of total items for this collection.
Attributes inherited from Response
#body, #client, #headers, #request_id, #request_time, #status
Instance Method Summary collapse
-
#initialize(faraday_response, client) ⇒ CollectionResponse
constructor
Instantiate a new Respose.
-
#next_results ⇒ nil, Orchestrate::API::CollectionResponse
Retrieves the next page of results, if available.
-
#previous_results ⇒ nil, Orchestrate::API::CollectionResponse
Retrieves the previous page of results, if available.
Methods inherited from Response
#finished?, #on_complete, #success?
Constructor Details
#initialize(faraday_response, client) ⇒ CollectionResponse
Instantiate a new Respose
122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/orchestrate/api/response.rb', line 122 def initialize(faraday_response, client) super(faraday_response, client) @response.on_complete do @count = body['count'] @total_count = body['total_count'] @results = body['results'] @aggregates = body['aggregates'] @next_link = body['next'] @prev_link = body['prev'] end end |
Instance Attribute Details
#aggregates ⇒ Array (readonly)
Returns The aggregate items in the response.
113 114 115 |
# File 'lib/orchestrate/api/response.rb', line 113 def aggregates @aggregates end |
#count ⇒ Integer (readonly)
Returns The number of items in this response.
104 105 106 |
# File 'lib/orchestrate/api/response.rb', line 104 def count @count end |
#next_link ⇒ String (readonly)
Returns The location for the next page of results.
116 117 118 |
# File 'lib/orchestrate/api/response.rb', line 116 def next_link @next_link end |
#prev_link ⇒ String (readonly)
Returns The location for the previous page of results.
119 120 121 |
# File 'lib/orchestrate/api/response.rb', line 119 def prev_link @prev_link end |
#results ⇒ Array (readonly)
Returns The items in the response.
110 111 112 |
# File 'lib/orchestrate/api/response.rb', line 110 def results @results end |
#total_count ⇒ Integer? (readonly)
Returns If provided, the number of total items for this collection.
107 108 109 |
# File 'lib/orchestrate/api/response.rb', line 107 def total_count @total_count end |
Instance Method Details
#next_results ⇒ nil, Orchestrate::API::CollectionResponse
Retrieves the next page of results, if available
136 137 138 |
# File 'lib/orchestrate/api/response.rb', line 136 def next_results fire_request(next_link) end |
#previous_results ⇒ nil, Orchestrate::API::CollectionResponse
Retrieves the previous page of results, if available
142 143 144 |
# File 'lib/orchestrate/api/response.rb', line 142 def previous_results fire_request(prev_link) end |