@labdigital/commercetools-mock 2.65.0 → 2.65.1

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.mjs CHANGED
@@ -1649,11 +1649,30 @@ var OrderUpdateHandler = class extends AbstractUpdateHandler {
1649
1649
  };
1650
1650
  }
1651
1651
  }
1652
+ addDelivery(context, resource, { action, items, ...deliveryDraft }) {
1653
+ if (!resource.shippingInfo) throw new Error("Resource has no shipping info");
1654
+ if (!items) throw new Error("Delivery items are required");
1655
+ if (!resource.shippingInfo.deliveries) resource.shippingInfo.deliveries = [];
1656
+ const parcels = deliveryDraft.parcels?.map((p) => ({
1657
+ ...getBaseResourceProperties(),
1658
+ ...p,
1659
+ custom: createCustomFields(p.custom, context.projectKey, this._storage)
1660
+ })) ?? [];
1661
+ const delivery = {
1662
+ ...getBaseResourceProperties(),
1663
+ ...deliveryDraft,
1664
+ parcels,
1665
+ items,
1666
+ address: createAddress(deliveryDraft.address, context.projectKey, this._storage),
1667
+ custom: createCustomFields(deliveryDraft.custom, context.projectKey, this._storage)
1668
+ };
1669
+ resource.shippingInfo.deliveries.push(delivery);
1670
+ }
1652
1671
  setDeliveryCustomField(context, resource, { deliveryId, name, value }) {
1653
1672
  if (!resource.shippingInfo) throw new Error("Resource has no shipping info");
1654
1673
  for (const delivery of resource.shippingInfo.deliveries || []) if (delivery.id === deliveryId && delivery.custom?.fields) delivery.custom.fields[name] = value;
1655
1674
  }
1656
- setLineItemCustomField(context, resource, { lineItemId, lineItemKey, name, value, action }) {
1675
+ setLineItemCustomField(context, resource, { lineItemId, lineItemKey, name, value }) {
1657
1676
  const lineItem = resource.lineItems.find((x) => lineItemId && x.id === lineItemId || lineItemKey && x.key === lineItemKey);
1658
1677
  if (!lineItem) throw new CommercetoolsError({
1659
1678
  code: "General",