Sha256: d726d89f84e9fe33d8e419e07a74c1429e3795efee084f4e69b44b110a744964

Contents?: true

Size: 884 Bytes

Versions: 50

Compression:

Stored size: 884 Bytes

Contents

require 'intercom/traits/api_resource'

module Intercom
  module ApiOperations
    module Convert
      def convert(contact, user = false)
        if contact.class == Intercom::Visitor
          visitor = contact
          req = {
            visitor: { user_id: visitor.user_id },
          }
          if user
            req[:user] = identity_hash(user)
            req[:type] = 'user'
          else
            req[:type] = 'lead'
          end
          Intercom::User.new.from_response(
            @client.post(
              "/visitors/convert", req
            )
          )
        else
          Intercom::User.new.from_response(
            @client.post(
              "/contacts/convert", {
                contact: { user_id: contact.user_id },
                user: identity_hash(user)
              }
            )
          )
        end
      end
    end
  end
end

Version data entries

50 entries across 50 versions & 1 rubygems

Version Path
intercom-3.7.2 lib/intercom/api_operations/convert.rb
intercom-3.7.1 lib/intercom/api_operations/convert.rb
intercom-3.7.0 lib/intercom/api_operations/convert.rb
intercom-3.6.2 lib/intercom/api_operations/convert.rb
intercom-3.6.1 lib/intercom/api_operations/convert.rb
intercom-3.6.0 lib/intercom/api_operations/convert.rb
intercom-3.5.26 lib/intercom/api_operations/convert.rb
intercom-3.5.25 lib/intercom/api_operations/convert.rb
intercom-3.5.24 lib/intercom/api_operations/convert.rb
intercom-3.5.23 lib/intercom/api_operations/convert.rb
intercom-3.5.22 lib/intercom/api_operations/convert.rb
intercom-3.5.21 lib/intercom/api_operations/convert.rb
intercom-3.5.20 lib/intercom/api_operations/convert.rb
intercom-3.5.19 lib/intercom/api_operations/convert.rb
intercom-3.5.17 lib/intercom/api_operations/convert.rb
intercom-3.5.16 lib/intercom/api_operations/convert.rb
intercom-3.5.15 lib/intercom/api_operations/convert.rb
intercom-3.5.14 lib/intercom/api_operations/convert.rb
intercom-3.5.12 lib/intercom/api_operations/convert.rb
intercom-3.5.11 lib/intercom/api_operations/convert.rb