8000 Added update message wrapper · zhangjingcat/twilio-python@72ec6a6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 72ec6a6

Browse files
committed
Added update message wrapper
1 parent 625bd8a commit 72ec6a6

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

tests/ip_messaging/test_messages.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,21 @@ def test_get(self, mock):
3939
mock.assert_called_with("GET", uri, auth=AUTH,
4040
use_json_extension=False)
4141

42+
@patch("twilio.rest.resources.base.make_twilio_request")
43+
def test_update(self, mock):
44+
resp = create_mock_json("tests/resources/ip_messaging/message_instance.json")
45+
mock.return_value = resp
46+
47+
update_params = {
48+
'UniqueName': 'unique'
49+
}
50+
51+
uri = "%s/Messages/%s" % (BASE_URI, MESSAGE_SID)
52+
list_resource.update(MESSAGE_SID, unique_name='unique')
53+
54+
mock.assert_called_with("POST", uri, data=update_params, auth=AUTH,
55+
use_json_extension=False)
56+
4257
@patch("twilio.rest.resources.base.Resource.request")
4358
def test_delete(self, req):
4459
""" Deleting a call should work """

twilio/rest/resources/ip_messaging/messages.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@
33

44
class Message(NextGenInstanceResource):
55

6+
def update(self, **kwargs):
7+
"""
8+
Updates the Message instance
9+
:param sid: Message instance identifier
10+
:param service_sid: Service instance identifier
11+
:param channel_sid: Channel instance identifier
12+
:param body: Message's body
13+
:return: the updated instance
14+
"""
15+
return self.update_instance(**kwargs)
16+
617
def delete(self):
718
"""
819
Delete this message
@@ -44,3 +55,14 @@ def delete(self, sid):
4455
Delete a given Message
4556
"""
4657
return self.delete_instance(sid)
58+
59+
def update(self, sid, **kwargs):
60+
"""
61+
Updates the Message instance identified by sid
62+
:param sid: Message instance identifier
63+
:param service_sid: Service instance identifier
64+
:param channel_sid: Channel instance identifier
65+
:param body: Message's body
66+
:return: the updated instance
67+
"""
68+
return self.update_instance(sid, kwargs)

0 commit comments

Comments
 (0)
0