From: Josh Roesslein Date: Thu, 23 Jul 2009 01:09:59 +0000 (-0500) Subject: Added create, destroy, exists blocks methods. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=204afa996945684d195ae41620872eb8c4805cd8;p=tweepy.git Added create, destroy, exists blocks methods. --- diff --git a/api.py b/api.py index b7c6ba2..09656e5 100644 --- a/api.py +++ b/api.py @@ -280,3 +280,34 @@ class API(object): require_auth = True ) + """Create a block""" + create_block = bind_api( + path = '/blocks/create.json', + method = 'POST', + parser = parse_user, + allowed_param = ['id'], + require_auth = True + ) + + """Destroy a block""" + destroy_block = bind_api( + path = '/blocks/destroy.json', + method = 'DELETE', + parser = parse_user, + allowed_param = ['id'], + require_auth = True + ) + + """Check if block exists""" + def exists_block(self, **kargs): + try: + bind_api( + path = '/blocks/exists.json', + parser = parse_none, + allowed_param = ['id', 'user_id', 'screen_name'], + require_auth = True + )(self, **kargs) + except TweepError: + return False + return True + diff --git a/parsers.py b/parsers.py index 3e58cfd..233621f 100644 --- a/parsers.py +++ b/parsers.py @@ -116,3 +116,7 @@ def parse_verify_credentials(data, api): def parse_rate_limit(data, api): return json.loads(data) + +def parse_none(data, api): + + return None