Skip to content

Commit

Permalink
Update PostmanCollection, Insomina Export was used
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmadabdulnasir committed Jun 21, 2022
1 parent a9b24a2 commit 22fb3aa
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions backend/src/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ def drink_list():
GET /drinks
it should be a public endpoint
it should contain only the drink.short() data representation
returns status code 200 and json {"success": True, "drinks": drinks} where drinks is the list of drinks
returns status code 200 and json
{"success": True, "drinks": drinks} where drinks is the list of drinks
or appropriate status code indicating reason for failure
"""
drinks = Drink.query.all()
Expand All @@ -45,7 +46,8 @@ def drink_list_detail(payload):
GET /drinks-detail
it should require the 'get:drinks-detail' permission
it should contain the drink.long() data representation
returns status code 200 and json {"success": True, "drinks": drinks} where drinks is the list of drinks
returns status code 200 and json
{"success": True, "drinks": drinks} where drinks is the list of drinks
or appropriate status code indicating reason for failure
"""
# Get all the drinks from db
Expand All @@ -62,7 +64,9 @@ def drink_create(payload):
it should create a new row in the drinks table
it should require the 'post:drinks' permission
it should contain the drink.long() data representation
returns status code 200 and json {"success": True, "drinks": drink} where drink an array containing only the newly created drink
returns status code 200 and json
{"success": True, "drinks": drink} where drink an array
containing only the newly created drink
or appropriate status code indicating reason for failure
"""
# Get the body
Expand Down Expand Up @@ -90,8 +94,10 @@ def drink_update(payload, id):
it should update the corresponding row for <id>
it should require the 'patch:drinks' permission
it should contain the drink.long() data representation
returns status code 200 and json {"success": True, "drinks": drink} where drink an array containing only the updated drink
or appropriate status code indicating reason for failure
returns status code 200 and json
{"success": True, "drinks": drink} where drink an array
containing only the updated drink
or appropriate status code indicating reason for failure
"""
# Get the body
body = request.get_json()
Expand All @@ -104,10 +110,8 @@ def drink_update(payload, id):
abort(404)

try:

title = body.get("title")
recipe = body.get("recipe")

# check if we should update title
if title:
drink.title = title
Expand All @@ -134,16 +138,15 @@ def drink_delete(payload, id):
it should respond with a 404 error if <id> is not found
it should delete the corresponding row for <id>
it should require the 'delete:drinks' permission
returns status code 200 and json {"success": True, "delete": id} where id is the id of the deleted record
returns status code 200 and json
{"success": True, "delete": id} where id is the id of the deleted record
or appropriate status code indicating reason for failure
"""
# filter Drink with requested Id
drink = Drink.query.filter(Drink.id == id).one_or_none()

# abort when drink not found
if not drink:
abort(404)

try:
# delete the drink
drink.delete()
Expand Down

0 comments on commit 22fb3aa

Please sign in to comment.