Class: Intercom::Service::Visitor

Inherits:
BaseService show all
Includes:
ApiOperations::Delete, ApiOperations::Find, ApiOperations::Load, ApiOperations::Save
Defined in:
lib/intercom/service/visitor.rb

Instance Attribute Summary

Attributes inherited from BaseService

#client

Instance Method Summary collapse

Methods included from ApiOperations::Delete

#delete

Methods included from ApiOperations::Save

#create, #identity_hash, #save

Methods included from ApiOperations::Find

#find

Methods included from ApiOperations::Load

#load

Methods inherited from BaseService

#collection_name, #collection_proxy_class, #from_api, #initialize

Constructor Details

This class inherits a constructor from Intercom::Service::BaseService

Instance Method Details

#collection_classObject



15
16
17
# File 'lib/intercom/service/visitor.rb', line 15

def collection_class
  Intercom::Visitor
end

#convert(visitor, contact = false) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/intercom/service/visitor.rb', line 19

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