Skip to content

Commit 09a79dc

Browse files
authored
Merge pull request #194 from plivo/VT-3986
application create/update changes
2 parents f8f8236 + 3996ede commit 09a79dc

File tree

5 files changed

+33
-11
lines changed

5 files changed

+33
-11
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Change Log
22

3+
## [4.22.3](https://github.com/plivo/plivo-python/tree/v4.22.3) (2022-03-04)
4+
**Bug fix - Application API (create/update)**
5+
- For [create & update application API](https://www.plivo.com/docs/account/api/application#create-an-application) the parameter `answer url` is set to optional.
6+
- Failing to [update application](https://www.plivo.com/docs/account/api/application#update-an-application) because of `app_id`
7+
38
## [4.22.2](https://github.com/plivo/plivo-python/tree/v4.22.2) (2022-02-25)
49
**Feature - conference_recording**
510
- Add callback_url parameter to [Record Conference API](https://www.plivo.com/docs/voice/api/conference/record-conference#start-recording-a-conference)

plivo/resources/applications.py

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ class Applications(PlivoResourceInterface):
4545
_resource_type = Application
4646

4747
@validate_args(
48-
answer_url=[is_url()],
4948
app_name=[of_type(six.text_type)],
49+
answer_url=[optional(is_url())],
5050
answer_method=[optional(of_type(six.text_type))],
5151
hangup_url=[optional(is_url())],
5252
hangup_method=[optional(of_type(six.text_type))],
@@ -60,8 +60,8 @@ class Applications(PlivoResourceInterface):
6060
log_incoming_messages=[optional(of_type_exact(bool))],
6161
public_uri=[optional(of_type_exact(bool))])
6262
def create(self,
63-
answer_url,
6463
app_name,
64+
answer_url=None,
6565
answer_method='POST',
6666
hangup_url=None,
6767
hangup_method='POST',
@@ -110,8 +110,8 @@ def list(self, subaccount=None, limit=20, offset=0):
110110
objects_type=Application, is_voice_request=True)
111111

112112
@validate_args(
113-
answer_url=[is_url()],
114113
app_id=[of_type(six.text_type)],
114+
answer_url=[optional(is_url())],
115115
answer_method=[optional(of_type(six.text_type))],
116116
hangup_url=[optional(is_url())],
117117
hangup_method=[optional(of_type(six.text_type))],
@@ -126,7 +126,7 @@ def list(self, subaccount=None, limit=20, offset=0):
126126
public_uri=[optional(of_type_exact(bool))])
127127
def update(self,
128128
app_id,
129-
answer_url,
129+
answer_url=None,
130130
answer_method='POST',
131131
hangup_url=None,
132132
hangup_method='POST',
@@ -142,8 +142,28 @@ def update(self,
142142
if subaccount:
143143
if isinstance(subaccount, Subaccount):
144144
subaccount = subaccount.id
145+
146+
# using localVariablesObject insteadof locals() because we need to remove app_id
147+
# as there is no support to update app_id, there is no way to remove an variable from locals() dictionary
148+
localVariablesObject = {
149+
'self': self,
150+
'answer_url': answer_url,
151+
'answer_method': answer_method,
152+
'hangup_url' : hangup_url,
153+
'hangup_method' : hangup_method,
154+
'fallback_answer_url' : fallback_answer_url,
155+
'fallback_method' : fallback_method,
156+
'message_url' : message_url,
157+
'message_method' : message_method,
158+
'default_number_app' : default_number_app,
159+
'default_endpoint_app' : default_endpoint_app,
160+
'subaccount' : subaccount,
161+
'log_incoming_messages' : log_incoming_messages,
162+
'public_uri' : public_uri
163+
}
164+
145165
return self.client.request('POST', ('Application', app_id),
146-
to_param_dict(self.update, locals()), is_voice_request=True)
166+
to_param_dict(self.update, localVariablesObject), is_voice_request=True)
147167

148168
@validate_args(
149169
app_id=[of_type(six.text_type)],

plivo/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# -*- coding: utf-8 -*-
2-
__version__ = '4.22.2'
2+
__version__ = '4.22.3'
33

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
setup(
1212
name='plivo',
13-
version='4.22.2',
13+
version='4.22.3',
1414
description='A Python SDK to make voice calls & send SMS using Plivo and to generate Plivo XML',
1515
long_description=long_description,
1616
url='https://github.com/plivo/plivo-python',

tests/resources/test_applications.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ def test_application_create_invalid_params(self):
1010
with self.assertRaises(plivo.exceptions.ValidationError):
1111
self.client.applications.create(None, None)
1212

13-
with self.assertRaises(plivo.exceptions.ValidationError):
14-
self.client.applications.create('None', None)
15-
1613
with self.assertRaises(plivo.exceptions.ValidationError):
1714
self.client.applications.create(
1815
answer_url='None',
@@ -150,7 +147,7 @@ def test_application_update_invalid_params(self):
150147
self.client.applications.update(None, 'None', 'None')
151148

152149
with self.assertRaises(plivo.exceptions.ValidationError):
153-
self.client.applications.update('AppId', None, None, None, None,
150+
self.client.applications.update(None, None, None, None, None,
154151
None, None, None, None, None, None,
155152
None)
156153

0 commit comments

Comments
 (0)