def post_account(client_id): if ClientServices.get_client_by_id(client_id): account = Account.json_parse(request.json) account = AccountServices.create_account(account) return jsonify(account.json()), 201
def get_all_accounts(client_id): try: if ClientServices.get_client_by_id(client_id): return jsonify(AccountServices.all_accounts(client_id)), 200 except UserNotFound as e: return "No such client exists", 404
def del_account(account_id, client_id): try: if ClientServices.get_client_by_id(client_id): AccountServices.get_account_by_id(account_id, client_id) AccountServices.delete_account(int(account_id), client_id) return '', 204 except UserNotFound: return "No such account or client exits", 404
def get_account_balance_range(client_id): if ClientServices.get_client_by_id(client_id): balance = request.args["balance"] print(balance) accounts = AccountServices.get_account_balance_range(float(balance), client_id) return jsonify(accounts) else: return UserNotFound("No such client exists"), 404
def get_account(account_id, client_id): try: if ClientServices.get_client_by_id(client_id): account = AccountServices.get_account_by_id(int(account_id), client_id) return jsonify(account.json()), 200 except ValueError as e: return "Not a valid ID", 400 except UserNotFound: return "No such account or client exists", 404
def get_client(client_id): try: client = ClientServices.get_client_by_id(client_id) if client: return jsonify(client.json()), 200 except ValueError as e: return "Not a valid ID", 400 except UserNotFound as r: return "No such client exists", 404
def put_account(account_id, client_id): try: if ClientServices.get_client_by_id(client_id): AccountServices.get_account_by_id(account_id, client_id) account = Account.json_parse(request.json) account.account_id = int(account_id) account = AccountServices.update_account(account, client_id) return jsonify(account.json()), 200 except UserNotFound: return "No such account or client exits", 404
def test_get_client(self): assert cs.get_client_by_id(1)