Added delete methods to Twython's API
This commit is contained in:
parent
36fda7ac02
commit
a8a0777f72
1 changed files with 6 additions and 2 deletions
|
|
@ -153,7 +153,7 @@ class Twython(EndpointsMixin, object):
|
||||||
if k in ('timeout', 'allow_redirects', 'stream', 'verify'):
|
if k in ('timeout', 'allow_redirects', 'stream', 'verify'):
|
||||||
requests_args[k] = v
|
requests_args[k] = v
|
||||||
|
|
||||||
if method == 'get':
|
if method == 'get' or method == 'delete':
|
||||||
requests_args['params'] = params
|
requests_args['params'] = params
|
||||||
else:
|
else:
|
||||||
# Check for json_encoded so we will sent params as "data" or "json"
|
# Check for json_encoded so we will sent params as "data" or "json"
|
||||||
|
|
@ -242,7 +242,7 @@ class Twython(EndpointsMixin, object):
|
||||||
(e.g. search/tweets)
|
(e.g. search/tweets)
|
||||||
:type endpoint: string
|
:type endpoint: string
|
||||||
:param method: (optional) Method of accessing data, either
|
:param method: (optional) Method of accessing data, either
|
||||||
GET or POST. (default GET)
|
GET, POST or DELETE. (default GET)
|
||||||
:type method: string
|
:type method: string
|
||||||
:param params: (optional) Dict of parameters (if any) accepted
|
:param params: (optional) Dict of parameters (if any) accepted
|
||||||
the by Twitter API endpoint you are trying to
|
the by Twitter API endpoint you are trying to
|
||||||
|
|
@ -281,6 +281,10 @@ class Twython(EndpointsMixin, object):
|
||||||
"""Shortcut for POST requests via :class:`request`"""
|
"""Shortcut for POST requests via :class:`request`"""
|
||||||
return self.request(endpoint, 'POST', params=params, version=version, json_encoded=json_encoded)
|
return self.request(endpoint, 'POST', params=params, version=version, json_encoded=json_encoded)
|
||||||
|
|
||||||
|
def delete(self, endpoint, params=None, version='1.1', json_encoded=False):
|
||||||
|
"""Shortcut for delete requests via :class:`request`"""
|
||||||
|
return self.request(endpoint, 'DELETE', params=params, version=version, json_encoded=json_encoded)
|
||||||
|
|
||||||
def get_lastfunction_header(self, header, default_return_value=None):
|
def get_lastfunction_header(self, header, default_return_value=None):
|
||||||
"""Returns a specific header from the last API call
|
"""Returns a specific header from the last API call
|
||||||
This will return None if the header is not present
|
This will return None if the header is not present
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue