Sha256: 1aaadc1e1ef64df9ebb4dc24f1655206d2306f46ddb45a4f52a04d0653e673be

Contents?: true

Size: 662 Bytes

Versions: 9

Compression:

Stored size: 662 Bytes

Contents

module Intercom
  module ApiOperations
    module Find
      module ClassMethods
        def find(params)
          raise BadRequestError, "#{self}#find takes a hash as it's parameter but you supplied #{params.inspect}" unless params.is_a? Hash
          collection_name = Utils.resource_class_to_collection_name(self)
          if params[:id]
            response = Intercom.get("/#{collection_name}/#{params[:id]}", {})
          else
            response = Intercom.get("/#{collection_name}", params)
          end
          from_api(response)
        end
      end

      def self.included(base)
        base.extend(ClassMethods)
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
intercom-2.1.4 lib/intercom/api_operations/find.rb
intercom-2.1.3 lib/intercom/api_operations/find.rb
intercom-2.1.2 lib/intercom/api_operations/find.rb
intercom-2.1.1 lib/intercom/api_operations/find.rb
intercom-2.1.0 lib/intercom/api_operations/find.rb
intercom-2.0.3 lib/intercom/api_operations/find.rb
intercom-2.0.2 lib/intercom/api_operations/find.rb
intercom-2.0.1 lib/intercom/api_operations/find.rb
intercom-2.0.0 lib/intercom/api_operations/find.rb