From 0da4b1966221ac65115f8a20edb3b0b09cb4a6c1 Mon Sep 17 00:00:00 2001 From: Senthil Ramakrishnan Date: Tue, 8 Dec 2015 14:13:10 -0800 Subject: [PATCH 1/5] Updated docstring - Added Unique name --- twilio/rest/resources/ip_messaging/channels.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/twilio/rest/resources/ip_messaging/channels.py b/twilio/rest/resources/ip_messaging/channels.py index 8f84b2216d..b7e4f5529a 100644 --- a/twilio/rest/resources/ip_messaging/channels.py +++ b/twilio/rest/resources/ip_messaging/channels.py @@ -16,6 +16,7 @@ def update(self, **kwargs): :param sid: Channel instance identifier :param type: Channel type :param friendly_name: Channel's friendly name + :param unique_name: Channel's Unique name :param attributes: Additional attributes that needs to be stored with channel :return: the updated instance @@ -49,8 +50,9 @@ def create(self, **kwargs): """ Create a channel. - :param str friendly_name: The friendly name of the channel. - :param str attributes: An attribute string with arbitrary + :param str friendly_name: Channel's friendly name + :param unique_name: Channel's Unique name + :param str attributes: Developer-specific data (json) storage :return: A :class:`Channel` object """ @@ -68,6 +70,7 @@ def update(self, sid, **kwargs): :param sid: Channel instance identifier :param type: Channel type :param friendly_name: Channel's friendly name + :param unique_name: Channel's Unique name :param attributes: Additional attributes that needs to be stored with channel :return: Updated instance From 625bd8a6c1c9b987cdcb39765083466afe0ad0a8 Mon Sep 17 00:00:00 2001 From: Senthil Ramakrishnan Date: Tue, 8 Dec 2015 16:20:10 -0800 Subject: [PATCH 2/5] Tests for UniqueName parameter --- tests/ip_messaging/test_channels.py | 13 ++++++++++--- tests/resources/ip_messaging/channel_instance.json | 1 + 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/ip_messaging/test_channels.py b/tests/ip_messaging/test_channels.py index 9d23b8df3f..ce4fe83a1c 100644 --- a/tests/ip_messaging/test_channels.py +++ b/tests/ip_messaging/test_channels.py @@ -20,9 +20,10 @@ def test_create_channel(self, mock): mock.return_value = resp uri = "%s/Channels" % (BASE_URI) - list_resource.create(friendly_name='TestChannel') + list_resource.create(friendly_name='TestChannel', unique_name='Unique') exp_params = { - 'FriendlyName': "TestChannel" + 'FriendlyName': "TestChannel", + 'UniqueName': 'Unique' } mock.assert_called_with("POST", uri, data=exp_params, auth=AUTH, @@ -34,10 +35,16 @@ def test_get(self, mock): mock.return_value = resp uri = "%s/Channels/%s" % (BASE_URI, CHANNEL_SID) - list_resource.get(CHANNEL_SID) + channel_instance = list_resource.get(CHANNEL_SID) mock.assert_called_with("GET", uri, auth=AUTH, use_json_extension=False) + self.assertIsNotNone(channel_instance) + self.assertEquals('CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', channel_instance.sid) + self.assertEquals('ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', channel_instance.account_sid) + self.assertEquals('ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', channel_instance.service_sid) + self.assertEquals('update', channel_instance.friendly_name) + self.assertEquals('unique', channel_instance.unique_name) @patch("twilio.rest.resources.base.Resource.request") def test_delete(self, req): diff --git a/tests/resources/ip_messaging/channel_instance.json b/tests/resources/ip_messaging/channel_instance.json index d713a5111b..938a62013a 100644 --- a/tests/resources/ip_messaging/channel_instance.json +++ b/tests/resources/ip_messaging/channel_instance.json @@ -3,6 +3,7 @@ "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "friendly_name": "update", + "unique_name": "unique", "attributes": "", "date_created": "2015-08-20T09:30:24Z", "date_updated": "2015-08-20T09:30:24Z", From 72ec6a6a80212cb6f6020a2fec4c58cc2262fca5 Mon Sep 17 00:00:00 2001 From: Senthil Ramakrishnan Date: Tue, 8 Dec 2015 16:44:28 -0800 Subject: [PATCH 3/5] Added update message wrapper --- tests/ip_messaging/test_messages.py | 15 +++++++++++++ .../rest/resources/ip_messaging/messages.py | 22 +++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/tests/ip_messaging/test_messages.py b/tests/ip_messaging/test_messages.py index 62f9d450d4..49b5778225 100644 --- a/tests/ip_messaging/test_messages.py +++ b/tests/ip_messaging/test_messages.py @@ -39,6 +39,21 @@ def test_get(self, mock): mock.assert_called_with("GET", uri, auth=AUTH, use_json_extension=False) + @patch("twilio.rest.resources.base.make_twilio_request") + def test_update(self, mock): + resp = create_mock_json("tests/resources/ip_messaging/message_instance.json") + mock.return_value = resp + + update_params = { + 'UniqueName': 'unique' + } + + uri = "%s/Messages/%s" % (BASE_URI, MESSAGE_SID) + list_resource.update(MESSAGE_SID, unique_name='unique') + + mock.assert_called_with("POST", uri, data=update_params, auth=AUTH, + use_json_extension=False) + @patch("twilio.rest.resources.base.Resource.request") def test_delete(self, req): """ Deleting a call should work """ diff --git a/twilio/rest/resources/ip_messaging/messages.py b/twilio/rest/resources/ip_messaging/messages.py index 72452e130d..848ba16095 100644 --- a/twilio/rest/resources/ip_messaging/messages.py +++ b/twilio/rest/resources/ip_messaging/messages.py @@ -3,6 +3,17 @@ class Message(NextGenInstanceResource): + def update(self, **kwargs): + """ + Updates the Message instance + :param sid: Message instance identifier + :param service_sid: Service instance identifier + :param channel_sid: Channel instance identifier + :param body: Message's body + :return: the updated instance + """ + return self.update_instance(**kwargs) + def delete(self): """ Delete this message @@ -44,3 +55,14 @@ def delete(self, sid): Delete a given Message """ return self.delete_instance(sid) + + def update(self, sid, **kwargs): + """ + Updates the Message instance identified by sid + :param sid: Message instance identifier + :param service_sid: Service instance identifier + :param channel_sid: Channel instance identifier + :param body: Message's body + :return: the updated instance + """ + return self.update_instance(sid, kwargs) From 2e1bb1600e5e2718ea896f2ab8c6e4dcde571df6 Mon Sep 17 00:00:00 2001 From: Senthil Ramakrishnan Date: Tue, 8 Dec 2015 17:58:35 -0800 Subject: [PATCH 4/5] Fixing Travis build --- tests/ip_messaging/test_channels.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/tests/ip_messaging/test_channels.py b/tests/ip_messaging/test_channels.py index ce4fe83a1c..90720cdd3a 100644 --- a/tests/ip_messaging/test_channels.py +++ b/tests/ip_messaging/test_channels.py @@ -35,16 +35,10 @@ def test_get(self, mock): mock.return_value = resp uri = "%s/Channels/%s" % (BASE_URI, CHANNEL_SID) - channel_instance = list_resource.get(CHANNEL_SID) + list_resource.get(CHANNEL_SID) mock.assert_called_with("GET", uri, auth=AUTH, use_json_extension=False) - self.assertIsNotNone(channel_instance) - self.assertEquals('CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', channel_instance.sid) - self.assertEquals('ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', channel_instance.account_sid) - self.assertEquals('ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', channel_instance.service_sid) - self.assertEquals('update', channel_instance.friendly_name) - self.assertEquals('unique', channel_instance.unique_name) @patch("twilio.rest.resources.base.Resource.request") def test_delete(self, req): From 0c2323b06d80613e2b7036e167ee70f85f62d61b Mon Sep 17 00:00:00 2001 From: Senthil Ramakrishnan Date: Wed, 9 Dec 2015 11:04:07 -0800 Subject: [PATCH 5/5] Create users, should set identity not id. --- tests/ip_messaging/test_users.py | 2 +- twilio/rest/resources/ip_messaging/users.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/ip_messaging/test_users.py b/tests/ip_messaging/test_users.py index 5790134b10..7a92c15569 100644 --- a/tests/ip_messaging/test_users.py +++ b/tests/ip_messaging/test_users.py @@ -22,7 +22,7 @@ def test_create_user(self, mock): uri = "%s/Users" % (BASE_URI) list_resource.create('test_id') exp_params = { - 'Id': "test_id" + 'Identity': "test_id" } mock.assert_called_with("POST", uri, data=exp_params, auth=AUTH, diff --git a/twilio/rest/resources/ip_messaging/users.py b/twilio/rest/resources/ip_messaging/users.py index b37e6767e5..1439772cc0 100644 --- a/twilio/rest/resources/ip_messaging/users.py +++ b/twilio/rest/resources/ip_messaging/users.py @@ -35,16 +35,16 @@ def list(self, **kwargs): """ return self.get_instances(kwargs) - def create(self, id, **kwargs): + def create(self, identity, **kwargs): """ Creates a User - :param str id: The identity of the user. + :param str identity: The identity of the user. :param str role_sid: The role to assign the user. :return: A :class:`User` object """ - kwargs["id"] = id + kwargs["identity"] = identity return self.create_instance(kwargs) def delete(self, sid):