Sha256: fafe5ade583571800677eb26d5ffdd5420a29585c276cffa9e903da94087843a

Contents?: true

Size: 869 Bytes

Versions: 8

Compression:

Stored size: 869 Bytes

Contents

# frozen_string_literal: true

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

        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, collection_class, details: finder_details, client: @client)
      end

      private

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

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
intercom-4.2.1 lib/intercom/api_operations/find_all.rb
intercom-4.2.0 lib/intercom/api_operations/find_all.rb
intercom-4.1.3 lib/intercom/api_operations/find_all.rb
intercom-4.1.2 lib/intercom/api_operations/find_all.rb
intercom-4.1.1 lib/intercom/api_operations/find_all.rb
intercom-4.1.0 lib/intercom/api_operations/find_all.rb
intercom-4.0.1 lib/intercom/api_operations/find_all.rb
intercom-4.0.0 lib/intercom/api_operations/find_all.rb