From 28589dd7d8ffffccf7d48db0e2d227f558e3ea7a Mon Sep 17 00:00:00 2001 From: Theo Brigitte Date: Wed, 4 Dec 2024 17:00:44 +0100 Subject: [PATCH] Add kimsufi.RemoveItemConfiguration, rename kimsufi.ConfigureItem to kimsufi.AddItemConfiguration --- pkg/kimsufi/order.go | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/pkg/kimsufi/order.go b/pkg/kimsufi/order.go index 1ca8f78..319e897 100644 --- a/pkg/kimsufi/order.go +++ b/pkg/kimsufi/order.go @@ -132,21 +132,24 @@ func (s *Service) GetItemRequiredConfiguration(cartID string, itemID int) ([]kim } // ConfigureItem configures an item in the cart with the given configurations. -func (s *Service) ConfigureItem(cartID string, itemID int, configurations []kimsufiorder.ItemConfigurationRequest) ([]kimsufiorder.ItemConfigurationResponse, error) { +func (s *Service) AddItemConfiguration(cartID string, itemID int, configuration kimsufiorder.ItemConfigurationRequest) (*kimsufiorder.ItemConfigurationResponse, error) { u := fmt.Sprintf("/order/cart/%s/item/%d/configuration", cartID, itemID) - var resps []kimsufiorder.ItemConfigurationResponse - for _, c := range configurations { - var resp kimsufiorder.ItemConfigurationResponse - s.logger.Debugf("ConfigureItem request: %+#v", c) - err := s.client.PostUnAuth(u, c, &resp) - if err != nil { - return nil, err - } - resps = append(resps, resp) + var resp kimsufiorder.ItemConfigurationResponse + s.logger.Debugf("ConfigureItem request: %+#v", configuration) + err := s.client.PostUnAuth(u, configuration, &resp) + if err != nil { + return nil, err } - return resps, nil + return &resp, nil +} + +// ConfigureItem configures an item in the cart with the given configurations. +func (s *Service) RemoveItemConfiguration(cartID string, itemID, configurationID int) error { + u := fmt.Sprintf("/order/cart/%s/item/%d/configuration/%d", cartID, itemID, configurationID) + + return s.client.DeleteUnAuth(u, nil) } // AssignCart assigns the cart to the user's account.