Sha256: f7c3b3a7f59b075926e259d248a0353511731b5f7cc113f7fb6593c9790fd196

Contents?: true

Size: 851 Bytes

Versions: 27

Compression:

Stored size: 851 Bytes

Contents

module Octobat
  module APIOperations
    module List
      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

      def set_parent_resource(filters)
        @parent_resource = {}
      end

      alias :all :list
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
octobat-2.0.27 lib/octobat/api_operations/list.rb
octobat-2.0.26 lib/octobat/api_operations/list.rb
octobat-2.0.25 lib/octobat/api_operations/list.rb
octobat-2.0.24 lib/octobat/api_operations/list.rb
octobat-2.0.23 lib/octobat/api_operations/list.rb
octobat-2.0.22 lib/octobat/api_operations/list.rb
octobat-2.0.21 lib/octobat/api_operations/list.rb
octobat-2.0.20 lib/octobat/api_operations/list.rb
octobat-2.0.19 lib/octobat/api_operations/list.rb
octobat-2.0.18 lib/octobat/api_operations/list.rb
octobat-2.0.17 lib/octobat/api_operations/list.rb
octobat-2.0.16 lib/octobat/api_operations/list.rb
octobat-2.0.15 lib/octobat/api_operations/list.rb
octobat-2.0.14 lib/octobat/api_operations/list.rb
octobat-2.0.12 lib/octobat/api_operations/list.rb
octobat-2.0.11 lib/octobat/api_operations/list.rb
octobat-2.0.10 lib/octobat/api_operations/list.rb
octobat-2.0.9 lib/octobat/api_operations/list.rb
octobat-2.0.8 lib/octobat/api_operations/list.rb
octobat-2.0.7 lib/octobat/api_operations/list.rb