@eagleeye-solutions/integration-events-common
Version:
Eagle Eye CDP connector common functionality
43 lines • 1.81 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getServiceTriggerEventData = getServiceTriggerEventData;
const atomic_operations_1 = require("./atomic-operations");
/**
* Returns data extracted from a SERVICE.TRIGGER event.
*
* @param event
* @returns
*/
function getServiceTriggerEventData(event) {
const eventData = {
awardedCoupons: [],
};
for (const op of event.atomicOperations) {
if ((0, atomic_operations_1.isWalletAccountTransactionEntityCreatePoints)(op)) {
eventData.points =
(0, atomic_operations_1.getPointsAttributesFromWalletAccountTransactionEntity)(op);
}
else if ((0, atomic_operations_1.isTierMembershipEntityUpdate)(op)) {
eventData.tier = (0, atomic_operations_1.getTierAttributesFromTierMembershipEntity)(op);
}
else if ((0, atomic_operations_1.isWalletAccountTransactionEntityRedeemBehavioralAction)(op)) {
eventData.awardedPoints =
(0, atomic_operations_1.getBehavioralActionAttributesFromWalletAccountTransactionEntity)(op);
}
else if ((0, atomic_operations_1.isWalletAccountTransactionEntityCreateEcoupon)(op)) {
const coupon = (0, atomic_operations_1.getCouponAttributesFromWalletAccountTransactionEntity)(op);
eventData.awardedCoupons.push({
accountId: coupon.accountId,
campaignId: coupon.campaignId,
type: coupon.type,
clientType: coupon.clientType,
state: coupon.state,
status: coupon.status,
dateStart: coupon.dateStart,
dateEnd: coupon.dateEnd,
});
}
}
return eventData;
}
//# sourceMappingURL=service-trigger.js.map