UNPKG

@eagleeye-solutions/integration-events-common

Version:
42 lines 2.3 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.getPosConnectWalletSpendVoidEventData = getPosConnectWalletSpendVoidEventData; const __1 = require(".."); const atomic_operations_1 = require("./atomic-operations"); const atomic_operations_2 = __importDefault(require("./atomic-operations")); /** * Returns an array of events derived from a POSCONNECT.WALLET.SETTLE event. * * @param event * @param configuration * @returns */ async function getPosConnectWalletSpendVoidEventData(event, opts) { const posConnectWalletSpendVoidEventData = { voided: true, }; for (const op of event.atomicOperations) { if ((0, atomic_operations_1.isWalletAccountTransactionEntityUpdatePoints)(op)) { posConnectWalletSpendVoidEventData.points = atomic_operations_2.default.WalletAccountTransactionEntity.UpdateEarnPoints.getPointsAttributes(op); } else if ((0, atomic_operations_1.isWalletTransactionEntityUpdateSpendVoided)(op)) { posConnectWalletSpendVoidEventData.transaction = atomic_operations_2.default.WalletTransactionEntity.UpdateSpendVoid.getTransactionAttributes(op, event); posConnectWalletSpendVoidEventData.tier = op.objectValue.basket?.summary?.results?.tiers?.points ?? 0; // original transaction reference is not available in the event from AIR, so // we have to fetch it directly from AIR itself. const airClient = new __1.EeAirClient(opts.connectorConfig.credentials.clientId, opts.connectorConfig.credentials.secret, opts.connectorConfig['domains'], opts.logger); const parentWalletTransaction = await airClient.getWalletTransactionById(op.objectValue.walletId, op.objectValue.parentWalletTransactionId); const originalTransactionReference = parentWalletTransaction.reference; posConnectWalletSpendVoidEventData.transaction.originalTransactionReference = originalTransactionReference; } } return posConnectWalletSpendVoidEventData; } //# sourceMappingURL=posconnect-wallet-spend-void.js.map