Skip to content

Commit 7d22a3f

Browse files
committed
Add ability to add customer to a conversation
1 parent 60b1413 commit 7d22a3f

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

intercom/service/conversation.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,15 @@ def collection_class(self):
2525

2626
def resource_url(self, _id):
2727
"""Return the URL for the specified resource in this collection."""
28-
return "/%s/%s/reply" % (self.collection, _id)
28+
return "/%s/%s/" % (self.collection, _id)
29+
30+
def reply_url(self, _id):
31+
"""URL for reply resources."""
32+
return '%sreply' % self.resource_url(_id)
33+
34+
def customers_url(self, _id):
35+
"""URL for customer resources"""
36+
return '%scustomers' % self.resource_url(_id)
2937

3038
def reply(self, **reply_data):
3139
"""Reply to a message."""
@@ -52,12 +60,18 @@ def close(self, **reply_data):
5260
def mark_read(self, _id):
5361
"""Mark a conversation as read."""
5462
data = {'read': True}
55-
response = self.client.put(self.resource_url(_id), data)
63+
response = self.client.put(self.reply_url(_id), data)
5664
return self.collection_class().from_response(response)
5765

5866
def __reply(self, reply_data):
5967
"""Send requests to the resource handler."""
6068
_id = reply_data.pop('id')
6169
reply_data['conversation_id'] = _id
62-
response = self.client.post(self.resource_url(_id), reply_data)
70+
response = self.client.post(self.reply_url(_id), reply_data)
71+
return self.collection_class().from_response(response)
72+
73+
def add_customer_to_conversation(self, data):
74+
"""Add a customer to a conversation."""
75+
_id = data.pop('id')
76+
response = self.client.post(self.customers_url(_id), data)
6377
return self.collection_class().from_response(response)

0 commit comments

Comments
 (0)