lib/intercom/api_operations/find_all.rb in intercom-2.5.4 vs lib/intercom/api_operations/find_all.rb in intercom-3.0.0b1

- old
+ new

@@ -1,33 +1,28 @@ -require 'intercom/collection_proxy' +require 'intercom/client_collection_proxy' module Intercom module ApiOperations module FindAll - module ClassMethods - def find_all(params) - raise BadRequestError, "#{self}#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(self) - 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 - CollectionProxy.new(collection_name, finder_details) - end - private - - def type_switched_finder?(params) - params.include?(:type) + 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 - def self.included(base) - base.extend(ClassMethods) + private + + def type_switched_finder?(params) + params.include?(:type) end end end end