Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions service/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def create_accounts():
jsonify(message), status.HTTP_201_CREATED, {"Location": location_url}
)


######################################################################
# LIST ALL ACCOUNTS
######################################################################
Expand All @@ -74,10 +75,10 @@ def list_accounts():
app.logger.info("Returning [%s] accounts", len(account_list))
return jsonify(account_list), status.HTTP_200_OK


######################################################################
# READ AN ACCOUNT
######################################################################

@app.route("/accounts/<int:account_id>", methods=["GET"])
def get_accounts(account_id):
"""
Expand All @@ -89,6 +90,8 @@ def get_accounts(account_id):
if not account:
abort(status.HTTP_404_NOT_FOUND, f"Account with id [{account_id}] could not be found.")
return account.serialize(), status.HTTP_200_OK


######################################################################
# UPDATE AN EXISTING ACCOUNT
######################################################################
Expand All @@ -108,6 +111,8 @@ def update_accounts(account_id):
account.update()

return account.serialize(), status.HTTP_200_OK


######################################################################
# DELETE AN ACCOUNT
######################################################################
Expand All @@ -129,8 +134,6 @@ def delete_accounts(account_id):
######################################################################
# U T I L I T Y F U N C T I O N S
######################################################################


def check_content_type(media_type):
"""Checks that the media type is correct"""
content_type = request.headers.get("Content-Type")
Expand All @@ -140,5 +143,4 @@ def check_content_type(media_type):
abort(
status.HTTP_415_UNSUPPORTED_MEDIA_TYPE,
f"Content-Type must be {media_type}",
)

)
Loading