Module: Octobat::APIOperations::List

Instance Method Summary collapse

Instance Method Details

#list(filters = {}, opts = {}) ⇒ Object Also known as: all



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/octobat/api_operations/list.rb', line 4

def list(filters={}, opts={})
  set_parent_resource(filters)
  api_key, headers = Util.parse_opts(opts)
  
  api_key ||= @api_key

  f = filters.select{|request_filter| !@parent_resource.has_key?(request_filter)}

  response, api_key = Octobat.request(:get, url, api_key, f, headers)
  obj = ListObject.construct_from(response, api_key)

  obj.filters = filters.dup
  obj.cursors[:ending_before] = obj.filters.delete(:ending_before)
  obj.cursors[:starting_after] = obj.filters.delete(:starting_after)

  obj.filters.delete(:expand)
  obj.parent_resource = @parent_resource

  obj
end

#set_parent_resource(filters) ⇒ Object



25
26
27
# File 'lib/octobat/api_operations/list.rb', line 25

def set_parent_resource(filters)
  @parent_resource = {}
end