Skip to content

Commit 5b70161

Browse files
author
Art van Scheppingen
committed
Returning the correct content via a switcher
1 parent c628ce2 commit 5b70161

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

messagebird/http_client.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,11 @@ def request(self, path, method='GET', params=None, format=ResponseFormat.text):
4545
if isinstance(response, str):
4646
raise ValueError(response)
4747

48-
if response.status_code in self.__supported_status_codes:
49-
if format == ResponseFormat.text:
50-
response_text = response.text
51-
else:
52-
response_text = response.content
53-
else:
48+
if response.status_code not in self.__supported_status_codes:
5449
response.raise_for_status()
5550

56-
return response_text
51+
response_switcher = {
52+
ResponseFormat.text: response.text,
53+
ResponseFormat.binary: response.content
54+
}
55+
return response_switcher.get(format)

0 commit comments

Comments
 (0)