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.6 lib/octobat/api_operations/list.rb
octobat-2.0.5 lib/octobat/api_operations/list.rb
octobat-2.0.4 lib/octobat/api_operations/list.rb
octobat-2.0.3 lib/octobat/api_operations/list.rb
octobat-2.0.2 lib/octobat/api_operations/list.rb
octobat-2.0.1 lib/octobat/api_operations/list.rb
octobat-2.0.0 lib/octobat/api_operations/list.rb