@labdigital/commercetools-mock 2.31.2 → 2.32.0

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
@@ -3297,6 +3297,58 @@ var CustomObjectRepository = class extends AbstractResourceRepository {
3297
3297
 
3298
3298
  // src/repositories/customer/actions.ts
3299
3299
  var CustomerUpdateHandler = class extends AbstractUpdateHandler {
3300
+ addAddress(_context, resource, { address }) {
3301
+ resource.addresses.push({
3302
+ ...address,
3303
+ id: address.id ?? generateRandomString(5)
3304
+ });
3305
+ }
3306
+ addBillingAddressId(_context, resource, { addressId, addressKey }) {
3307
+ const address = resource.addresses.find((a) => {
3308
+ if (a.id != void 0 && addressId != void 0 && a.id === addressId) {
3309
+ return true;
3310
+ }
3311
+ return a.key != void 0 && addressKey != void 0 && a.key === addressKey;
3312
+ });
3313
+ if (!address) {
3314
+ throw new CommercetoolsError(
3315
+ {
3316
+ code: "InvalidInput",
3317
+ message: `Address with id '${addressId}' or key '${addressKey}' not found.`
3318
+ },
3319
+ 400
3320
+ );
3321
+ }
3322
+ const billingAddressId = String(address.id);
3323
+ if (resource.billingAddressIds?.length) {
3324
+ resource.billingAddressIds.push(billingAddressId);
3325
+ } else if (address) {
3326
+ resource.billingAddressIds = [billingAddressId];
3327
+ }
3328
+ }
3329
+ addShippingAddressId(_context, resource, { addressId, addressKey }) {
3330
+ const address = resource.addresses.find((a) => {
3331
+ if (a.id != void 0 && addressId != void 0 && a.id === addressId) {
3332
+ return true;
3333
+ }
3334
+ return a.key != void 0 && addressKey != void 0 && a.key === addressKey;
3335
+ });
3336
+ if (!address) {
3337
+ throw new CommercetoolsError(
3338
+ {
3339
+ code: "InvalidInput",
3340
+ message: `Address with id '${addressId}' or key '${addressKey}' not found.`
3341
+ },
3342
+ 400
3343
+ );
3344
+ }
3345
+ const shippingAddressId = String(address.id);
3346
+ if (resource.shippingAddressIds?.length) {
3347
+ resource.shippingAddressIds.push(shippingAddressId);
3348
+ } else if (address) {
3349
+ resource.shippingAddressIds = [shippingAddressId];
3350
+ }
3351
+ }
3300
3352
  changeAddress(context, resource, { addressId, addressKey, address }) {
3301
3353
  const oldAddressIndex = resource.addresses.findIndex((a) => {
3302
3354
  if (a.id != void 0 && addressId != void 0 && a.id === addressId) {