-
-
Notifications
You must be signed in to change notification settings - Fork 109
API Specification for Cart
Summary:
Returns the shopping session (the cart info).
Description:
This API receives a JSON object containing a shoppingSessionId. Returns the shopping session (the cart info).
Parameter | In | Type | Required | Description |
---|---|---|---|---|
shoppingSessionId | body | string | true | The identifier of the cart. |
Request Example:
POST /cart/items/
{
"id": "fddfgd-fdgdfgdfh-hdfhdfh-436346dfhd-hdfhdf",
"itemId": "463463gfd-436fdhtgery3-hdhgdfghdgh46-hdhdghd"
}
200 OK
If the client sends an valid request, a 200 OK should be returned.
Parameter | Type | Required | Description |
---|---|---|---|
shoppingSessionId | string | true | The identifier of the cart. |
itemsAmount | integer | true | The amount of items. |
totalPrice | number | true | The total price of all items. |
itemList | item list | true | The item list. |
itemId | integer | true | The identifier of the item |
productsAmount | integer | true | The amount of products. |
totalProductsPrice | integer | true | The total products price. |
product | integer | true | The product description |
Response Example:
{
"shoppingSessionId": "fddfgd-fdgdfgdfh-hdfhdfh-436346dfhd-hdfhdf",
"itemsAmount": "2",
"totalPrice": "3200",
"itemList": [
{
"itemId": "463463gfd-436fdhtgery3-hdhgdfghdgh46-hdhdghd",
"productsAmount": "2",
"totalProductsPrice": "1500",
"product": {
"productData" : "productData"
}
},
{
"itemId": "463463gfd-436fdhtgery3-hdhgdfghdgh46-hdhdghd",
"productsAmount": "3",
"totalProductsPrice": "1700",
"product": {
"productData" : "productData"
}
}
]
}
400 Bad Request
If the client sends an invalid request, a 400 Bad Request should be returned.
Parameter | Type | Required | Description |
---|---|---|---|
error | string | true | Error message indicating the reason for the failure. |
Response Examples:
{
"error": "The 'shoppingSessionId' cannot be empty."
}
{
"error": "Invalid 'shoppingSessionId' value."
}
Summary:
Returns 200 OK as the confirmation of adding a new item to the cart.
Description:
This API receives a JSON object containing a shoppingSessionId and an itemId. Returns 200 OK as the confirmation of adding a new item to the cart.
Parameter | In | Type | Required | Description |
---|---|---|---|---|
shoppingSessionId | body | string | true | The identifier of the cart. |
itemId | body | string | true | The identifier of the item. |
Request Example:
POST /cart/items/
{
"shoppingSessionId": "fddfgd-fdgdfgdfh-hdfhdfh-436346dfhd-hdfhdf",
"itemId": "463463gfd-436fdhtgery3-hdhgdfghdgh46-hdhdghd"
}
200 OK
If the client sends an valid request, a 200 OK should be returned.
400 Bad Request
If the client sends an invalid request, a 400 Bad Request should be returned.
Parameter | Type | Required | Description |
---|---|---|---|
error | string | true | Error message indicating the reason for the failure. |
Response Examples:
{
"error": "The 'shoppingSessionId' cannot be empty."
}
{
"error": "Invalid 'shoppingSessionId' value."
}
{
"error": "The 'itemId' cannot be empty."
}
{
"error": "Invalid 'itemId' value."
}
Summary:
Returns 200 OK as the confirmation of deleting the specified item in the cart.
Description:
This API receives a JSON object containing a shoppingSessionId and an itemList. Returns 200 OK as the confirmation of deleting the given itemList in the cart.
Parameter | In | Type | Required | Description |
---|---|---|---|---|
shoppingSessionId | body | string | true | The identifier of the cart. |
itemList | body | item list | true | The item identifiers list. |
Request Example:
POST /cart/items/
{
"shoppingSessionId": "fddfgd-fdgdfgdfh-hdfhdfh-436346dfhd-hdfhdf",
"itemList": [
{
"itemId": "463463gfd-436fdhtgery3-hdhgdfghdgh46-hdhdghd"
},
{
"itemId": "463463gfd-436fdhtgery3-hdhgdfghdgh46-hdhdghd"
}
]
}
200 OK
If the client sends an valid request, a 200 OK should be returned.
400 Bad Request
If the client sends an invalid request, a 400 Bad Request should be returned.
Parameter | Type | Required | Description |
---|---|---|---|
error | string | true | Error message indicating the reason for the failure. |
Response Examples:
{
"error": "The 'shoppingSessionId' cannot be empty."
}
{
"error": "Invalid 'shoppingSessionId' value."
}
{
"error": "The 'itemList' cannot be empty."
}
{
"error": "Invalid 'itemList' value."
}
Summary:
Returns 200 OK as the confirmation of changing the amount of the specified item products in the cart.
Description:
This API receives a JSON object containing a shoppingSessionId, an itemId and the change of products amount in the item. Returns 200 OK as the confirmation of changing the amount of the specified item products in the cart.
Parameter | In | Type | Required | Description |
---|---|---|---|---|
shoppingSessionId | body | string | true | The identifier of the cart. |
itemId | body | string | true | The identifier of the item. |
change | body | string | true | The amount of the specified item products in the cart. |
Request Example:
POST /cart/items/
{
"shoppingSessionId": "fddfgd-fdgdfgdfh-hdfhdfh-436346dfhd-hdfhdf",
"itemId": "463463gfd-436fdhtgery3-hdhgdfghdgh46-hdhdghd",
"change": "-1"
}
{
"shoppingSessionId": "fddfgd-fdgdfgdfh-hdfhdfh-436346dfhd-hdfhdf",
"itemId": "463463gfd-436fdhtgery3-hdhgdfghdgh46-hdhdghd",
"change": "-7"
}
{
"shoppingSessionId": "fddfgd-fdgdfgdfh-hdfhdfh-436346dfhd-hdfhdf",
"itemId": "463463gfd-436fdhtgery3-hdhgdfghdgh46-hdhdghd",
"change": "+1"
}
{
"shoppingSessionId": "fddfgd-fdgdfgdfh-hdfhdfh-436346dfhd-hdfhdf",
"itemId": "463463gfd-436fdhtgery3-hdhgdfghdgh46-hdhdghd",
"change": "+6"
}
200 OK
If the client sends an valid request, a 200 OK should be returned.
400 Bad Request
If the client sends an invalid request, a 400 Bad Request should be returned.
Parameter | Type | Required | Description |
---|---|---|---|
error | string | true | Error message indicating the reason for the failure. |
Response Examples:
{
"error": "The 'shoppingSessionId' cannot be empty."
}
{
"error": "Invalid 'shoppingSessionId' value."
}
{
"error": "The 'itemId' cannot be empty."
}
{
"error": "Invalid 'itemId' value."
}
public interface CartApi {
/**
* Метод получения покупочной сессии (текущее состояние корзины)
*
* @param getShoppingSessionRequest запрос на получение покупочной сессии (текущее состояние корзины)
* @return покупочная сессия (текущее состояние корзины)
* */
ShoppingSession createReservation(GetShoppingSessionRequest getShoppingSessionRequest);
/**
* Метод добавление нового item в покупочную сессию (в корзины)
*
* @param addNewItemToShoppingSessionRequest запрос на добавление нового item в покупочную сессию (в корзины)
* @return покупочная сессия (текущее состояние корзины)
* */
ShoppingSession addNewItemToShoppingSession(GetShoppingSessionRequest addNewItemToShoppingSessionRequest);
/**
* Метод удаления существующего item в покупочной сессии (в корзине)
*
* @param removeItemFromShoppingSessionRequest запрос на удаления существующего item в покупочной сессии (в корзине)
* @return покупочная сессия (текущее состояние корзины)
* */
ShoppingSession removeItemFromShoppingSession(GetShoppingSessionRequest removeItemFromShoppingSessionRequest);
/**
* Метод изменения количества продуктов в определенном item в покупочной сессии (в корзине)
*
* @param updateProductAmountInShoppingSessionItemRequest запрос на изменение количества продуктов в определенном item в покупочной сессии (в корзине)
* @return покупочная сессия (текущее состояние корзины)
* */
ShoppingSession updateProductAmountInShoppingSessionItem(GetShoppingSessionRequest updateProductAmountInShoppingSessionItemRequest);
}
import java.math.BigDecimal;
import java.util.Collection;
/**
* @shoppingSessionId идентификатор покупочной сессии
* @itemsAmount количество items в определенной покупочной сессии
* @totalPrice сумма всех item вместе взятых в покупочной сессии
* @items все items в определенной покупочной сессии
*/
public record ShoppingSession(String shoppingSessionId,
Integer itemsAmount,
BigDecimal totalPrice,
Collection<Item> items) {}
import java.math.BigDecimal;
/**
* @itemId идентификатор item в определенной покупочной сессии
* @productsAmount количество продуктов в определенном item
* @totalProductsPrice сумма всех продуктов вместе взятых в item
* @products все products в item
*/
public record Item(String itemId,
Integer productsAmount,
BigDecimal totalProductsPrice,
Collection<Product> products) { }