Package dev.ucomprotocol.spi
Interface CartAdapter
public interface CartAdapter
Adapter interface for shopping cart operations.
Implement this interface to connect to a commerce platform's cart functionality.
-
Method Summary
Modifier and TypeMethodDescriptionAdds an item to the cart.createCart(String customerId) Creates a new cart for a customer.Retrieves a cart by its ID.removeFromCart(String cartId, String itemId) Removes an item from the cart.updateItemQuantity(String cartId, String itemId, int quantity) Updates the quantity of an item in the cart.
-
Method Details
-
getCart
Retrieves a cart by its ID.- Parameters:
cartId- the unique identifier of the cart- Returns:
- the requested cart, or null if not found
-
createCart
Creates a new cart for a customer.- Parameters:
customerId- the unique identifier of the customer (optional)- Returns:
- the newly created cart
-
addToCart
Adds an item to the cart.- Parameters:
cartId- the unique identifier of the cartproductId- the unique identifier of the product to addquantity- the quantity of the product to add- Returns:
- the updated cart
-
removeFromCart
Removes an item from the cart.- Parameters:
cartId- the unique identifier of the cartitemId- the unique identifier of the item to remove- Returns:
- the updated cart
-
updateItemQuantity
Updates the quantity of an item in the cart.- Parameters:
cartId- the unique identifier of the cartitemId- the unique identifier of the item to updatequantity- the new quantity- Returns:
- the updated cart
-