-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added API for Cart #31
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #31 +/- ##
=======================================
Coverage 96.53% 96.53%
=======================================
Files 18 18
Lines 520 520
=======================================
Hits 502 502
Misses 18 18 ☔ View full report in Codecov by Sentry. |
PCP/server/src/server.py
Outdated
@@ -47,6 +49,9 @@ | |||
api.add_resource(Prices, '/prices') | |||
api.add_resource(UserFavorites, '/user_favorites') | |||
api.add_resource(UserFavoritesById, '/user_favorites/<int:user_id>') | |||
api.add_resource(Cart, '/cart/<int:user_id>') | |||
api.add_resource(AddToCart, '/add-to-cart/<int:user_id>/<int:product_id>/<int:quantity>') | |||
api.add_resource(RemoveFromCart, '/remove-from-cart/<int:user_id>/<int:product_id>') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please do not make a new api for remove it should be in a PUT request to delete it !! not in POST !!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same for add too
return jsonify({"error": str(e)}), 500 | ||
|
||
|
||
class AddToCart(Resource): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should be get , post and put in one class u don't have to make two class over here please fix it
def post(self, user_id, product_id, quantity): | ||
"""Adds a new item to the shopping cart or updates the quantity if it already exists.""" | ||
try: | ||
result = add_item_to_cart(user_id, product_id, quantity) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does it takes session_key as a input !! as I have explained it previously that user can only send the session_key and u guys have to put the code which validates the user based on the session_key and with that it stores the product_id in that user_id !!
and also please resolve the conflicts from ur branch only !!do not change anything in main |
Quality Gate passedIssues Measures |
api.add_resource(AddToCart, '/add-to-cart/<int:user_id>/<int:product_id>/<int:quantity>') | ||
api.add_resource(RemoveFromCart, '/remove-from-cart/<int:user_id>/<int:product_id>') | ||
api.add_resource(AddToCart, '/addtocart/<int:user_id>/<int:product_id>/<int:quantity>') | ||
api.add_resource(RemoveFromCart, '/removefromcart/<int:user_id>/<int:product_id>') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please DOnt make two API for Remove and Add I will put a PUT Request !! instead so do that
No description provided.