Sha256: 7ee2eaddd3ae0957d7dcf4e25d005ba0e71a2e1e443e3ce8ab445666d7fdf0cb

Contents?: true

Size: 911 Bytes

Versions: 1

Compression:

Stored size: 911 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
        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

1 entries across 1 versions & 1 rubygems

Version Path
intercom-3.5.10 lib/intercom/api_operations/find_all.rb