Class: Intercom::Service::Contact

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

Instance Attribute Summary

Attributes inherited from BaseService

#client

Instance Method Summary collapse

Methods included from ApiOperations::Search

#search

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::List

#all

Methods included from ApiOperations::Load

#load

Methods inherited from BaseService

#collection_name, #from_api, #initialize

Constructor Details

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

Instance Method Details

#archive(contact) ⇒ Object



36
37
38
39
# File 'lib/intercom/service/contact.rb', line 36

def archive(contact)
  @client.post("/#{collection_name}/#{contact.id}/archive", {})
  contact
end

#collection_classObject



19
20
21
# File 'lib/intercom/service/contact.rb', line 19

def collection_class
  Intercom::Contact
end

#collection_proxy_classObject



23
24
25
# File 'lib/intercom/service/contact.rb', line 23

def collection_proxy_class
  Intercom::BaseCollectionProxy
end

#delete_archived_contact(id) ⇒ Object



46
47
48
# File 'lib/intercom/service/contact.rb', line 46

def delete_archived_contact(id)
  @client.delete("/#{collection_name}/#{id}", {})
end

#merge(lead, user) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/intercom/service/contact.rb', line 27

def merge(lead, user)
  raise_invalid_merge_error unless lead.role == 'lead' && user.role == 'user'

  response = @client.post('/contacts/merge', from: lead.id, into: user.id)
  raise Intercom::HttpError, 'Http Error - No response entity returned' unless response

  user.from_response(response)
end

#unarchive(contact) ⇒ Object



41
42
43
44
# File 'lib/intercom/service/contact.rb', line 41

def unarchive(contact)
  @client.post("/#{collection_name}/#{contact.id}/unarchive", {})
  contact
end