@eagleeye-solutions/integration-events-common
Version:
Eagle Eye CDP connector common functionality
33 lines • 1.4 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getWalletAccountUpdateEventData = getWalletAccountUpdateEventData;
const atomic_operations_1 = require("./atomic-operations");
/**
* Returns an array of events derived from a WALLET.ACCOUNT.UPDATE event.
*
* @param event
* @param configuration
* @returns
*/
function getWalletAccountUpdateEventData(event) {
let standardSubscriptionAttributes = null;
const entitlements = [];
for (const op of event.atomicOperations) {
if ((0, atomic_operations_1.isWalletAccountTransactionEntityUpdateStandardSubscription)(op)) {
standardSubscriptionAttributes =
(0, atomic_operations_1.getStandardSubscriptionAttributesFromWalletAccountTransactionEntity)(op);
}
else if ((0, atomic_operations_1.isWalletAccountTransactionEntityUpdateEcouponEntitlement)(op)) {
entitlements.push((0, atomic_operations_1.getCouponAttributesFromWalletAccountTransactionEntity)(op));
}
}
if (standardSubscriptionAttributes === null) {
throw new RangeError('WalletAccountTransactionEntity/UPDATE/STANDARD_SUBSCRIPTION not found in WALLET.ACCOUNT.CREATE.PLAN');
}
const eventData = {
account: standardSubscriptionAttributes,
entitlements,
};
return eventData;
}
//# sourceMappingURL=wallet-account-update.js.map