def send_notification(self, username, title, body, data): request_body = { "username": username, "notification": { "title": title, "body": body, "data": data } } response = requests.post(f'{self.url}/notifications', json=request_body) return make_flask_response(response)
def get_user_videos(self, user_id, search): query = "?user_id={}&visibility=public".format(user_id) for k,v in search.items(): query+= "&{}={}".format(k,v) response = requests.get('{}/videos{}'.format(self.url, query)) return make_flask_response(response)
def get_videos(self): response = requests.get(self.url + '/videos?is_blocked=false') return make_flask_response(response)
def add_video(self, data): response = requests.post(self.url + '/videos', json=data) return make_flask_response(response)
def validate_code(self, code, email): response = requests.get( f'{self.url}/users/password?code={code}&email={email}', headers=self._headers()) return make_flask_response(response)
def change_password(self, body, code, email): response = requests.post( f'{self.url}/users/password?code={code}&email={email}', json=body, headers=self._headers()) return make_flask_response(response)
def delete_user_profile(self, user_id): response = requests.delete(f'{self.url}/users/{user_id}', headers=self._headers()) return make_flask_response(response)
def oauth_login(self, body): response = requests.post(self.url + '/users/oauth2login', json=body, headers=self._headers()) return make_flask_response(response)
def get_user_profile(self, user_id_request): response = requests.get(f'{self.url}/users/{user_id_request}', headers=self._headers()) return make_flask_response(response)
def edit_user_profile(self, user_id, body): response = requests.put(f'{self.url}/users/{user_id}', json=body, headers=self._headers()) return make_flask_response(response)
def authorize_user(self, token): headers = {'access-token': token} response = requests.post(f'{self.url}/users/authorize', headers=self._headers(headers)) return make_flask_response(response)
def get_users(self): response = requests.get(f'{self.url}/users', headers=self._headers()) return make_flask_response(response)
def register(self, body): response = requests.post(f'{self.url}/users/register', json=body, headers=self._headers()) return make_flask_response(response)
def delete_video(self, video_id): response = requests.delete('{}/videos/{}'.format(self.url, video_id)) return make_flask_response(response)
def send_mail(self, body): response = requests.post(f'{self.url}/users/reset_password', json=body, headers=self._headers()) return make_flask_response(response)
def edit_video(self, video_id, data): response = requests.put('{}/videos/{}'.format(self.url, video_id), json=data) return make_flask_response(response)
def login(self, body): response = requests.post(f'{self.url}/users/login', json=body, headers=self._headers()) return make_flask_response(response)