From d303afefc815af6207d8800ef4929a9a9693e0eb Mon Sep 17 00:00:00 2001 From: Lorenz Diener Date: Tue, 21 Nov 2017 13:53:42 +0100 Subject: Manually merge #94 --- mastodon/Mastodon.py | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'mastodon') 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: response_object = None try: + kwargs = dict(headers=headers, files=files, + timeout=self.request_timeout) if method == 'GET': - response_object = requests.get(self.api_base_url + endpoint, params=params, - headers=headers, files=files, - timeout=self.request_timeout) - if method == 'POST': - response_object = requests.post(self.api_base_url + endpoint, data=params, headers=headers, - files=files, timeout=self.request_timeout) - - if method == 'PATCH': - response_object = requests.patch(self.api_base_url + endpoint, data=params, headers=headers, - files=files, timeout=self.request_timeout) - - if method == 'DELETE': - response_object = requests.delete(self.api_base_url + endpoint, data=params, headers=headers, - files=files, timeout=self.request_timeout) + kwargs['params'] = params + else: + kwargs['data'] = params + + response_object = requests.request( + method, self.api_base_url + endpoint, **kwargs) except Exception as e: raise MastodonNetworkError("Could not complete request: %s" % e) -- cgit v1.2.3