Skip to content

Commit 0295d50

Browse files
committed
Deploy
1 parent 6008abb commit 0295d50

File tree

10 files changed

+39
-191
lines changed

10 files changed

+39
-191
lines changed

bandwidth/controllers/base_controller.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class BaseController(object):
2727
"""
2828

2929
global_headers = {
30-
'user-agent': 'APIMATIC 2.0'
30+
'user-agent': 'python-sdk-refs/tags/python6.0.0'
3131
}
3232

3333
def __init__(self, config, call_back=None):

bandwidth/messaging/controllers/api_controller.py

Lines changed: 31 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
from bandwidth.http.auth.messaging_basic_auth import MessagingBasicAuth
1515
from bandwidth.messaging.models.media import Media
1616
from bandwidth.messaging.models.bandwidth_message import BandwidthMessage
17-
from bandwidth.messaging.exceptions.generic_client_exception import GenericClientException
18-
from bandwidth.messaging.exceptions.path_client_exception import PathClientException
17+
from bandwidth.messaging.exceptions.messaging_exception import MessagingException
1918

2019

2120
class APIController(BaseController):
@@ -25,50 +24,6 @@ class APIController(BaseController):
2524
def __init__(self, config, call_back=None):
2625
super(APIController, self).__init__(config, call_back)
2726

28-
def get_message(self):
29-
"""Does a GET request to /ping.
30-
31-
getMessage
32-
33-
Returns:
34-
void: Response from the API.
35-
36-
Raises:
37-
APIException: When an error occurs while fetching the data from
38-
the remote API. This exception includes the HTTP Response
39-
code, an error message, and the HTTP body that was received in
40-
the request.
41-
42-
"""
43-
44-
# Prepare query URL
45-
_url_path = '/ping'
46-
_query_builder = self.config.get_base_uri(Server.MESSAGINGDEFAULT)
47-
_query_builder += _url_path
48-
_query_url = APIHelper.clean_url(_query_builder)
49-
50-
# Prepare and execute request
51-
_request = self.config.http_client.get(_query_url)
52-
MessagingBasicAuth.apply(self.config, _request)
53-
_response = self.execute_request(_request)
54-
55-
# Endpoint and global error handling using HTTP status codes.
56-
if _response.status_code == 400:
57-
raise GenericClientException('400 Request is malformed or invalid', _response)
58-
elif _response.status_code == 401:
59-
raise PathClientException('401 The specified user does not have access to the account', _response)
60-
elif _response.status_code == 403:
61-
raise PathClientException('403 The user does not have access to this API', _response)
62-
elif _response.status_code == 404:
63-
raise PathClientException('404 Path not found', _response)
64-
elif _response.status_code == 415:
65-
raise GenericClientException('415 The content-type of the request is incorrect', _response)
66-
elif _response.status_code == 429:
67-
raise GenericClientException('429 The rate limit has been reached', _response)
68-
self.validate_response(_response)
69-
70-
# Return appropriate type
71-
ApiResponse(_response)
7227
def list_media(self,
7328
user_id,
7429
continuation_token=None):
@@ -114,17 +69,17 @@ def list_media(self,
11469

11570
# Endpoint and global error handling using HTTP status codes.
11671
if _response.status_code == 400:
117-
raise GenericClientException('400 Request is malformed or invalid', _response)
72+
raise MessagingException('400 Request is malformed or invalid', _response)
11873
elif _response.status_code == 401:
119-
raise PathClientException('401 The specified user does not have access to the account', _response)
74+
raise MessagingException('401 The specified user does not have access to the account', _response)
12075
elif _response.status_code == 403:
121-
raise PathClientException('403 The user does not have access to this API', _response)
76+
raise MessagingException('403 The user does not have access to this API', _response)
12277
elif _response.status_code == 404:
123-
raise PathClientException('404 Path not found', _response)
78+
raise MessagingException('404 Path not found', _response)
12479
elif _response.status_code == 415:
125-
raise GenericClientException('415 The content-type of the request is incorrect', _response)
80+
raise MessagingException('415 The content-type of the request is incorrect', _response)
12681
elif _response.status_code == 429:
127-
raise GenericClientException('429 The rate limit has been reached', _response)
82+
raise MessagingException('429 The rate limit has been reached', _response)
12883
self.validate_response(_response)
12984

13085
decoded = APIHelper.json_deserialize(_response.text, Media.from_dictionary)
@@ -170,17 +125,17 @@ def get_media(self,
170125

171126
# Endpoint and global error handling using HTTP status codes.
172127
if _response.status_code == 400:
173-
raise GenericClientException('400 Request is malformed or invalid', _response)
128+
raise MessagingException('400 Request is malformed or invalid', _response)
174129
elif _response.status_code == 401:
175-
raise PathClientException('401 The specified user does not have access to the account', _response)
130+
raise MessagingException('401 The specified user does not have access to the account', _response)
176131
elif _response.status_code == 403:
177-
raise PathClientException('403 The user does not have access to this API', _response)
132+
raise MessagingException('403 The user does not have access to this API', _response)
178133
elif _response.status_code == 404:
179-
raise PathClientException('404 Path not found', _response)
134+
raise MessagingException('404 Path not found', _response)
180135
elif _response.status_code == 415:
181-
raise GenericClientException('415 The content-type of the request is incorrect', _response)
136+
raise MessagingException('415 The content-type of the request is incorrect', _response)
182137
elif _response.status_code == 429:
183-
raise GenericClientException('429 The rate limit has been reached', _response)
138+
raise MessagingException('429 The rate limit has been reached', _response)
184139
self.validate_response(_response)
185140

186141
decoded = _response.text
@@ -249,17 +204,17 @@ def upload_media(self,
249204

250205
# Endpoint and global error handling using HTTP status codes.
251206
if _response.status_code == 400:
252-
raise GenericClientException('400 Request is malformed or invalid', _response)
207+
raise MessagingException('400 Request is malformed or invalid', _response)
253208
elif _response.status_code == 401:
254-
raise PathClientException('401 The specified user does not have access to the account', _response)
209+
raise MessagingException('401 The specified user does not have access to the account', _response)
255210
elif _response.status_code == 403:
256-
raise PathClientException('403 The user does not have access to this API', _response)
211+
raise MessagingException('403 The user does not have access to this API', _response)
257212
elif _response.status_code == 404:
258-
raise PathClientException('404 Path not found', _response)
213+
raise MessagingException('404 Path not found', _response)
259214
elif _response.status_code == 415:
260-
raise GenericClientException('415 The content-type of the request is incorrect', _response)
215+
raise MessagingException('415 The content-type of the request is incorrect', _response)
261216
elif _response.status_code == 429:
262-
raise GenericClientException('429 The rate limit has been reached', _response)
217+
raise MessagingException('429 The rate limit has been reached', _response)
263218
self.validate_response(_response)
264219

265220
# Return appropriate type
@@ -303,17 +258,17 @@ def delete_media(self,
303258

304259
# Endpoint and global error handling using HTTP status codes.
305260
if _response.status_code == 400:
306-
raise GenericClientException('400 Request is malformed or invalid', _response)
261+
raise MessagingException('400 Request is malformed or invalid', _response)
307262
elif _response.status_code == 401:
308-
raise PathClientException('401 The specified user does not have access to the account', _response)
263+
raise MessagingException('401 The specified user does not have access to the account', _response)
309264
elif _response.status_code == 403:
310-
raise PathClientException('403 The user does not have access to this API', _response)
265+
raise MessagingException('403 The user does not have access to this API', _response)
311266
elif _response.status_code == 404:
312-
raise PathClientException('404 Path not found', _response)
267+
raise MessagingException('404 Path not found', _response)
313268
elif _response.status_code == 415:
314-
raise GenericClientException('415 The content-type of the request is incorrect', _response)
269+
raise MessagingException('415 The content-type of the request is incorrect', _response)
315270
elif _response.status_code == 429:
316-
raise GenericClientException('429 The rate limit has been reached', _response)
271+
raise MessagingException('429 The rate limit has been reached', _response)
317272
self.validate_response(_response)
318273

319274
# Return appropriate type
@@ -362,17 +317,17 @@ def create_message(self,
362317

363318
# Endpoint and global error handling using HTTP status codes.
364319
if _response.status_code == 400:
365-
raise GenericClientException('400 Request is malformed or invalid', _response)
320+
raise MessagingException('400 Request is malformed or invalid', _response)
366321
elif _response.status_code == 401:
367-
raise PathClientException('401 The specified user does not have access to the account', _response)
322+
raise MessagingException('401 The specified user does not have access to the account', _response)
368323
elif _response.status_code == 403:
369-
raise PathClientException('403 The user does not have access to this API', _response)
324+
raise MessagingException('403 The user does not have access to this API', _response)
370325
elif _response.status_code == 404:
371-
raise PathClientException('404 Path not found', _response)
326+
raise MessagingException('404 Path not found', _response)
372327
elif _response.status_code == 415:
373-
raise GenericClientException('415 The content-type of the request is incorrect', _response)
328+
raise MessagingException('415 The content-type of the request is incorrect', _response)
374329
elif _response.status_code == 429:
375-
raise GenericClientException('429 The rate limit has been reached', _response)
330+
raise MessagingException('429 The rate limit has been reached', _response)
376331
self.validate_response(_response)
377332

378333
decoded = APIHelper.json_deserialize(_response.text, BandwidthMessage.from_dictionary)

bandwidth/messaging/controllers/base_controller.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class BaseController(object):
2727
"""
2828

2929
global_headers = {
30-
'user-agent': 'APIMATIC 2.0'
30+
'user-agent': 'python-sdk-refs/tags/python6.0.0'
3131
}
3232

3333
def __init__(self, config, call_back=None):
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
__all__ = [
2-
'generic_client_exception',
3-
'path_client_exception',
2+
'messaging_exception',
43
]

bandwidth/messaging/exceptions/generic_client_exception.py renamed to bandwidth/messaging/exceptions/messaging_exception.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,19 @@
88

99
from bandwidth.api_helper import APIHelper
1010
import bandwidth.exceptions.api_exception
11-
import bandwidth.messaging.models.field_error
1211

1312

14-
class GenericClientException(bandwidth.exceptions.api_exception.APIException):
13+
class MessagingException(bandwidth.exceptions.api_exception.APIException):
1514
def __init__(self, reason, response):
16-
"""Constructor for the GenericClientException class
15+
"""Constructor for the MessagingException class
1716
1817
Args:
1918
reason (string): The reason (or error message) for the Exception
2019
to be raised.
2120
response (HttpResponse): The HttpResponse of the API call.
2221
2322
"""
24-
super(GenericClientException, self).__init__(reason, response)
23+
super(MessagingException, self).__init__(reason, response)
2524
dictionary = APIHelper.json_deserialize(self.response.text)
2625
if isinstance(dictionary, dict):
2726
self.unbox(dictionary)
@@ -37,6 +36,3 @@ def unbox(self, dictionary):
3736
"""
3837
self.mtype = dictionary.get('type')
3938
self.description = dictionary.get('description')
40-
self.field_errors = None
41-
if dictionary.get('fieldErrors') is not None:
42-
self.field_errors = [bandwidth.messaging.models.field_error.FieldError.from_dictionary(x) for x in dictionary.get('fieldErrors')]

bandwidth/messaging/exceptions/path_client_exception.py

Lines changed: 0 additions & 41 deletions
This file was deleted.

bandwidth/messaging/models/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
__all__ = [
2-
'field_error',
32
'media',
43
'tag',
54
'deferred_result',

bandwidth/messaging/models/field_error.py

Lines changed: 0 additions & 60 deletions
This file was deleted.

bandwidth/voice/controllers/base_controller.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class BaseController(object):
2727
"""
2828

2929
global_headers = {
30-
'user-agent': 'APIMATIC 2.0'
30+
'user-agent': 'python-sdk-refs/tags/python6.0.0'
3131
}
3232

3333
def __init__(self, config, call_back=None):

setup.py

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

1313
setup(
1414
name='bandwidth-sdk',
15-
version='5.2.1',
15+
version='6.0.0',
1616
description='Bandwidth\'s set of APIs',
1717
long_description=long_description,
1818
long_description_content_type="text/markdown",

0 commit comments

Comments
 (0)