Added create, destroy, exists blocks methods.
authorJosh Roesslein <jroesslein@gmail.com>
Thu, 23 Jul 2009 01:09:59 +0000 (20:09 -0500)
committerJosh Roesslein <jroesslein@gmail.com>
Thu, 23 Jul 2009 01:09:59 +0000 (20:09 -0500)
api.py
parsers.py

diff --git a/api.py b/api.py
index b7c6ba2c0c4c4fd6632188ff9fa5f784dfc0b40b..09656e5cd0eb414d018899dd6e397d037f81873b 100644 (file)
--- 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
+
index 3e58cfdb28b7ed3ab18782d00b854cb49f4da0cd..233621faec6e150eca0944b25e40373f0187f392 100644 (file)
@@ -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