コード例 #1
0
    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
コード例 #2
0
    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
コード例 #3
0
 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
コード例 #4
0
 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
コード例 #5
0
 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
コード例 #6
0
    def put_client(client_id):
        try:
            client = Client.json_parse(request.json)
            client.client_id = int(client_id)
            client = ClientServices.update_client(client, client_id)

            return jsonify(client.json()), 200
        except UserNotFound as e:
            return "No such client exists", 404
コード例 #7
0
 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
コード例 #8
0
    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
コード例 #9
0
 def test_get_all_clients(self):
     assert cs.all_clients()
コード例 #10
0
 def test_get_client(self):
     assert cs.get_client_by_id(1)
コード例 #11
0
 def get_all_clients():
     return jsonify(ClientServices.all_clients()), 200
コード例 #12
0
 def del_client(client_id):
     if ClientServices.delete_client(int(client_id)):
         return '', 204
     else:
         return "No such client exists", 404
コード例 #13
0
    def post_client():
        client = Client.json_parse(request.json)
        client = ClientServices.create_client(client)

        return jsonify(client.json()), 201