Repository navigation
Expand file tree
/
Copy pathlead.py
More file actions
44 lines (35 loc) · 1.39 KB
/
Copy pathlead.py
File metadata and controls
44 lines (35 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# -*- coding: utf-8 -*- # noqa
from intercom import lead
from intercom.api_operations.all import All
from intercom.api_operations.convert import Convert
from intercom.api_operations.find import Find
from intercom.api_operations.find_all import FindAll
from intercom.api_operations.delete import Delete
from intercom.api_operations.save import Save
from intercom.api_operations.load import Load
from intercom.service.base_service import BaseService
class Lead(BaseService, All, Find, FindAll, Delete, Save, Load, Convert):
"""Leads are useful for representing logged-out users of your application.
Ref: https://developers.intercom.io/reference#leads
"""
@property
def collection(self):
"""Return the name of the collection."""
return utils.resource_class_to_collection_name(self.collection_class)
@property
def collection_class(self):
"""The collection class that represents this resource."""
return lead.Lead
def convert(self, _id, _email):
"""convert a lead to a user"""
service_url = "/contacts/convert/" #different service_url for conversion
data = {
'contact': {
'id' : _id,
},
'user': {
'email' : _email,
}
}
response = self.client.post(service_url, data)
return self.collection_class().from_response(response)