@@ -25,7 +25,15 @@ def collection_class(self):
25
25
26
26
def resource_url (self , _id ):
27
27
"""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 )
29
37
30
38
def reply (self , ** reply_data ):
31
39
"""Reply to a message."""
@@ -52,12 +60,18 @@ def close(self, **reply_data):
52
60
def mark_read (self , _id ):
53
61
"""Mark a conversation as read."""
54
62
data = {'read' : True }
55
- response = self .client .put (self .resource_url (_id ), data )
63
+ response = self .client .put (self .reply_url (_id ), data )
56
64
return self .collection_class ().from_response (response )
57
65
58
66
def __reply (self , reply_data ):
59
67
"""Send requests to the resource handler."""
60
68
_id = reply_data .pop ('id' )
61
69
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 )
63
77
return self .collection_class ().from_response (response )
0 commit comments