From 0bd6d578fdf5a2906a0035b71c4d0cc62a368c1c Mon Sep 17 00:00:00 2001 From: Thomas Whitton Date: Wed, 19 Dec 2012 23:33:03 +0000 Subject: [PATCH] Added suggest user api methods --- tests.py | 9 +++++++++ tweepy/__init__.py | 2 +- tweepy/api.py | 24 ++++++++++++++++++++++++ tweepy/models.py | 21 ++++++++++++++++----- 4 files changed, 50 insertions(+), 6 deletions(-) diff --git a/tests.py b/tests.py index 5bd2bd1..9736340 100644 --- 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) diff --git a/tweepy/__init__.py b/tweepy/__init__.py index 31e4d1e..a311a81 100644 --- a/tweepy/__init__.py +++ b/tweepy/__init__.py @@ -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 diff --git a/tweepy/api.py b/tweepy/api.py index e1f89ae..060a879 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -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', diff --git a/tweepy/models.py b/tweepy/models.py index fe5521f..8275505 100644 --- a/tweepy/models.py +++ b/tweepy/models.py @@ -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 -- 2.25.1