diff --git a/src/backend/docker/docker-compose.override.yml b/src/backend/docker/docker-compose.override.yml index 87ef1b8fe..5c4e90c75 100755 --- a/src/backend/docker/docker-compose.override.yml +++ b/src/backend/docker/docker-compose.override.yml @@ -20,7 +20,7 @@ services: - CHECKOUT_TOPIC=checkout - IDENTITY_URL=http://identity-api - AUTH_URL=http://localhost:8080/identity - - BASE_PATH=/basket + - BASE_PATH=/shoppingcart - OTEL_EXPORTER_OTLP_ENDPOINT=otel-collector:4317 payment-api: diff --git a/src/backend/docker/docker-compose.traefik.yml b/src/backend/docker/docker-compose.traefik.yml index ce66f403f..297a40d8d 100644 --- a/src/backend/docker/docker-compose.traefik.yml +++ b/src/backend/docker/docker-compose.traefik.yml @@ -36,7 +36,7 @@ services: cart-api: labels: - "traefik.enable=true" - - "traefik.http.routers.basket.rule=PathPrefix(`/basket/`)" + - "traefik.http.routers.basket.rule=PathPrefix(`/shoppingcart/`)" - "traefik.port=5200" order-api: diff --git a/src/backend/services/cart-api/cmd/api/main.go b/src/backend/services/cart-api/cmd/api/main.go index c6e6b7b6c..5529cf646 100644 --- a/src/backend/services/cart-api/cmd/api/main.go +++ b/src/backend/services/cart-api/cmd/api/main.go @@ -99,12 +99,16 @@ func main() { basketRepository := repositories.NewCartRepository(redisClient) cartHandler := handlers.NewCartHandler(basketRepository) - api := router.Group(basePath + "/api/v1/cart") + apiV1 := router.Group(basePath + "/api/v1") { - api.POST("", handlers.ErrorHandler(cartHandler.Create)) - api.GET(":id", handlers.ErrorHandler(cartHandler.Get)) - api.DELETE(":id", handlers.ErrorHandler(cartHandler.Delete)) - api.PUT(":id/items", handlers.ErrorHandler(cartHandler.UpdateItem)) // updates line item by CartID + cart := apiV1.Group("/cart") + { + cart.POST("", handlers.ErrorHandler(cartHandler.Create)) + cart.GET(":id", handlers.ErrorHandler(cartHandler.Get)) + cart.DELETE(":id", handlers.ErrorHandler(cartHandler.Delete)) + cart.PUT(":id", handlers.ErrorHandler(cartHandler.Update)) + cart.PUT(":id/item", handlers.ErrorHandler(cartHandler.UpdateItem)) // updates line item by CartID + } } // Home page should be redirected to swagger page diff --git a/src/backend/services/cart-api/internal/docs/docs.go b/src/backend/services/cart-api/internal/docs/docs.go index c1dde16e1..7f74a4f0e 100644 --- a/src/backend/services/cart-api/internal/docs/docs.go +++ b/src/backend/services/cart-api/internal/docs/docs.go @@ -24,9 +24,9 @@ const docTemplate = `{ "host": "{{.Host}}", "basePath": "{{.BasePath}}", "paths": { - "/items": { + "/cart": { "post": { - "description": "add by json new CustomerBasket", + "description": "add by json new Cart", "consumes": [ "application/json" ], @@ -34,17 +34,17 @@ const docTemplate = `{ "application/json" ], "tags": [ - "CustomerBasket" + "Cart" ], - "summary": "Add a CustomerBasket", + "summary": "Creates new cart", "parameters": [ { - "description": "Add CustomerBasket", - "name": "CustomerBasket", + "description": "Creates new cart", + "name": "cart", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/models.Cart" + "$ref": "#/definitions/models.CreateCartReq" } } ], @@ -76,9 +76,9 @@ const docTemplate = `{ } } }, - "/items/{id}": { + "/cart/{id}": { "get": { - "description": "Get CustomerBasket by ID", + "description": "Get Cart by ID", "consumes": [ "application/json" ], @@ -86,13 +86,13 @@ const docTemplate = `{ "application/json" ], "tags": [ - "CustomerBasket" + "Cart" ], - "summary": "Gets a CustomerBasket", + "summary": "Gets a Cart", "parameters": [ { "type": "string", - "description": "CustomerBasket ID", + "description": "Cart ID", "name": "id", "in": "path", "required": true @@ -119,8 +119,65 @@ const docTemplate = `{ } } }, + "put": { + "description": "update by json cart", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Cart" + ], + "summary": "Update cart", + "parameters": [ + { + "type": "string", + "description": "Cart ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Updates cart", + "name": "update_cart", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/models.CreateCartReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/models.Cart" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/models.HTTPError" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/models.HTTPError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/models.HTTPError" + } + } + } + }, "delete": { - "description": "Deletes CustomerBasket by ID", + "description": "Deletes Cart by ID", "consumes": [ "application/json" ], @@ -128,13 +185,13 @@ const docTemplate = `{ "application/json" ], "tags": [ - "CustomerBasket" + "Cart" ], - "summary": "Deletes a CustomerBasket", + "summary": "Deletes a Cart", "parameters": [ { "type": "string", - "description": "CustomerBasket ID", + "description": "Cart ID", "name": "id", "in": "path", "required": true @@ -164,6 +221,65 @@ const docTemplate = `{ } } } + }, + "/cart/{id}/item": { + "put": { + "description": "update by json new line item", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Cart" + ], + "summary": "Update or add a line item", + "parameters": [ + { + "type": "string", + "description": "Cart ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Update line item", + "name": "lineItem", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/models.LineItem" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/models.Cart" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/models.HTTPError" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/models.HTTPError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/models.HTTPError" + } + } + } + } } }, "definitions": { @@ -205,6 +321,20 @@ const docTemplate = `{ } } }, + "models.CreateCartReq": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/models.LineItem" + } + }, + "user_id": { + "type": "string" + } + } + }, "models.HTTPError": { "type": "object", "properties": { diff --git a/src/backend/services/cart-api/internal/docs/swagger.json b/src/backend/services/cart-api/internal/docs/swagger.json index d7c860a2e..57e61bff6 100644 --- a/src/backend/services/cart-api/internal/docs/swagger.json +++ b/src/backend/services/cart-api/internal/docs/swagger.json @@ -16,9 +16,9 @@ "version": "1.0" }, "paths": { - "/items": { + "/cart": { "post": { - "description": "add by json new CustomerBasket", + "description": "add by json new Cart", "consumes": [ "application/json" ], @@ -26,17 +26,17 @@ "application/json" ], "tags": [ - "CustomerBasket" + "Cart" ], - "summary": "Add a CustomerBasket", + "summary": "Creates new cart", "parameters": [ { - "description": "Add CustomerBasket", - "name": "CustomerBasket", + "description": "Creates new cart", + "name": "cart", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/models.Cart" + "$ref": "#/definitions/models.CreateCartReq" } } ], @@ -68,9 +68,9 @@ } } }, - "/items/{id}": { + "/cart/{id}": { "get": { - "description": "Get CustomerBasket by ID", + "description": "Get Cart by ID", "consumes": [ "application/json" ], @@ -78,13 +78,13 @@ "application/json" ], "tags": [ - "CustomerBasket" + "Cart" ], - "summary": "Gets a CustomerBasket", + "summary": "Gets a Cart", "parameters": [ { "type": "string", - "description": "CustomerBasket ID", + "description": "Cart ID", "name": "id", "in": "path", "required": true @@ -111,8 +111,65 @@ } } }, + "put": { + "description": "update by json cart", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Cart" + ], + "summary": "Update cart", + "parameters": [ + { + "type": "string", + "description": "Cart ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Updates cart", + "name": "update_cart", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/models.CreateCartReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/models.Cart" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/models.HTTPError" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/models.HTTPError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/models.HTTPError" + } + } + } + }, "delete": { - "description": "Deletes CustomerBasket by ID", + "description": "Deletes Cart by ID", "consumes": [ "application/json" ], @@ -120,13 +177,13 @@ "application/json" ], "tags": [ - "CustomerBasket" + "Cart" ], - "summary": "Deletes a CustomerBasket", + "summary": "Deletes a Cart", "parameters": [ { "type": "string", - "description": "CustomerBasket ID", + "description": "Cart ID", "name": "id", "in": "path", "required": true @@ -156,6 +213,65 @@ } } } + }, + "/cart/{id}/item": { + "put": { + "description": "update by json new line item", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Cart" + ], + "summary": "Update or add a line item", + "parameters": [ + { + "type": "string", + "description": "Cart ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Update line item", + "name": "lineItem", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/models.LineItem" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/models.Cart" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/models.HTTPError" + } + }, + "404": { + "description": "Not Found", + "schema": { + "$ref": "#/definitions/models.HTTPError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/models.HTTPError" + } + } + } + } } }, "definitions": { @@ -197,6 +313,20 @@ } } }, + "models.CreateCartReq": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/models.LineItem" + } + }, + "user_id": { + "type": "string" + } + } + }, "models.HTTPError": { "type": "object", "properties": { diff --git a/src/backend/services/cart-api/internal/docs/swagger.yaml b/src/backend/services/cart-api/internal/docs/swagger.yaml index 4fcbec27d..bc4979b64 100644 --- a/src/backend/services/cart-api/internal/docs/swagger.yaml +++ b/src/backend/services/cart-api/internal/docs/swagger.yaml @@ -24,6 +24,15 @@ definitions: user_id: type: string type: object + models.CreateCartReq: + properties: + items: + items: + $ref: '#/definitions/models.LineItem' + type: array + user_id: + type: string + type: object models.HTTPError: properties: code: @@ -64,18 +73,18 @@ info: title: Cart API version: "1.0" paths: - /items: + /cart: post: consumes: - application/json - description: add by json new CustomerBasket + description: add by json new Cart parameters: - - description: Add CustomerBasket + - description: Creates new cart in: body - name: CustomerBasket + name: cart required: true schema: - $ref: '#/definitions/models.Cart' + $ref: '#/definitions/models.CreateCartReq' produces: - application/json responses: @@ -95,16 +104,16 @@ paths: description: Internal Server Error schema: $ref: '#/definitions/models.HTTPError' - summary: Add a CustomerBasket + summary: Creates new cart tags: - - CustomerBasket - /items/{id}: + - Cart + /cart/{id}: delete: consumes: - application/json - description: Deletes CustomerBasket by ID + description: Deletes Cart by ID parameters: - - description: CustomerBasket ID + - description: Cart ID in: path name: id required: true @@ -126,15 +135,15 @@ paths: description: Internal Server Error schema: $ref: '#/definitions/models.HTTPError' - summary: Deletes a CustomerBasket + summary: Deletes a Cart tags: - - CustomerBasket + - Cart get: consumes: - application/json - description: Get CustomerBasket by ID + description: Get Cart by ID parameters: - - description: CustomerBasket ID + - description: Cart ID in: path name: id required: true @@ -154,7 +163,84 @@ paths: description: Not Found schema: $ref: '#/definitions/models.HTTPError' - summary: Gets a CustomerBasket + summary: Gets a Cart + tags: + - Cart + put: + consumes: + - application/json + description: update by json cart + parameters: + - description: Cart ID + in: path + name: id + required: true + type: string + - description: Updates cart + in: body + name: update_cart + required: true + schema: + $ref: '#/definitions/models.CreateCartReq' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/models.Cart' + "400": + description: Bad Request + schema: + $ref: '#/definitions/models.HTTPError' + "404": + description: Not Found + schema: + $ref: '#/definitions/models.HTTPError' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/models.HTTPError' + summary: Update cart + tags: + - Cart + /cart/{id}/item: + put: + consumes: + - application/json + description: update by json new line item + parameters: + - description: Cart ID + in: path + name: id + required: true + type: string + - description: Update line item + in: body + name: lineItem + required: true + schema: + $ref: '#/definitions/models.LineItem' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/models.Cart' + "400": + description: Bad Request + schema: + $ref: '#/definitions/models.HTTPError' + "404": + description: Not Found + schema: + $ref: '#/definitions/models.HTTPError' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/models.HTTPError' + summary: Update or add a line item tags: - - CustomerBasket + - Cart swagger: "2.0" diff --git a/src/backend/services/cart-api/internal/handlers/cart_handler.go b/src/backend/services/cart-api/internal/handlers/cart_handler.go index 5c7ec14fb..492cb655a 100644 --- a/src/backend/services/cart-api/internal/handlers/cart_handler.go +++ b/src/backend/services/cart-api/internal/handlers/cart_handler.go @@ -14,7 +14,7 @@ type GetCreateDeleter interface { Get(ctx context.Context, cartID string) (*models.Cart, error) Update(ctx context.Context, cart *models.Cart) error Delete(ctx context.Context, id string) error - UpdateItem(ctx context.Context, cartID string, item models.LineItem) error + SetItem(ctx context.Context, cartID string, item models.LineItem) error } // CartHandler is router initializer for http @@ -22,7 +22,7 @@ type CartHandler struct { repository GetCreateDeleter } -// NewCartHandler creates new instance of BasketController with BasketRepository +// NewCartHandler creates new instance of CartHandler with CartRepository func NewCartHandler(r GetCreateDeleter) *CartHandler { return &CartHandler{repository: r} } @@ -43,29 +43,30 @@ func ErrorHandler(f func(c *gin.Context) error) gin.HandlerFunc { // Create go doc // -// @Summary Add a CustomerBasket -// @Description add by json new CustomerBasket -// @Tags CustomerBasket +// @Summary Creates new cart +// @Description add by json new Cart +// @Tags Cart // @Accept json // @Produce json -// @Param CustomerBasket body models.Cart true "Add CustomerBasket" +// @Param cart body models.CreateCartReq true "Creates new cart" // @Success 200 {object} models.Cart // @Failure 400 {object} models.HTTPError // @Failure 404 {object} models.HTTPError // @Failure 500 {object} models.HTTPError -// @Router /items [post] +// @Router /cart [post] func (h *CartHandler) Create(c *gin.Context) error { - var entity models.Cart - if err := c.BindJSON(&entity); err != nil { + var req models.CreateCartReq + if err := c.BindJSON(&req); err != nil { return models.NewHTTPError(http.StatusBadRequest, err) } - err := h.repository.Update(c.Request.Context(), &entity) + cart := models.MapCreateCartReqToCart(req) + err := h.repository.Update(c.Request.Context(), cart) if err != nil { return models.NewHTTPError(http.StatusBadRequest, err) } - result, err := h.repository.Get(c.Request.Context(), entity.ID.String()) + result, err := h.repository.Get(c.Request.Context(), cart.ID.String()) if err != nil { return models.NewHTTPError(http.StatusBadRequest, err) } @@ -74,27 +75,38 @@ func (h *CartHandler) Create(c *gin.Context) error { return nil } -// Update line item doc +// Update cart doc // -// @Summary Update a line item -// @Description update by json new line item -// @Tags CustomerBasket +// @Summary Update cart +// @Description update by json cart +// @Tags Cart // @Accept json // @Produce json -// @Param id path string true "Cart ID" -// @Param lineItem body models.LineItem true "Update line item" -// @Success 200 {object} models.Cart -// @Failure 400 {object} models.HTTPError -// @Failure 404 {object} models.HTTPError -// @Failure 500 {object} models.HTTPError - -func (h *CartHandler) UpdateItem(c *gin.Context) error { +// @Param id path string true "Cart ID" +// @Param update_cart body models.CreateCartReq true "Updates cart" +// @Success 200 {object} models.Cart +// @Failure 400 {object} models.HTTPError +// @Failure 404 {object} models.HTTPError +// @Failure 500 {object} models.HTTPError +// @Router /cart/{id} [put] +func (h *CartHandler) Update(c *gin.Context) error { cartID := c.Param("id") - var entity models.LineItem + var entity models.CreateCartReq if err := c.BindJSON(&entity); err != nil { return models.NewHTTPError(http.StatusBadRequest, err) } - if err := h.repository.UpdateItem(c.Request.Context(), cartID, entity); err != nil { + + _, err := h.repository.Get(c.Request.Context(), cartID) + if err != nil { + if errors.Is(err, repositories.ErrCartNotFound) { + return models.NewHTTPError(http.StatusNotFound, errors.Wrap(err, "cartID: "+cartID)) + } + return models.NewHTTPError(http.StatusInternalServerError, err) + } + + cart := models.MapCreateCartReqToCart(entity) + + if err := h.repository.Update(c.Request.Context(), cart); err != nil { return models.NewHTTPError(http.StatusInternalServerError, err) } return nil @@ -102,23 +114,23 @@ func (h *CartHandler) UpdateItem(c *gin.Context) error { // Get go doc // -// @Summary Gets a CustomerBasket -// @Description Get CustomerBasket by ID -// @Tags CustomerBasket +// @Summary Gets a Cart +// @Description Get Cart by ID +// @Tags Cart // @Accept json // @Produce json -// @Param id path string true "CustomerBasket ID" +// @Param id path string true "Cart ID" // @Success 200 {object} models.Cart // @Failure 400 {object} models.HTTPError // @Failure 404 {object} models.HTTPError -// @Router /items/{id} [get] +// @Router /cart/{id} [get] func (h *CartHandler) Get(c *gin.Context) error { id := c.Param("id") result, err := h.repository.Get(c.Request.Context(), id) if err != nil { if errors.Is(err, repositories.ErrCartNotFound) { - return models.NewHTTPError(http.StatusNotFound, errors.Wrap(err, "itemID: "+id)) + return models.NewHTTPError(http.StatusNotFound, errors.Wrap(err, "cartID: "+id)) } return models.NewHTTPError(http.StatusInternalServerError, err) } @@ -128,17 +140,17 @@ func (h *CartHandler) Get(c *gin.Context) error { // Delete go doc // -// @Summary Deletes a CustomerBasket -// @Description Deletes CustomerBasket by ID -// @Tags CustomerBasket +// @Summary Deletes a Cart +// @Description Deletes Cart by ID +// @Tags Cart // @Accept json // @Produce json -// @Param id path string true "CustomerBasket ID" +// @Param id path string true "Cart ID" // @Success 200 "" // @Failure 400 {object} models.HTTPError // @Failure 404 {object} models.HTTPError // @Failure 500 {object} models.HTTPError -// @Router /items/{id} [delete] +// @Router /cart/{id} [delete] func (h *CartHandler) Delete(c *gin.Context) error { id := c.Param("id") @@ -149,3 +161,29 @@ func (h *CartHandler) Delete(c *gin.Context) error { c.Status(http.StatusOK) return nil } + +// Update line item doc +// +// @Summary Update or add a line item +// @Description update by json new line item +// @Tags Cart +// @Accept json +// @Produce json +// @Param id path string true "Cart ID" +// @Param lineItem body models.LineItem true "Update line item" +// @Success 200 {object} models.Cart +// @Failure 400 {object} models.HTTPError +// @Failure 404 {object} models.HTTPError +// @Failure 500 {object} models.HTTPError +// @Router /cart/{id}/item [put] +func (h *CartHandler) UpdateItem(c *gin.Context) error { + cartID := c.Param("id") + var entity models.LineItem + if err := c.BindJSON(&entity); err != nil { + return models.NewHTTPError(http.StatusBadRequest, err) + } + if err := h.repository.SetItem(c.Request.Context(), cartID, entity); err != nil { + return models.NewHTTPError(http.StatusInternalServerError, err) + } + return nil +} diff --git a/src/backend/services/cart-api/internal/handlers/cart_handler_test.go b/src/backend/services/cart-api/internal/handlers/cart_handler_test.go index ea1cf8ec7..6e9117b4a 100644 --- a/src/backend/services/cart-api/internal/handlers/cart_handler_test.go +++ b/src/backend/services/cart-api/internal/handlers/cart_handler_test.go @@ -32,8 +32,8 @@ type CartRepositoryMock struct { mock.Mock } -// UpdateItem implements GetCreateDeleter. -func (r *CartRepositoryMock) UpdateItem(ctx context.Context, cartID string, item models.LineItem) error { +// SetItem implements GetCreateDeleter. +func (r *CartRepositoryMock) SetItem(ctx context.Context, cartID string, item models.LineItem) error { args := r.Called(ctx, cartID, item) return args.Error(0) } diff --git a/src/backend/services/cart-api/internal/models/cart.go b/src/backend/services/cart-api/internal/models/cart.go index 55fdcfde4..8c04dbaf4 100644 --- a/src/backend/services/cart-api/internal/models/cart.go +++ b/src/backend/services/cart-api/internal/models/cart.go @@ -2,6 +2,26 @@ package models import "github.com/google/uuid" +type CreateCartReq struct { + LineItems *[]LineItem `json:"items,omitempty"` + UserID *string `json:"user_id,omitempty"` +} + +func MapCreateCartReqToCart(req CreateCartReq) *Cart { + if req.LineItems == nil { + req.LineItems = &[]LineItem{} + } + if req.UserID == nil || *req.UserID == "" { + *req.UserID = "anonymous" + } + cart := &Cart{ + LineItems: *req.LineItems, + UserID: req.UserID, + ID: uuid.New(), + } + return cart +} + // LineItem type LineItem struct { ItemID int `json:"item_id"` @@ -15,14 +35,15 @@ type LineItem struct { // Cart type Cart struct { - ID uuid.UUID `json:"id"` - LineItems []LineItem `json:"items"` - UserID *string `json:"user_id"` - Total float32 `json:"total"` - Discount float32 `json:"discount"` - Tax float32 `json:"tax"` - Shipping float32 `json:"shipping"` - ShippingMethod string `json:"shipping_method"` - Currency string `json:"currency"` - Status string `json:"status"` + ID uuid.UUID `json:"id"` + LineItems []LineItem `json:"items"` + Total float32 `json:"total"` + + UserID *string `json:"user_id,omitempty"` + Discount *float32 `json:"discount,omitempty"` + Tax *float32 `json:"tax,omitempty"` + Shipping *float32 `json:"shipping,omitempty"` + ShippingMethod *string `json:"shipping_method,omitempty"` + Currency *string `json:"currency,omitempty"` + Status *string `json:"status,omitempty"` } diff --git a/src/backend/services/cart-api/internal/repositories/redis_repository.go b/src/backend/services/cart-api/internal/repositories/redis_repository.go index 0b50ccc2c..e53a06761 100644 --- a/src/backend/services/cart-api/internal/repositories/redis_repository.go +++ b/src/backend/services/cart-api/internal/repositories/redis_repository.go @@ -44,7 +44,7 @@ func (r *CartRepository) Get(ctx context.Context, cartID string) (*models.Cart, return &result, err } -func (r *CartRepository) UpdateItem(ctx context.Context, cartID string, item models.LineItem) error { +func (r *CartRepository) SetItem(ctx context.Context, cartID string, item models.LineItem) error { // Fetch the existing cart existingCart, err := r.Get(ctx, cartID) if err != nil {