def get(self, user_id: str) -> Any: try: user_id_in_int = validate_path_parameter(user_id) return ( marshal(UsersDAL.get_user(user_id_in_int), user_output_fields), HTTPStatus.OK, ) except (ValidationException, UsersDALException) as e: return marshal({'message': e}, error_fields), HTTPStatus.BAD_REQUEST
def get(self, currency_id: str) -> Any: request.get_json() try: currency_id_in_int: int = validate_path_parameter(currency_id) return ( marshal( CurrenciesDAL.get_currency_by_id(currency_id_in_int), currency_output_fields, ), HTTPStatus.OK, ) except (ValidationException, CurrenciesDALException) as e: return marshal({'message': e}, error_fields), HTTPStatus.BAD_REQUEST
def post(self, user_id: str) -> Any: try: validated_json = validate_request_json(request.data, currency_input_fields) user_id_in_int = validate_path_parameter(user_id) return ( marshal( UsersDAL.make_operation_with_currency( user_id_in_int, **validated_json ), currency_output_fields, ), HTTPStatus.CREATED, ) except (ValidationException, UsersDALException) as e: return marshal({'message': e}, error_fields), HTTPStatus.BAD_REQUEST
def get(self, user_id: str) -> Any: try: validated_params: Dict[str, RequestParam] = validate_request_params( dict( operation_type=RequestParam(OperationType), size=RequestParam(int), page=RequestParam(int), ), request.values, ) user_id_in_int = validate_path_parameter(user_id) return UsersDAL.get_user_operations_history( user_id_in_int, **validated_params # type: ignore ) except (ValidationException, PaginationError, UsersDALException) as e: abort(HTTPStatus.BAD_REQUEST, e)
def get(self) -> Any: try: user_id = request.args.get('user_id') user_name = request.args.get('user_name') if not user_id and not user_name or user_id and user_name: raise ValidationException() if user_id: user_id_in_int = validate_path_parameter(user_id) return ( marshal(UsersDAL.get_user_by_id(user_id_in_int), user_output_fields), HTTPStatus.OK, ) else: return marshal(UsersDAL.get_user_by_name(user_name), user_output_fields), HTTPStatus.OK except (ValidationException, UsersDALException) as e: return marshal({'message': e}, error_fields), HTTPStatus.BAD_REQUEST
def get(self, currency_id: str): # type: ignore try: currency_id_in_int: int = validate_path_parameter(currency_id) return CurrenciesDAL.get_currency_history(currency_id_in_int) except (ValidationException, CurrenciesDALException) as e: abort(HTTPStatus.BAD_REQUEST, e)
def get(self, user_id: str) -> Any: try: user_id_int = validate_path_parameter(user_id) return UsersDAL.get_user_currencies(user_id_int) except (UsersDALException, ValidationException) as e: return marshal({'message': e}, error_fields), HTTPStatus.BAD_REQUEST