arky-sdk 0.7.9 → 0.7.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -878,6 +878,17 @@ var createEshopApi = (apiConfig) => {
878
878
  };
879
879
 
880
880
  // src/api/booking.ts
881
+ function groupCartToItems(cart) {
882
+ const groups = /* @__PURE__ */ new Map();
883
+ for (const s of cart) {
884
+ const key = `${s.serviceId}:${s.providerId}`;
885
+ if (!groups.has(key)) {
886
+ groups.set(key, { serviceId: s.serviceId, providerId: s.providerId, slots: [] });
887
+ }
888
+ groups.get(key).slots.push({ from: s.from, to: s.to });
889
+ }
890
+ return [...groups.values()];
891
+ }
881
892
  var createBookingApi = (apiConfig) => {
882
893
  let cart = [];
883
894
  return {
@@ -913,12 +924,7 @@ var createBookingApi = (apiConfig) => {
913
924
  async checkout(params, options) {
914
925
  const { businessId, items: paramItems, ...payload } = params || {};
915
926
  const targetBusinessId = businessId || apiConfig.businessId;
916
- const items = paramItems || cart.map((s) => ({
917
- serviceId: s.serviceId,
918
- providerId: s.providerId,
919
- from: s.from,
920
- to: s.to
921
- }));
927
+ const items = paramItems || groupCartToItems(cart);
922
928
  return apiConfig.httpClient.post(
923
929
  `/v1/businesses/${targetBusinessId}/bookings/checkout`,
924
930
  { market: apiConfig.market, ...payload, items },