From: John Gunnarsson Date: Mon, 19 Mar 2012 00:35:16 +0000 (+0100) Subject: Added support for /friendships/lookup api call X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=aa055fe16c73f80a0a36279bfc83e40af3d93008;p=tweepy.git Added support for /friendships/lookup api call --- diff --git a/tweepy/api.py b/tweepy/api.py index 7692ce4..6750229 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -278,6 +278,19 @@ class API(object): 'target_id', 'target_screen_name'] ) + + """ Perform bulk look up of friendships from user ID or screenname """ + def lookup_friendships(self, user_ids=None, screen_names=None): + return self._lookup_friendships(list_to_csv(user_ids), list_to_csv(screen_names)) + + _lookup_friendships = bind_api( + path = '/friendships/lookup.json', + payload_type = 'relationship', payload_list = True, + allowed_param = ['user_id', 'screen_name'], + require_auth = True + ) + + """ friends/ids """ friends_ids = bind_api( path = '/friends/ids.json', diff --git a/tweepy/models.py b/tweepy/models.py index d640b9c..0235cc1 100644 --- a/tweepy/models.py +++ b/tweepy/models.py @@ -290,6 +290,17 @@ class Relation(Model): setattr(result, k, v) return result +class Relationship(Model): + @classmethod + def parse(cls, api, json): + result = cls(api) + for k,v in json.items(): + if k == 'connections': + setattr(result, 'is_following', 'following' in v) + setattr(result, 'is_followed_by', 'followed_by' in v) + else: + setattr(result, k, v) + return result class JSONModel(Model): @@ -323,6 +334,7 @@ class ModelFactory(object): search_result = SearchResult list = List relation = Relation + relationship = Relationship json = JSONModel ids = IDModel