@labdigital/commercetools-mock 2.33.0 → 2.33.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.js CHANGED
@@ -2581,6 +2581,29 @@ var CartUpdateHandler = class extends AbstractUpdateHandler {
2581
2581
  this._storage
2582
2582
  );
2583
2583
  }
2584
+ setBillingAddressCustomType(context, resource, custom) {
2585
+ if (!resource.billingAddress) {
2586
+ throw new Error("Resource has no billing address");
2587
+ }
2588
+ if (!custom.type) {
2589
+ resource.billingAddress.custom = void 0;
2590
+ return;
2591
+ }
2592
+ const resolvedType = this._storage.getByResourceIdentifier(
2593
+ context.projectKey,
2594
+ custom.type
2595
+ );
2596
+ if (!resolvedType) {
2597
+ throw new Error(`Type ${custom.type} not found`);
2598
+ }
2599
+ resource.billingAddress.custom = {
2600
+ type: {
2601
+ typeId: "type",
2602
+ id: resolvedType.id
2603
+ },
2604
+ fields: custom.fields || {}
2605
+ };
2606
+ }
2584
2607
  setCountry(context, resource, { country }) {
2585
2608
  resource.country = country;
2586
2609
  }
@@ -2693,6 +2716,29 @@ var CartUpdateHandler = class extends AbstractUpdateHandler {
2693
2716
  custom
2694
2717
  };
2695
2718
  }
2719
+ setShippingAddressCustomType(context, resource, custom) {
2720
+ if (!resource.shippingAddress) {
2721
+ throw new Error("Resource has no shipping address");
2722
+ }
2723
+ if (!custom.type) {
2724
+ resource.shippingAddress.custom = void 0;
2725
+ return;
2726
+ }
2727
+ const resolvedType = this._storage.getByResourceIdentifier(
2728
+ context.projectKey,
2729
+ custom.type
2730
+ );
2731
+ if (!resolvedType) {
2732
+ throw new Error(`Type ${custom.type} not found`);
2733
+ }
2734
+ resource.shippingAddress.custom = {
2735
+ type: {
2736
+ typeId: "type",
2737
+ id: resolvedType.id
2738
+ },
2739
+ fields: custom.fields || {}
2740
+ };
2741
+ }
2696
2742
  setShippingMethod(context, resource, { shippingMethod }) {
2697
2743
  if (shippingMethod) {
2698
2744
  const method = this._storage.getByResourceIdentifier(