Sha256: d4ed9ae296c1b1f03e9ef5d383fa9dcad72867d9415561d52273f8edac5abfc9

Contents?: true

Size: 661 Bytes

Versions: 7

Compression:

Stored size: 661 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
          from_api(response)
        end
      end

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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
intercom-2.2.4 lib/intercom/api_operations/find.rb
intercom-2.2.3 lib/intercom/api_operations/find.rb
intercom-2.2.2 lib/intercom/api_operations/find.rb
intercom-2.2.1 lib/intercom/api_operations/find.rb
intercom-2.2.0 lib/intercom/api_operations/find.rb
intercom-2.1.6 lib/intercom/api_operations/find.rb
intercom-2.1.5 lib/intercom/api_operations/find.rb