コード例 #1
0
    def get_subscriptions(network, user_id):
        url = get_url(network) + PersonalizedStream.USER_SUBSCRIPTION_PATH.format(network.get_urn_for_user(user_id))
        headers = get_lf_token_header(network)

        response = requests.get(url, headers = headers)
        data = evaluate_response(response)['data']
        
        return [Subscription.serialize_from_json(x) for x in data['subscriptions']] if 'subscriptions' in data else []
コード例 #2
0
    def get_subscribers(network, topic, limit=100, offset=0):
        url = get_url(network) + PersonalizedStream.TOPIC_SUBSCRIPTION_PATH.format(topic.topic_id)
        headers = get_lf_token_header(network)

        response = requests.get(url, params = {'limit': limit, 'offset': offset}, headers = headers)
        data = evaluate_response(response)['data']
        
        return [Subscription.serialize_from_json(x) for x in data['subscriptions']] if 'subscriptions' in data else []
コード例 #3
0
 def test_func(self):
     sub = Subscription(self.TO, self.BY, self.TYPE, self.CREATED_AT)
     self.assertEqual(self.DICT, sub.to_dict())
     
     sub2 = Subscription.serialize_from_json(self.DICT)
     self.assertEqual(self.TO, sub2.to)
     self.assertEqual(self.BY, sub2.by)
     self.assertEqual(self.TYPE, sub2.sub_type)
     self.assertEqual(self.CREATED_AT, sub2.created_at)
     
     sub3 = json.dumps(sub2)
     self.assertEqual(json.dumps(self.DICT), sub3)