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.5.24 lib/intercom/api_operations/find_all.rb
intercom-3.5.23 lib/intercom/api_operations/find_all.rb
intercom-3.5.22 lib/intercom/api_operations/find_all.rb
intercom-3.5.21 lib/intercom/api_operations/find_all.rb
intercom-3.5.20 lib/intercom/api_operations/find_all.rb
intercom-3.5.19 lib/intercom/api_operations/find_all.rb
intercom-3.5.17 lib/intercom/api_operations/find_all.rb
intercom-3.5.16 lib/intercom/api_operations/find_all.rb
intercom-3.5.15 lib/intercom/api_operations/find_all.rb
intercom-3.5.14 lib/intercom/api_operations/find_all.rb
intercom-3.5.12 lib/intercom/api_operations/find_all.rb
intercom-3.5.11 lib/intercom/api_operations/find_all.rb