@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.cjs CHANGED
@@ -3334,6 +3334,58 @@ var CustomObjectRepository = class extends AbstractResourceRepository {
3334
3334
 
3335
3335
  // src/repositories/customer/actions.ts
3336
3336
  var CustomerUpdateHandler = class extends AbstractUpdateHandler {
3337
+ addAddress(_context, resource, { address }) {
3338
+ resource.addresses.push({
3339
+ ...address,
3340
+ id: address.id ?? generateRandomString(5)
3341
+ });
3342
+ }
3343
+ addBillingAddressId(_context, resource, { addressId, addressKey }) {
3344
+ const address = resource.addresses.find((a) => {
3345
+ if (a.id != void 0 && addressId != void 0 && a.id === addressId) {
3346
+ return true;
3347
+ }
3348
+ return a.key != void 0 && addressKey != void 0 && a.key === addressKey;
3349
+ });
3350
+ if (!address) {
3351
+ throw new CommercetoolsError(
3352
+ {
3353
+ code: "InvalidInput",
3354
+ message: `Address with id '${addressId}' or key '${addressKey}' not found.`
3355
+ },
3356
+ 400
3357
+ );
3358
+ }
3359
+ const billingAddressId = String(address.id);
3360
+ if (resource.billingAddressIds?.length) {
3361
+ resource.billingAddressIds.push(billingAddressId);
3362
+ } else if (address) {
3363
+ resource.billingAddressIds = [billingAddressId];
3364
+ }
3365
+ }
3366
+ addShippingAddressId(_context, resource, { addressId, addressKey }) {
3367
+ const address = resource.addresses.find((a) => {
3368
+ if (a.id != void 0 && addressId != void 0 && a.id === addressId) {
3369
+ return true;
3370
+ }
3371
+ return a.key != void 0 && addressKey != void 0 && a.key === addressKey;
3372
+ });
3373
+ if (!address) {
3374
+ throw new CommercetoolsError(
3375
+ {
3376
+ code: "InvalidInput",
3377
+ message: `Address with id '${addressId}' or key '${addressKey}' not found.`
3378
+ },
3379
+ 400
3380
+ );
3381
+ }
3382
+ const shippingAddressId = String(address.id);
3383
+ if (resource.shippingAddressIds?.length) {
3384
+ resource.shippingAddressIds.push(shippingAddressId);
3385
+ } else if (address) {
3386
+ resource.shippingAddressIds = [shippingAddressId];
3387
+ }
3388
+ }
3337
3389
  changeAddress(context, resource, { addressId, addressKey, address }) {
3338
3390
  const oldAddressIndex = resource.addresses.findIndex((a) => {
3339
3391
  if (a.id != void 0 && addressId != void 0 && a.id === addressId) {