8000 Ip messaging updates by senthgit · Pull Request #241 · twilio/twilio-python · GitHub
[go: up one dir, main page]

Skip to content

Ip messaging updates #241

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Dec 9, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions tests/ip_messaging/test_channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
15 changes: 15 additions & 0 deletions tests/ip_messaging/test_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 """
Expand Down
2 changes: 1 addition & 1 deletion tests/ip_messaging/test_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions tests/resources/ip_messaging/channel_instance.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 5 additions & 2 deletions twilio/rest/resources/ip_messaging/channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
"""
Expand All @@ -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
Expand Down
22 changes: 22 additions & 0 deletions twilio/rest/resources/ip_messaging/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
6 changes: 3 additions & 3 deletions twilio/rest/resources/ip_messaging/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
0