def get_data(self): """Returns the data of the user""" if self.user_type is 'Me': data = r.get('/profile') return data else: data = r.get('/user/{}'.format(self.id)) if 'error' in data: print('Error user was not found') return data['results']
def yield_users(self): """Returns a generator of nearby users as NormalUser()""" while True: resp = r.get('/user/recs') recs = resp['results'] if 'results' in resp else [] for rec in recs: yield u.UserController(rec['_id']).get_user()
def yield_usersv2(self): """Returns a generator of nearby users as NormalUser() and calculates location""" while True: resp = r.get('/v2/recs/core?locale=en-US') recs = resp['data']['results'] if 'data' in resp else [] for rec in recs: if rec['type'] == 'user': yield u.UserController(rec['user']['_id']).get_user()
def __init__(self): self.auth = self.auth() self.id = self.get_id() self.data = r.get('/profile') self.meta = r.get('/meta') self.metav2 = r.get('/v2/meta')
def me(self): """Returns a UserModel() for the Session""" return u.UserController(r.get('/profile')['_id']).get_user()
def get_id(self): """Returns the _id of the Session""" return r.get('/profile')['_id']
def fast_match_count(self): """Returns the number of like's the session user has received""" return r.get('/v2/fast-match/count')['data']['count']
def search_gifs(self, query, limit=3): """Returns the limit=int(amount) of gifs based on the query -> see giphy docs""" return r.get('/giphy/search?limit={}&query={}'.format(limit, query))
def trending_gifs(self, limit=3): """Returns the trending gifs based on limit=int(amount)""" return r.get('/giphy/trending?limit={}'.format(limit))
def dislike(self): """Dislikes (swipes left) the user""" resp = r.get('/pass/{}'.format(self.id)) return 'passed'
def super_like(self): """Super likes (swipes up) the user""" resp = r.get('/like/{}/super'.format(self.id), {}) return resp['match']
def like(self): """Likes (swipes right) the user""" resp = r.get('/like/{}'.format(self.id)) return resp['match']