diff options
author | Lorenz Diener <[email protected]> | 2017-11-21 13:53:42 +0100 |
---|---|---|
committer | Lorenz Diener <[email protected]> | 2017-11-21 13:53:42 +0100 |
commit | d303afefc815af6207d8800ef4929a9a9693e0eb (patch) | |
tree | 09858da6cca76df33fea6cc9aea4e2bb3cfd51b2 | |
parent | 61552f9f84c736d447e0fccd54040d3b956a83e9 (diff) | |
download | mastodon.py-d303afefc815af6207d8800ef4929a9a9693e0eb.tar.gz |
Manually merge #94
-rw-r--r-- | mastodon/Mastodon.py | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py index b118421..da600cd 100644 --- a/mastodon/Mastodon.py +++ b/mastodon/Mastodon.py | |||
@@ -1029,21 +1029,15 @@ class Mastodon: | |||
1029 | 1029 | ||
1030 | response_object = None | 1030 | response_object = None |
1031 | try: | 1031 | try: |
1032 | kwargs = dict(headers=headers, files=files, | ||
1033 | timeout=self.request_timeout) | ||
1032 | if method == 'GET': | 1034 | if method == 'GET': |
1033 | response_object = requests.get(self.api_base_url + endpoint, params=params, | 1035 | kwargs['params'] = params |
1034 | headers=headers, files=files, | 1036 | else: |
1035 | timeout=self.request_timeout) | 1037 | kwargs['data'] = params |
1036 | if method == 'POST': | 1038 | |
1037 | response_object = requests.post(self.api_base_url + endpoint, data=params, headers=headers, | 1039 | response_object = requests.request( |
1038 | files=files, timeout=self.request_timeout) | 1040 | method, self.api_base_url + endpoint, **kwargs) |
1039 | |||
1040 | if method == 'PATCH': | ||
1041 | response_object = requests.patch(self.api_base_url + endpoint, data=params, headers=headers, | ||
1042 | files=files, timeout=self.request_timeout) | ||
1043 | |||
1044 | if method == 'DELETE': | ||
1045 | response_object = requests.delete(self.api_base_url + endpoint, data=params, headers=headers, | ||
1046 | files=files, timeout=self.request_timeout) | ||
1047 | except Exception as e: | 1041 | except Exception as e: |
1048 | raise MastodonNetworkError("Could not complete request: %s" % e) | 1042 | raise MastodonNetworkError("Could not complete request: %s" % e) |
1049 | 1043 | ||