Sha256: ff0e1f3c9125a1f3f4dfbc61d859758e5266dfb054d46da6099a7809aef3d6ee

Contents?: true

Size: 761 Bytes

Versions: 8

Compression:

Stored size: 761 Bytes

Contents

module Intercom
  module ApiOperations
    module Find
      module ClassMethods
        def find(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)
          if params[:id]
            response = Intercom.get("/#{collection_name}/#{params[:id]}", {})
          else
            response = Intercom.get("/#{collection_name}", params)
          end
          raise Intercom::HttpError.new('Http Error - No response entity returned') unless response
          from_api(response)
        end
      end

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

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
cogniteev-intercom-2.5.4 lib/intercom/api_operations/find.rb
intercom-2.5.4 lib/intercom/api_operations/find.rb
intercom-2.4.4 lib/intercom/api_operations/find.rb
intercom-2.4.3 lib/intercom/api_operations/find.rb
intercom-2.4.2 lib/intercom/api_operations/find.rb
intercom-2.4.1 lib/intercom/api_operations/find.rb
intercom-2.4.0 lib/intercom/api_operations/find.rb
intercom-2.3.0 lib/intercom/api_operations/find.rb