@labdigital/commercetools-mock 2.32.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.cjs +49 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +49 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/repositories/cart/actions.ts +66 -0
- package/src/repositories/order/actions.ts +9 -0
- package/src/services/cart.test.ts +134 -0
- package/src/services/order.test.ts +16 -0
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(
|
|
@@ -4077,6 +4123,9 @@ var OrderUpdateHandler = class extends AbstractUpdateHandler {
|
|
|
4077
4123
|
setOrderNumber(context, resource, { orderNumber }) {
|
|
4078
4124
|
resource.orderNumber = orderNumber;
|
|
4079
4125
|
}
|
|
4126
|
+
setPurchaseOrderNumber(context, resource, { purchaseOrderNumber }) {
|
|
4127
|
+
resource.purchaseOrderNumber = purchaseOrderNumber;
|
|
4128
|
+
}
|
|
4080
4129
|
setShippingAddress(context, resource, { address }) {
|
|
4081
4130
|
resource.shippingAddress = createAddress(
|
|
4082
4131
|
address,
|