From: Aaron Swartz Date: Sat, 5 Feb 2011 05:32:25 +0000 (-0600) Subject: Add support for related_result X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=22d10a73296fcdb6c91d6255029364661ff178ae;p=tweepy.git Add support for related_result --- diff --git a/tweepy/api.py b/tweepy/api.py index b2304b6..2668787 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -77,6 +77,14 @@ class API(object): allowed_param = ['id', 'count', 'page'], require_auth = True ) + + """/related_results/show/:id.format""" + related_results = bind_api( + path = '/related_results/show/{id}.json', + payload_type = 'relation', payload_list = True, + allowed_param = ['id'], + require_auth = False + ) """/statuses/:id/retweeted_by/ids.format""" retweeted_by_ids = bind_api( diff --git a/tweepy/models.py b/tweepy/models.py index b584fbc..d4d5c4e 100644 --- a/tweepy/models.py +++ b/tweepy/models.py @@ -276,6 +276,19 @@ class List(Model): def is_subscribed(self, id): return self._api.is_subscribed_list(self.user.screen_name, self.slug, id) +class Relation(Model): + @classmethod + def parse(cls, api, json): + result = cls(api) + for k,v in json.items(): + if k == 'value' and json['kind'] in ['Tweet', 'LookedupStatus']: + setattr(result, k, Status.parse(api, v)) + elif k == 'results': + setattr(result, k, Relation.parse_list(api, v)) + else: + setattr(result, k, v) + return result + class JSONModel(Model): @@ -308,6 +321,7 @@ class ModelFactory(object): saved_search = SavedSearch search_result = SearchResult list = List + relation = Relation json = JSONModel ids = IDModel