@@ 35,6 35,7 @@ class API(object):
self.likes_remaining = -1
self.super_likes_remaining = -1
self.super_likes_allotment = -1
+ self.super_likes_resets_at = None
self.rate_limited_until = None
def set_auth(self, fb_id, fb_token):
@@ 79,10 80,10 @@ class API(object):
allowed_param=['user_id'],
)
- # XXX Needs to be updated. Path is incorrect
_super_like = bind_api(
path='/like/{user_id}/super',
allowed_param=['user_id'],
+ method='POST',
)
nope = bind_api(
@@ 176,10 177,37 @@ class API(object):
return data.get('match', False)
def super_like(self, user_id):
- ''' XXX needs to be inspected and updated
+ '''
+ Response (normal):
+ {u'match': False,
+ u'status': 200,
+ u'super_likes': {u'allotment': 1,
+ u'remaining': 0,
+ u'resets_at': u'2015-11-07T13:27:23.748Z'}}
+
+ Response (exceeded):
+ {u'limit_exceeded': True,
+ u'status': 200,
+ u'super_likes': {u'allotment': 1,
+ u'remaining': 0,
+ u'resets_at': u'2015-11-07T13:27:24.146Z'}}
'''
data = self._super_like(user_id)
- return data
+ if 'limit_exceeded' in data and self.debug:
+ log.info('X You have no available Super Likes')
+
+ self.super_likes_remaining = \
+ data['rating']['super_likes']['remaining']
+ self.super_likes_allotment = \
+ data['rating']['super_likes']['allotment']
+ self.super_likes_resets_at = \
+ data['rating']['super_likes']['resets_at']
+ if self.debug:
+ log.info('* Super Likes Remaining: {0} (out of {1})'.format(
+ self.super_likes_remaining,
+ self.super_likes_allotment,
+ ))
+ return data.get('match', False)
def update_likes_remaining(self):
data = self.meta()