This application is being built to track banks, customers, and the accounts between them.
Fork and clone this repo. Use pipenv install
and pipenv shell
to begin. Be sure to cd server
.
There are no tests so be sure to use the flask shell
and Postman to be certain everything's working correctly!
You have three models:
name
(string): Cannot be null, must be unique
-
first_name
(string): Cannot be null -
last_name
(string): Cannot be null
-
balance
(integer): Cannot be null, cannot be less than 0 -
account_type
(string): Cannot be null
This is a many-to-many relationship.
-
A bank has many accounts and an account belongs to a bank.
-
A customer has many accounts and an account belongs to a customer.
-
A bank has many customers and a customer has many banks through accounts.
Bank --< Account >-- Customer
The foreign keys aren't specified so you'll have to determine where they go.
You can either use the seed.py
to create your seeds or you can seed manually with flask shell
.
Build out these routes:
Returns a list of all customers formatted like so:
[
{
"id": 1,
"first_name": "Chett",
"last_name": "Tiller"
},
{
"id": 2,
"first_name": "Charlie",
"last_name": "Kozey"
}
]
Returns a customer with the matching id. If there is no customer, returns a message that the customer could not be found along with a 404.
Format your customer object like so:
{
"id": 1,
"first_name": "Chett",
"last_name": "Tiller",
"accounts": [
{
"id": 1,
"balance": 100,
"account_type": "checking",
"customer_name": "Chett Tiller",
"bank_name": "Crown Royale"
},
{
"id": 2,
"balance": 30,
"account_type": "savings",
"customer_name": "Chett Tiller",
"bank_name": "Royal Raccoon Bank"
}
]
}
Hint: You'll need to find a way to include the customer accounts in this route. This may involve a method similar to_dict()
Deletes the customer and all associated accounts from the database. Returns 204 if the customer was successfully deleted or 404 and an appropriate message if that customer could not be found.
Returns a list of all banks.
[
{
"id": 1,
"name": "Royal Raccoon Bank"
},
{
"id": 2,
"name": "Bob's Bank",
}
]
Returns a bank with the matching id. If there is no bank, returns a message that the bank could not be found along with a 404.
{
"id": 2,
"name": "Bob's Bank",
}
Creates a new account. The account must belong to a customer and a bank. Return the new account details like so:
{
"id": 3,
"balance": 10000,
"account_type": "checking",
"customer_name": "Charlie Kozey",
"bank_name": "Royal Raccoon Bank"
}
HINT: You might need to create more than one method with the functionality of to_dict
in order to make this work.