UNPKG

@eagleeye-solutions/integration-events-common

Version:
43 lines 2.08 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getWalletAccountCreateCampaignEventData = getWalletAccountCreateCampaignEventData; const atomic_operations_1 = require("./atomic-operations"); /** * Returns an array of events derived from a WALLET.ACCOUNT.CREATE.SCHEME event. * * @param event * @param configuration * @returns */ function getWalletAccountCreateCampaignEventData(event) { const eventData = { coupons: [], continuityAccounts: [], questAccounts: [], stampCards: [], }; for (const op of event.atomicOperations) { if ((0, atomic_operations_1.isWalletAccountTransactionEntityCreateEcoupon)(op)) { const baseCoupon = (0, atomic_operations_1.getCouponAttributesFromWalletAccountTransactionEntity)(op); const account = op.objectValue?.account; const relationships = account?.relationships; // Include relationships block when present so connectors can flatten OBJECTIVE_OF const couponWithRelationships = relationships ? { ...baseCoupon, relationships } : baseCoupon; // Push, allowing extra field via any eventData.coupons.push(couponWithRelationships); } else if ((0, atomic_operations_1.isWalletAccountTransactionEntityCreateContinuity)(op)) { eventData.continuityAccounts.push((0, atomic_operations_1.getContinuityAttributesFromWalletAccountTransactionEntity)(op)); } else if ((0, atomic_operations_1.isWalletAccountTransactionEntityCreateQuest)(op)) { eventData.questAccounts.push((0, atomic_operations_1.getQuestAttributesFromWalletAccountTransactionEntity)(op)); } else if ((0, atomic_operations_1.isWalletAccountTransactionEntityCreateStampCard)(op)) { eventData.stampCards.push((0, atomic_operations_1.getStampCardAttributesFromWalletAccountTransactionEntity)(op)); } } return eventData; } //# sourceMappingURL=wallet-account-create-campaign.js.map