class Orchestrate::API::CollectionResponse

A generic response for a collection of entities (K/V, Refs, Events, Search)

Attributes

aggregates[R]

@return [Array] The aggregate items in the response.

count[R]

@return [Integer] The number of items in this response

results[R]

@return [Array] The items in the response.

total_count[R]

@return [Integer, nil] If provided, the number of total items for this collection

Public Class Methods

new(faraday_response, client) click to toggle source

(see Orchestrate::API::Response#initialize)

Calls superclass method Orchestrate::API::Response::new
# 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

Public Instance Methods

next_results() click to toggle source

Retrieves the next page of results, if available @return [nil, Orchestrate::API::CollectionResponse]

# File lib/orchestrate/api/response.rb, line 136
def next_results
  fire_request(next_link)
end
previous_results() click to toggle source

Retrieves the previous page of results, if available @return [nil, Orchestrate::API::CollectionResponse]

# File lib/orchestrate/api/response.rb, line 142
def previous_results
  fire_request(prev_link)
end

Private Instance Methods

fire_request(link) click to toggle source
# File lib/orchestrate/api/response.rb, line 147
def fire_request(link)
  return nil unless link
  uri = URI(link)
  params = WEBrick::HTTPUtils.parse_query(uri.query)
  path = uri.path.split("/")[2..-1]
  @client.send_request(:get, path, { query: params, response: self.class })
end