示例#1
0
 def wrapper(*args, **kwargs):
     try:
         return route_func(*args, **kwargs)
     except (IncorrectParameterException, ValueError) as e:
         # ValueError for bad UUID.
         logger.warning(str(e))
         return form_response(400, False, description=dict(error=str(e)))
     except ClosedBankAccountExeption as e:
         logger.info(str(e))
         return form_response(403, False, description=dict(error=str(e)))
     except UUIDNotFoundException as e:
         logger.info(str(e))
         return form_response(404, False, description=dict(error=str(e)))
     except NotEnoughMoney as e:
         logger.info(str(e))
         return form_response(406, False, description=dict(error=str(e)))
     except Exception as e:
         logger.error(str(e))
         return form_response(500, False, description=dict(error=str(e)))
示例#2
0
def status():
    logger.debug('Status was called.')
    json_data = JSONData(request.data)
    balance, status = get_status(json_data.uuid)
    return form_response(200, True, json_data.uuid,
                         addition=dict(balance=balance, status=status))
示例#3
0
def subtract():
    logger.debug('Subtract was called.')
    json_data = JSONData(request.data)
    subtract_sum(json_data.uuid, json_data.value)
    return form_response(200, True, json_data.uuid)
示例#4
0
def add():
    logger.debug('Add was called.')
    json_data = JSONData(request.data)
    add_sum(json_data.uuid, json_data.value)
    return form_response(200, True, json_data.uuid)
示例#5
0
def ping():
    logger.debug('Ping was called.')
    return form_response(200, True)