From 204afa996945684d195ae41620872eb8c4805cd8 Mon Sep 17 00:00:00 2001 From: Josh Roesslein Date: Wed, 22 Jul 2009 20:09:59 -0500 Subject: [PATCH] Added create, destroy, exists blocks methods. --- api.py | 31 +++++++++++++++++++++++++++++++ parsers.py | 4 ++++ 2 files changed, 35 insertions(+) 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 -- 2.25.1