Class: Orchestrate::API::CollectionResponse

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

Attributes inherited from Response

#body, #client, #headers, #request_id, #request_time, #status

Instance Method Summary collapse

Methods inherited from Response

#finished?, #on_complete, #success?

Constructor Details

#initialize(faraday_response, client) ⇒ CollectionResponse

Instantiate a new Respose

Parameters:

  • faraday_response (Faraday::Response)

    The Faraday response object.

  • client (Orchestrate::Client)

    The client used to generate the response.


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

#aggregatesArray (readonly)

Returns The aggregate items in the response.

Returns:

  • (Array)

    The aggregate items in the response.


113
114
115
# File 'lib/orchestrate/api/response.rb', line 113

def aggregates
  @aggregates
end

#countInteger (readonly)

Returns The number of items in this response.

Returns:

  • (Integer)

    The number of items in this response


104
105
106
# File 'lib/orchestrate/api/response.rb', line 104

def count
  @count
end

Returns The location for the next page of results.

Returns:

  • (String)

    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

Returns The location for the previous page of results.

Returns:

  • (String)

    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

#resultsArray (readonly)

Returns The items in the response.

Returns:

  • (Array)

    The items in the response.


110
111
112
# File 'lib/orchestrate/api/response.rb', line 110

def results
  @results
end

#total_countInteger? (readonly)

Returns If provided, the number of total items for this collection.

Returns:

  • (Integer, nil)

    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_resultsnil, 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_resultsnil, 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