Skip to content

Commit 66f63f7

Browse files
authored
DX-2471 Add priority to createCallRequest model (#63)
* DX-2471 Add `priority` field to `createCallRequest` and `createCallResponse` models Also added missing `machine_detection` field to `createCallResponse` model * Add test for createCall with `priority` field * bump version to `13.3.0` * Remove `machineDetection` from `createCallResponse` model
1 parent 77c5b73 commit 66f63f7

File tree

4 files changed

+61
-7
lines changed

4 files changed

+61
-7
lines changed

bandwidth/tests/test_api.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,45 @@ def test_failed_create_and_failed_get_call(self, voice_client):
287287
if get_response_body.id:
288288
assert type(get_response_body.id) is str
289289

290+
291+
def test_createCall_with_priority(self, voice_client):
292+
"""Create a successful voice api call with priority set
293+
294+
Args:
295+
voice_client: Contains the basic auth credentials needed to authenticate.
296+
297+
"""
298+
call_body = CreateCallRequest()
299+
call_body.mfrom = BW_NUMBER
300+
call_body.to = USER_NUMBER
301+
call_body.application_id = BW_VOICE_APPLICATION_ID
302+
call_body.answer_url = BASE_CALLBACK_URL + '/callbacks/answer'
303+
call_body.answer_method = CallbackMethodEnum.POST
304+
call_body.disconnect_url = BASE_CALLBACK_URL + '/callbacks/disconnect'
305+
call_body.disconnect_method = CallbackMethodEnum.GET
306+
call_body.priority = 1
307+
308+
create_response = voice_client.create_call(BW_ACCOUNT_ID, call_body)
309+
create_response_body = create_response.body
310+
311+
print(vars(create_response))
312+
313+
assert create_response.status_code == 201
314+
assert len(create_response_body.call_id) == 47 # assert request created and id matches expected length (47)
315+
assert create_response_body.account_id == BW_ACCOUNT_ID
316+
assert create_response_body.application_id == BW_VOICE_APPLICATION_ID
317+
assert create_response_body.to == USER_NUMBER
318+
assert create_response_body.mfrom == BW_NUMBER
319+
assert create_response_body.call_url == "https://voice.bandwidth.com/api/v2/accounts/" + \
320+
BW_ACCOUNT_ID + "/calls/" + create_response_body.call_id
321+
assert dateutil.parser.isoparse(str(create_response_body.start_time)) # assert that str(start_time) is datetime
322+
assert type(create_response_body.call_timeout) is float
323+
assert type(create_response_body.callback_timeout) is float
324+
assert create_response_body.answer_method == "POST"
325+
assert create_response_body.disconnect_method == "GET"
326+
assert create_response_body.priority == 1
327+
328+
290329
def test_successful_mfa_messaging(self, mfa_client):
291330
"""Create a successful messaging MFA request.
292331

bandwidth/voice/models/create_call_request.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ class CreateCallRequest(object):
4242
application_id (string): TODO: type description here.
4343
machine_detection (MachineDetectionConfiguration): TODO: type description
4444
here.
45+
priority (int): 1-5. The priority of this call over other calls from
46+
your account when outbound call queueing is enabled.
4547
4648
"""
4749

@@ -64,7 +66,8 @@ class CreateCallRequest(object):
6466
"disconnect_url": 'disconnectUrl',
6567
"disconnect_method": 'disconnectMethod',
6668
"tag": 'tag',
67-
"machine_detection": 'machineDetection'
69+
"machine_detection": 'machineDetection',
70+
"priority": "priority"
6871
}
6972

7073
def __init__(self,
@@ -85,7 +88,8 @@ def __init__(self,
8588
disconnect_url=None,
8689
disconnect_method=None,
8790
tag=None,
88-
machine_detection=None):
91+
machine_detection=None,
92+
priority=None):
8993
"""Constructor for the CreateCallRequest class"""
9094

9195
# Initialize members of the class
@@ -107,6 +111,7 @@ def __init__(self,
107111
self.tag = tag
108112
self.application_id = application_id
109113
self.machine_detection = machine_detection
114+
self.priority=priority
110115

111116
@classmethod
112117
def from_dictionary(cls,
@@ -144,6 +149,7 @@ def from_dictionary(cls,
144149
disconnect_method = dictionary.get('disconnectMethod')
145150
tag = dictionary.get('tag')
146151
machine_detection = MachineDetectionConfiguration.from_dictionary(dictionary.get('machineDetection')) if dictionary.get('machineDetection') else None
152+
priority = dictionary.get('priority')
147153

148154
# Return an object of this model
149155
return cls(mfrom,
@@ -163,4 +169,5 @@ def from_dictionary(cls,
163169
disconnect_url,
164170
disconnect_method,
165171
tag,
166-
machine_detection)
172+
machine_detection,
173+
priority)

bandwidth/voice/models/create_call_response.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
https://www.apimatic.io ).
88
"""
99
from bandwidth.api_helper import APIHelper
10+
from bandwidth.voice.models.machine_detection_configuration import MachineDetectionConfiguration
1011

1112

1213
class CreateCallResponse(object):
@@ -38,6 +39,7 @@ class CreateCallResponse(object):
3839
fallback_username (string): TODO: type description here.
3940
fallback_password (string): TODO: type description here.
4041
tag (string): TODO: type description here.
42+
priority (int): TODO: type description here.
4143
4244
"""
4345

@@ -62,7 +64,9 @@ class CreateCallResponse(object):
6264
"password": 'password',
6365
"fallback_username": 'fallbackUsername',
6466
"fallback_password": 'fallbackPassword',
65-
"tag": 'tag'
67+
"tag": 'tag',
68+
"machine_detection": 'machineDetection',
69+
"priority": 'priority'
6670
}
6771

6872
def __init__(self,
@@ -85,7 +89,8 @@ def __init__(self,
8589
password=None,
8690
fallback_username=None,
8791
fallback_password=None,
88-
tag=None):
92+
tag=None,
93+
priority=None):
8994
"""Constructor for the CreateCallResponse class"""
9095

9196
# Initialize members of the class
@@ -109,6 +114,7 @@ def __init__(self,
109114
self.fallback_username = fallback_username
110115
self.fallback_password = fallback_password
111116
self.tag = tag
117+
self.priority = priority
112118

113119
@classmethod
114120
def from_dictionary(cls,
@@ -148,6 +154,7 @@ def from_dictionary(cls,
148154
fallback_username = dictionary.get('fallbackUsername')
149155
fallback_password = dictionary.get('fallbackPassword')
150156
tag = dictionary.get('tag')
157+
priority = dictionary.get('priority')
151158

152159
# Return an object of this model
153160
return cls(account_id,
@@ -169,4 +176,5 @@ def from_dictionary(cls,
169176
password,
170177
fallback_username,
171178
fallback_password,
172-
tag)
179+
tag,
180+
priority)

setup.py

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

1616
setup(
1717
name='bandwidth-sdk',
18-
version='13.2.0',
18+
version='13.3.0',
1919
description='Bandwidth\'s set of APIs',
2020
long_description=long_description,
2121
long_description_content_type="text/markdown",

0 commit comments

Comments
 (0)