diff --git a/README b/README index d092a68..71b342a 100644 --- a/README +++ b/README @@ -25,7 +25,7 @@ API Items amount can be added to basket through API by posting to */api/lingo/add-basket-item* endpoint a json payload containing *amount* and/or -*"extra": {"amount": ...}* attribute. +*"extra": {"amount": ...}* attribute or passing *amount* in the query string For example: @@ -34,7 +34,10 @@ For example: "amount": "42.42", "extra": {"amount": "10.42", ...}, ... - } + } + +or + /api/lingo/add-basket-item?amount=10 The "amount" attribute should be float or decimal or a list of floats/decimals. For example: diff --git a/lingo/views.py b/lingo/views.py index 44b3ac8..32f8a60 100644 --- a/lingo/views.py +++ b/lingo/views.py @@ -69,6 +69,7 @@ class AddBasketItemApiView(View): extra = request_body.get('extra', {}) item = BasketItem(amount=0) + item.amount = sum([Decimal(x) for x in request.GET.getlist('amount')]) if request_body.get('amount'): item.amount += self.get_amount(request_body['amount'])