UNPKG

@eagleeye-solutions/integration-events-common

Version:
36 lines 2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getPointsAttributesFromWalletTransactionEntityUpdateSpendVoid = getPointsAttributesFromWalletTransactionEntityUpdateSpendVoid; exports.getTransactionAttributesFromWalletTransactionEntityUpdateSpendVoid = getTransactionAttributesFromWalletTransactionEntityUpdateSpendVoid; const common_1 = require("./common"); function getPointsAttributesFromWalletTransactionEntityUpdateSpendVoid(entity) { const balanceAfter = entity.objectValue.basket?.summary?.spendAdjudicationResults?.balanceAfter .current || 0; const pointsValue = entity.objectValue.basket?.summary?.spendAdjudicationResults?.pointsValue || 0; return { pointsBalance: balanceAfter + pointsValue, }; } function getTransactionAttributesFromWalletTransactionEntityUpdateSpendVoid(entity, eeAirOutboundEvent) { const transactionAttributes = {}; transactionAttributes.transactionReference = entity.objectValue.reference; const balanceAfter = entity.objectValue.basket?.summary?.spendAdjudicationResults?.balanceAfter .current || 0; const pointsValue = entity.objectValue.basket?.summary?.spendAdjudicationResults?.pointsValue || 0; const pointsSpent = entity.objectValue.basket?.summary?.results?.points.spend || 0; transactionAttributes.pointsSpent = pointsSpent; transactionAttributes.pointsBalance = balanceAfter + pointsValue; const storeLocation = (0, common_1.getStoreLocationAttributes)(entity); if (storeLocation) { transactionAttributes.storeLocation = storeLocation; } const spendRequestBody = typeof eeAirOutboundEvent.request.body === 'string' ? JSON.parse(eeAirOutboundEvent.request.body) : eeAirOutboundEvent.request.body; transactionAttributes.originalTransactionReference = spendRequestBody.parentWalletTransactionReference; return transactionAttributes; } //# sourceMappingURL=update-spend-void.js.map