Sha256: c831d4de22560c7f3cc010497fcd2873080a3455c7a0437549dd7ba033dca65e

Contents?: true

Size: 886 Bytes

Versions: 20

Compression:

Stored size: 886 Bytes

Contents

require 'intercom/client_collection_proxy'

module Intercom
  module ApiOperations
    module FindAll

      def find_all(params)
        raise BadRequestError, "#find takes a hash as its parameter but you supplied #{params.inspect}" unless params.is_a? Hash
        collection_name = Utils.resource_class_to_collection_name(collection_class)
        finder_details = {}
        if params[:id] && !type_switched_finder?(params)
          finder_details[:url] = "/#{collection_name}/#{params[:id]}"
          finder_details[:params] = {}
        else
          finder_details[:url] = "/#{collection_name}"
          finder_details[:params] = params
        end
        ClientCollectionProxy.new(collection_name, finder_details: finder_details,  client: @client)
      end

      private

      def type_switched_finder?(params)
        params.include?(:type)
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
intercom-3.5.9 lib/intercom/api_operations/find_all.rb
intercom-3.5.8 lib/intercom/api_operations/find_all.rb
intercom-3.5.7 lib/intercom/api_operations/find_all.rb
intercom-3.5.6 lib/intercom/api_operations/find_all.rb
intercom-3.5.5 lib/intercom/api_operations/find_all.rb
intercom-3.5.4 lib/intercom/api_operations/find_all.rb
intercom-3.5.3 lib/intercom/api_operations/find_all.rb
intercom-3.5.2 lib/intercom/api_operations/find_all.rb
intercom-3.5.1 lib/intercom/api_operations/find_all.rb
intercom-3.4.0 lib/intercom/api_operations/find_all.rb
intercom-3.3.0 lib/intercom/api_operations/find_all.rb
intercom-3.2.0 lib/intercom/api_operations/find_all.rb
intercom-3.1.0 lib/intercom/api_operations/find_all.rb
intercom-3.0.6 lib/intercom/api_operations/find_all.rb
intercom-3.0.5 lib/intercom/api_operations/find_all.rb
intercom-3.0.4 lib/intercom/api_operations/find_all.rb
intercom-3.0.3 lib/intercom/api_operations/find_all.rb
intercom-3.0.2 lib/intercom/api_operations/find_all.rb
intercom-3.0.0 lib/intercom/api_operations/find_all.rb
intercom-3.0.0b1 lib/intercom/api_operations/find_all.rb