All files / src/app/core/models/basket-merge basket-merge.helper.ts

100% Statements 2/2
96.15% Branches 25/26
100% Functions 1/1
100% Lines 2/2

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32              28x     3x                                          
import { BasketData } from 'ish-core/models/basket/basket.interface';
 
import { BasketMergeData } from './basket-merge.interface';
 
/**
 * class is required to transform BasketMergeData into BasketData format
 */
export class BasketMergeHelper {
  // eslint-disable-next-line complexity
  static transform(basketMergeData: BasketMergeData): BasketData {
    return {
      data: basketMergeData.included
        ? basketMergeData.included.targetBasket[basketMergeData.data.targetBasket] || undefined
        : undefined,
      included: basketMergeData.included
        ? {
            invoiceToAddress: basketMergeData.included.targetBasket_invoiceToAddress || undefined,
            lineItems: basketMergeData.included.targetBasket_lineItems || undefined,
            discounts: basketMergeData.included.targetBasket_discounts || undefined,
            lineItems_discounts: basketMergeData.included.targetBasket_lineItems_discounts || undefined,
            lineItems_warranty: basketMergeData.included.targetBasket_lineItems_warranty || undefined,
            commonShipToAddress: basketMergeData.included.targetBasket_commonShipToAddress || undefined,
            commonShippingMethod: basketMergeData.included.targetBasket_commonShippingMethod || undefined,
            payments: basketMergeData.included.targetBasket_payments || undefined,
            payments_paymentMethod: basketMergeData.included.targetBasket_payments_paymentMethod || undefined,
            payments_paymentInstrument: basketMergeData.included.targetBasket_payments_paymentInstrument || undefined,
          }
        : undefined,
    };
  }
}