Added suggest user api methods
authorThomas Whitton <mail@thomaswhitton.com>
Wed, 19 Dec 2012 23:33:03 +0000 (23:33 +0000)
committerThomas Whitton <mail@thomaswhitton.com>
Wed, 19 Dec 2012 23:33:03 +0000 (23:33 +0000)
tests.py
tweepy/__init__.py
tweepy/api.py
tweepy/models.py

index 5bd2bd190aaaae59edc8b3b0f7d63da03b963fc0..97363405cd317a0b6d48f8f5bd846694202651a9 100644 (file)
--- a/tests.py
+++ b/tests.py
@@ -95,6 +95,15 @@ class TweepyAPITests(unittest.TestCase):
     def testsearchusers(self):
         self.api.search_users('twitter')
 
+    def testsuggestedusers(self):
+        self.api.suggested_users('twitter')
+
+    def testsuggestedcategories(self):
+        self.api.suggested_categories()
+
+    def testsuggestedhuserstweets(self):
+        self.api.suggested_users_tweets('twitter')
+
     def testme(self):
         me = self.api.me()
         self.assertEqual(me.screen_name, username)
index 31e4d1e1394f937cd0bc96278aba29c05ebf79e0..a311a81a3624c61b23918e6d10bdfe568881020e 100644 (file)
@@ -9,7 +9,7 @@ __version__ = '1.12'
 __author__ = 'Joshua Roesslein'
 __license__ = 'MIT'
 
-from tweepy.models import Status, User, DirectMessage, Friendship, SavedSearch, SearchResult, ModelFactory
+from tweepy.models import Status, User, DirectMessage, Friendship, SavedSearch, SearchResult, ModelFactory, Category
 from tweepy.error import TweepError
 from tweepy.api import API
 from tweepy.cache import Cache, MemoryCache, FileCache
index e1f89ae0ca1177490c82df12788e485cf4ada842..060a879f77a3ee140d65484e930942269ccc90c4 100644 (file)
@@ -198,6 +198,30 @@ class API(object):
         allowed_param = ['q', 'per_page', 'page']
     )
 
+    """ users/suggestions/:slug """
+    suggested_users = bind_api(
+        path = '/users/suggestions/{slug}.json',
+        payload_type = 'user', payload_list = True,
+        require_auth = True,
+        allowed_param = ['slug', 'lang']
+    )
+
+    """ users/suggestions """
+    suggested_categories = bind_api(
+        path = '/users/suggestions.json',
+        payload_type = 'category', payload_list = True,
+        allowed_param = ['lang'],
+        require_auth = True
+    )
+
+    """ users/suggestions/:slug/members """
+    suggested_users_tweets = bind_api(
+        path = '/users/suggestions/{slug}/members.json',
+        payload_type = 'status', payload_list = True,
+        allowed_param = ['slug'],
+        require_auth = True
+    )
+
     """ statuses/friends """
     friends = bind_api(
         path = '/statuses/friends.json',
index fe5521f2d8db239f6d32fcad7a401d6a3f98e1f8..827550573c5e856a47b050918a193760a268be06 100644 (file)
@@ -183,6 +183,16 @@ class Friendship(Model):
         return source, target
 
 
+class Category(Model):
+
+    @classmethod
+    def parse(cls, api, json):
+        category = cls(api)
+        for k, v in json.items():
+            setattr(category, k, v)
+        return category
+
+
 class SavedSearch(Model):
 
     @classmethod
@@ -338,9 +348,9 @@ class BoundingBox(Model):
 
     def origin(self):
         """
-        Return longitude, latitude of southwest (bottom, left) corner of 
-        bounding box, as a tuple.  
-        
+        Return longitude, latitude of southwest (bottom, left) corner of
+        bounding box, as a tuple.
+
         This assumes that bounding box is always a rectangle, which
         appears to be the case at present.
         """
@@ -349,8 +359,8 @@ class BoundingBox(Model):
     def corner(self):
         """
         Return longitude, latitude of northeast (top, right) corner of
-        bounding box, as a tuple.  
-        
+        bounding box, as a tuple.
+
         This assumes that bounding box is always a rectangle, which
         appears to be the case at present.
         """
@@ -403,6 +413,7 @@ class ModelFactory(object):
     friendship = Friendship
     saved_search = SavedSearch
     search_result = SearchResult
+    category = Category
     list = List
     relation = Relation
     relationship = Relationship