Skip to content

Commit 0bd6d57

Browse files
committed
Added suggest user api methods
1 parent 93f0a76 commit 0bd6d57

File tree

4 files changed

+50
-6
lines changed

4 files changed

+50
-6
lines changed

tests.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,15 @@ def testgetuser(self):
9595
def testsearchusers(self):
9696
self.api.search_users('twitter')
9797

98+
def testsuggestedusers(self):
99+
self.api.suggested_users('twitter')
100+
101+
def testsuggestedcategories(self):
102+
self.api.suggested_categories()
103+
104+
def testsuggestedhuserstweets(self):
105+
self.api.suggested_users_tweets('twitter')
106+
98107
def testme(self):
99108
me = self.api.me()
100109
self.assertEqual(me.screen_name, username)

tweepy/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
__author__ = 'Joshua Roesslein'
1010
__license__ = 'MIT'
1111

12-
from tweepy.models import Status, User, DirectMessage, Friendship, SavedSearch, SearchResult, ModelFactory
12+
from tweepy.models import Status, User, DirectMessage, Friendship, SavedSearch, SearchResult, ModelFactory, Category
1313
from tweepy.error import TweepError
1414
from tweepy.api import API
1515
from tweepy.cache import Cache, MemoryCache, FileCache

tweepy/api.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,30 @@ def me(self):
198198
allowed_param = ['q', 'per_page', 'page']
199199
)
200200

201+
""" users/suggestions/:slug """
202+
suggested_users = bind_api(
203+
path = '/users/suggestions/{slug}.json',
204+
payload_type = 'user', payload_list = True,
205+
require_auth = True,
206+
allowed_param = ['slug', 'lang']
207+
)
208+
209+
""" users/suggestions """
210+
suggested_categories = bind_api(
211+
path = '/users/suggestions.json',
212+
payload_type = 'category', payload_list = True,
213+
allowed_param = ['lang'],
214+
require_auth = True
215+
)
216+
217+
""" users/suggestions/:slug/members """
218+
suggested_users_tweets = bind_api(
219+
path = '/users/suggestions/{slug}/members.json',
220+
payload_type = 'status', payload_list = True,
221+
allowed_param = ['slug'],
222+
require_auth = True
223+
)
224+
201225
""" statuses/friends """
202226
friends = bind_api(
203227
path = '/statuses/friends.json',

tweepy/models.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,16 @@ def parse(cls, api, json):
183183
return source, target
184184

185185

186+
class Category(Model):
187+
188+
@classmethod
189+
def parse(cls, api, json):
190+
category = cls(api)
191+
for k, v in json.items():
192+
setattr(category, k, v)
193+
return category
194+
195+
186196
class SavedSearch(Model):
187197

188198
@classmethod
@@ -338,9 +348,9 @@ def parse(cls, api, json):
338348

339349
def origin(self):
340350
"""
341-
Return longitude, latitude of southwest (bottom, left) corner of
342-
bounding box, as a tuple.
343-
351+
Return longitude, latitude of southwest (bottom, left) corner of
352+
bounding box, as a tuple.
353+
344354
This assumes that bounding box is always a rectangle, which
345355
appears to be the case at present.
346356
"""
@@ -349,8 +359,8 @@ def origin(self):
349359
def corner(self):
350360
"""
351361
Return longitude, latitude of northeast (top, right) corner of
352-
bounding box, as a tuple.
353-
362+
bounding box, as a tuple.
363+
354364
This assumes that bounding box is always a rectangle, which
355365
appears to be the case at present.
356366
"""
@@ -403,6 +413,7 @@ class ModelFactory(object):
403413
friendship = Friendship
404414
saved_search = SavedSearch
405415
search_result = SearchResult
416+
category = Category
406417
list = List
407418
relation = Relation
408419
relationship = Relationship

0 commit comments

Comments
 (0)