Skip to content

Commit

Permalink
fix: article_add API method validation and types (#93)
Browse files Browse the repository at this point in the history
Co-authored-by: Sven Eberth <[email protected]>
  • Loading branch information
KadirBalku and sveneberth authored Feb 15, 2025
1 parent 4a995f9 commit c8fd8d0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/viur/shop/modules/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def article_add(
article_key, "article_key")
parent_cart_key = self._normalize_external_key(
parent_cart_key, "parent_cart_key")
assert isinstance(quantity, QuantityMode)
assert isinstance(quantity_mode, QuantityMode)
return JsonResponse(self.shop.cart.add_or_update_article(
article_key=article_key,
parent_cart_key=parent_cart_key,
Expand Down
14 changes: 7 additions & 7 deletions src/viur/shop/modules/cart.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,22 +546,22 @@ def cart_remove(

def additional_add_or_update_article(
self,
skel: SkeletonInstance_T[CartNodeSkel],
skel: SkeletonInstance_T[CartItemSkel],
/,
**kwargs,
) -> SkeletonInstance_T[CartNodeSkel]:
) -> SkeletonInstance_T[CartItemSkel]:
"""
Hook method called by :meth:`add_or_update_article` before the skeleton is saved.
This method can be overridden in a subclass to implement additional API fields or
make further modifications to the cart skeleton (`skel`).
By default, it raises an exception if unexpected arguments
(``kwargs``) are provided and returns the unchanged `skel`` object.
(``kwargs``) are provided and returns the unchanged `skel` object.
:param skel: The current instance of the cart skeleton.
:param skel: The current instance of the cart item skeleton.
:param kwargs: Additional optional arguments for extended implementations.
:raises TooManyArgumentsException: If unexpected arguments are passed in ``kwargs``.
:return: The (potentially modified) cart skeleton.
:return: The (potentially modified) cart item skeleton.
"""
if kwargs:
raise e.TooManyArgumentsException(f"{self}.add_or_update_article", *kwargs.keys())
Expand All @@ -579,7 +579,7 @@ def additional_cart_add(
This method can be overridden in a subclass to implement additional API fields or
make further modifications to the cart skeleton (`skel`).
By default, it raises an exception if unexpected arguments
(``kwargs``) are provided and returns the unchanged `skel`` object.
(``kwargs``) are provided and returns the unchanged `skel` object.
:param skel: The current instance of the cart skeleton.
:param kwargs: Additional optional arguments for extended implementations.
Expand All @@ -602,7 +602,7 @@ def additional_cart_update(
This method can be overridden in a subclass to implement additional API fields or
make further modifications to the cart skeleton (`skel`).
By default, it raises an exception if unexpected arguments
(``kwargs``) are provided and returns the unchanged `skel`` object.
(``kwargs``) are provided and returns the unchanged `skel` object.
:param skel: The current instance of the cart skeleton.
:param kwargs: Additional optional arguments for extended implementations.
Expand Down
4 changes: 2 additions & 2 deletions src/viur/shop/modules/order.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ def additional_order_add(
This method can be overridden in a subclass to implement additional API fields or
make further modifications to the order skeleton (`skel`).
By default, it raises an exception if unexpected arguments
(``kwargs``) are provided and returns the unchanged `skel`` object.
(``kwargs``) are provided and returns the unchanged `skel` object.
:param skel: The current instance of the order skeleton.
:param kwargs: Additional optional arguments for extended implementations.
Expand All @@ -543,7 +543,7 @@ def additional_order_update(
This method can be overridden in a subclass to implement additional API fields or
make further modifications to the order skeleton (`skel`).
By default, it raises an exception if unexpected arguments
(``kwargs``) are provided and returns the unchanged `skel`` object.
(``kwargs``) are provided and returns the unchanged `skel` object.
:param skel: The current instance of the order skeleton.
:param kwargs: Additional optional arguments for extended implementations.
Expand Down

0 comments on commit c8fd8d0

Please sign in to comment.