Skip to content
This repository has been archived by the owner on Feb 10, 2021. It is now read-only.

Commit

Permalink
Merge pull request #33 from jmulford-bandwidth/changed-api-response-h…
Browse files Browse the repository at this point in the history
…eader

Added application/json hotfix, updated version number of SDK
  • Loading branch information
Aubron committed Mar 25, 2019
2 parents 221bc68 + 8ff9107 commit 68d41f5
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
6 changes: 4 additions & 2 deletions bandwidth/account/client_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ def _request(self, method, url, *args, **kwargs):

def _check_response(self, response):
if response.status_code >= 400:
if response.headers.get('content-type') == 'application/json':
if response.headers.get('content-type') is not None and \
response.headers.get('content-type').startswith("application/json"):
data = response.json()
raise BandwidthAccountAPIException(
response.status_code, data['message'], code=data.get('code'))
Expand All @@ -81,7 +82,8 @@ def _make_request(self, method, url, *args, **kwargs):
self._check_response(response)
data = None
id = None
if response.headers.get('content-type') == 'application/json':
if response.headers.get('content-type') is not None and \
response.headers.get('content-type').startswith("application/json"):
data = convert_object_to_snake_case(response.json())
location = response.headers.get('location')
if location is not None:
Expand Down
6 changes: 4 additions & 2 deletions bandwidth/messaging/client_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ def _request(self, method, url, *args, **kwargs):

def _check_response(self, response):
if response.status_code >= 400:
if response.headers.get('content-type') == 'application/json':
if response.headers.get('content-type') is not None and \
response.headers.get('content-type').startswith("application/json"):
data = response.json()
raise BandwidthMessageAPIException(
response.status_code, data['message'], code=data.get('code'))
Expand All @@ -80,7 +81,8 @@ def _make_request(self, method, url, *args, **kwargs):
self._check_response(response)
data = None
id = None
if response.headers.get('content-type') == 'application/json':
if response.headers.get('content-type') is not None and \
response.headers.get('content-type').startswith("application/json"):
data = convert_object_to_snake_case(response.json())
location = response.headers.get('location')
if location is not None:
Expand Down
2 changes: 1 addition & 1 deletion bandwidth/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = 'v3.0.1'
__version__ = 'v3.0.2'
6 changes: 4 additions & 2 deletions bandwidth/voice/client_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ def _request(self, method, url, *args, **kwargs):

def _check_response(self, response):
if response.status_code >= 400:
if response.headers.get('content-type') == 'application/json':
if response.headers.get('content-type') is not None and \
response.headers.get('content-type').startswith("application/json"):
data = response.json()
raise BandwidthVoiceAPIException(
response.status_code, data['message'], code=data.get('code'))
Expand All @@ -89,7 +90,8 @@ def _make_request(self, method, url, *args, **kwargs):
self._check_response(response)
data = None
id = None
if response.headers.get('content-type') == 'application/json':
if response.headers.get('content-type') is not None and \
response.headers.get('content-type').startswith("application/json"):
data = convert_object_to_snake_case(response.json())
location = response.headers.get('location')
if location is not None:
Expand Down

0 comments on commit 68d41f5

Please sign in to comment.