Sha256: 3682a6b471dd12253dccc90ceb11ed086e3e7cf6d3d208557062b3f191bbe483

Contents?: true

Size: 912 Bytes

Versions: 32

Compression:

Stored size: 912 Bytes

Contents

require 'intercom/client_collection_proxy'
require 'intercom/utils'

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
        collection_proxy_class.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

32 entries across 32 versions & 1 rubygems

Version Path
intercom-3.9.5 lib/intercom/api_operations/find_all.rb
intercom-3.9.4 lib/intercom/api_operations/find_all.rb
intercom-3.9.3 lib/intercom/api_operations/find_all.rb
intercom-3.9.2 lib/intercom/api_operations/find_all.rb
intercom-3.9.0 lib/intercom/api_operations/find_all.rb
intercom-3.8.1 lib/intercom/api_operations/find_all.rb
intercom-3.8.0 lib/intercom/api_operations/find_all.rb
intercom-3.7.7 lib/intercom/api_operations/find_all.rb
intercom-3.7.6 lib/intercom/api_operations/find_all.rb
intercom-3.7.5 lib/intercom/api_operations/find_all.rb
intercom-3.7.4 lib/intercom/api_operations/find_all.rb
intercom-3.7.3 lib/intercom/api_operations/find_all.rb
intercom-3.7.2 lib/intercom/api_operations/find_all.rb
intercom-3.7.1 lib/intercom/api_operations/find_all.rb
intercom-3.7.0 lib/intercom/api_operations/find_all.rb
intercom-3.6.2 lib/intercom/api_operations/find_all.rb
intercom-3.6.1 lib/intercom/api_operations/find_all.rb
intercom-3.6.0 lib/intercom/api_operations/find_all.rb
intercom-3.5.26 lib/intercom/api_operations/find_all.rb
intercom-3.5.25 lib/intercom/api_operations/find_all.rb