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