Skip to content

Commit

Permalink
change coupon verify response
Browse files Browse the repository at this point in the history
  • Loading branch information
shaheenhyderk committed Feb 14, 2024
1 parent 1cbe9b4 commit 00058c6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions api/dashboard/coupon/coupon_view.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from rest_framework.views import APIView
from utils.response import CustomResponse
from db.user import UserCouponLink
from rest_framework.response import Response


class CouponApi(APIView):
def post(self, request):
if coupon_code := request.data.get('data'):
if UserCouponLink.objects.filter(coupon=coupon_code).exists():
return CustomResponse(general_message="Coupon is valid").get_success_response()
return CustomResponse(general_message="Coupon is invalid").get_failure_response()
return CustomResponse(general_message="Coupon code is required").get_failure_response()
return Response(data={"discount_type": "Percentage", "discount_value": 100})
return Response(data={"discount_type": "Percentage", "discount_value": 0})
return Response(data={"discount_type": "Percentage", "discount_value": 0})

0 comments on commit 00058c6

Please sign in to comment.