Skip to content

Commit c8fd8d0

Browse files
fix: article_add API method validation and types (#93)
Co-authored-by: Sven Eberth <[email protected]>
1 parent 4a995f9 commit c8fd8d0

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

src/viur/shop/modules/api.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def article_add(
5656
article_key, "article_key")
5757
parent_cart_key = self._normalize_external_key(
5858
parent_cart_key, "parent_cart_key")
59-
assert isinstance(quantity, QuantityMode)
59+
assert isinstance(quantity_mode, QuantityMode)
6060
return JsonResponse(self.shop.cart.add_or_update_article(
6161
article_key=article_key,
6262
parent_cart_key=parent_cart_key,

src/viur/shop/modules/cart.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -546,22 +546,22 @@ def cart_remove(
546546

547547
def additional_add_or_update_article(
548548
self,
549-
skel: SkeletonInstance_T[CartNodeSkel],
549+
skel: SkeletonInstance_T[CartItemSkel],
550550
/,
551551
**kwargs,
552-
) -> SkeletonInstance_T[CartNodeSkel]:
552+
) -> SkeletonInstance_T[CartItemSkel]:
553553
"""
554554
Hook method called by :meth:`add_or_update_article` before the skeleton is saved.
555555
556556
This method can be overridden in a subclass to implement additional API fields or
557557
make further modifications to the cart skeleton (`skel`).
558558
By default, it raises an exception if unexpected arguments
559-
(``kwargs``) are provided and returns the unchanged `skel`` object.
559+
(``kwargs``) are provided and returns the unchanged `skel` object.
560560
561-
:param skel: The current instance of the cart skeleton.
561+
:param skel: The current instance of the cart item skeleton.
562562
:param kwargs: Additional optional arguments for extended implementations.
563563
:raises TooManyArgumentsException: If unexpected arguments are passed in ``kwargs``.
564-
:return: The (potentially modified) cart skeleton.
564+
:return: The (potentially modified) cart item skeleton.
565565
"""
566566
if kwargs:
567567
raise e.TooManyArgumentsException(f"{self}.add_or_update_article", *kwargs.keys())
@@ -579,7 +579,7 @@ def additional_cart_add(
579579
This method can be overridden in a subclass to implement additional API fields or
580580
make further modifications to the cart skeleton (`skel`).
581581
By default, it raises an exception if unexpected arguments
582-
(``kwargs``) are provided and returns the unchanged `skel`` object.
582+
(``kwargs``) are provided and returns the unchanged `skel` object.
583583
584584
:param skel: The current instance of the cart skeleton.
585585
:param kwargs: Additional optional arguments for extended implementations.
@@ -602,7 +602,7 @@ def additional_cart_update(
602602
This method can be overridden in a subclass to implement additional API fields or
603603
make further modifications to the cart skeleton (`skel`).
604604
By default, it raises an exception if unexpected arguments
605-
(``kwargs``) are provided and returns the unchanged `skel`` object.
605+
(``kwargs``) are provided and returns the unchanged `skel` object.
606606
607607
:param skel: The current instance of the cart skeleton.
608608
:param kwargs: Additional optional arguments for extended implementations.

src/viur/shop/modules/order.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ def additional_order_add(
520520
This method can be overridden in a subclass to implement additional API fields or
521521
make further modifications to the order skeleton (`skel`).
522522
By default, it raises an exception if unexpected arguments
523-
(``kwargs``) are provided and returns the unchanged `skel`` object.
523+
(``kwargs``) are provided and returns the unchanged `skel` object.
524524
525525
:param skel: The current instance of the order skeleton.
526526
:param kwargs: Additional optional arguments for extended implementations.
@@ -543,7 +543,7 @@ def additional_order_update(
543543
This method can be overridden in a subclass to implement additional API fields or
544544
make further modifications to the order skeleton (`skel`).
545545
By default, it raises an exception if unexpected arguments
546-
(``kwargs``) are provided and returns the unchanged `skel`` object.
546+
(``kwargs``) are provided and returns the unchanged `skel` object.
547547
548548
:param skel: The current instance of the order skeleton.
549549
:param kwargs: Additional optional arguments for extended implementations.

0 commit comments

Comments
 (0)