@capillarytech/creatives-library 8.0.136-beta.3 → 8.0.136-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/utils/transformerUtils.js +20 -7
package/package.json
CHANGED
|
@@ -283,8 +283,6 @@ const transformLinePayload = (lineData, options = {}) => {
|
|
|
283
283
|
|
|
284
284
|
// Get base payload structure
|
|
285
285
|
const payload = createBasePayload(LINE, loyaltyMetaData);
|
|
286
|
-
|
|
287
|
-
// Add LINE-specific properties
|
|
288
286
|
payload.centralCommsPayload.lineMessageContent = {
|
|
289
287
|
channel: LINE,
|
|
290
288
|
accountId: lineData?.accountId || 0,
|
|
@@ -293,7 +291,6 @@ const transformLinePayload = (lineData, options = {}) => {
|
|
|
293
291
|
...lineData,
|
|
294
292
|
};
|
|
295
293
|
payload.centralCommsPayload.lineDeliverySettings = lineDeliverySettings || {};
|
|
296
|
-
|
|
297
294
|
return payload;
|
|
298
295
|
};
|
|
299
296
|
|
|
@@ -307,11 +304,8 @@ const transformViberPayload = (viberData, options = {}) => {
|
|
|
307
304
|
const { loyaltyMetaData = {} } = options;
|
|
308
305
|
const { transformedMessageDetails = {} } = loyaltyMetaData;
|
|
309
306
|
const { viberDeliverySettings = {} } = transformedMessageDetails;
|
|
310
|
-
|
|
311
307
|
// Get base payload structure
|
|
312
308
|
const payload = createBasePayload(VIBER, loyaltyMetaData);
|
|
313
|
-
|
|
314
|
-
// Add VIBER-specific properties
|
|
315
309
|
payload.centralCommsPayload.viberMessageContent = {
|
|
316
310
|
channel: VIBER,
|
|
317
311
|
accountId: viberData?.accountId || 0,
|
|
@@ -320,12 +314,13 @@ const transformViberPayload = (viberData, options = {}) => {
|
|
|
320
314
|
...viberData,
|
|
321
315
|
};
|
|
322
316
|
payload.centralCommsPayload.viberDeliverySettings = viberDeliverySettings || {};
|
|
323
|
-
|
|
324
317
|
return payload;
|
|
325
318
|
};
|
|
326
319
|
|
|
327
320
|
// Checks if the template has changed
|
|
328
321
|
export const getTemplateDiffState = (channel, oldData, newData) => {
|
|
322
|
+
// Original switch implementation (commented out)
|
|
323
|
+
/*
|
|
329
324
|
switch (channel.toUpperCase()) {
|
|
330
325
|
case SMS:
|
|
331
326
|
return checkSmsDiff(oldData, newData);
|
|
@@ -348,6 +343,24 @@ export const getTemplateDiffState = (channel, oldData, newData) => {
|
|
|
348
343
|
default:
|
|
349
344
|
return false;
|
|
350
345
|
}
|
|
346
|
+
*/
|
|
347
|
+
|
|
348
|
+
// Refactored implementation using object mapping
|
|
349
|
+
const diffHandlers = {
|
|
350
|
+
[SMS]: checkSmsDiff,
|
|
351
|
+
[EMAIL]: checkEmailDiff,
|
|
352
|
+
[MOBILE_PUSH]: checkPushDiff,
|
|
353
|
+
[PUSH]: checkPushDiff,
|
|
354
|
+
[WHATSAPP]: checkWhatsappDiff,
|
|
355
|
+
[ZALO]: checkZaloDiff,
|
|
356
|
+
[LINE]: checkLineDiff,
|
|
357
|
+
[VIBER]: checkViberDiff,
|
|
358
|
+
// TODO: RCS is currently not supported by the CCS - BE. We need to make changes in future as per the BE changes.
|
|
359
|
+
// [RCS]: checkRcsDiff,
|
|
360
|
+
};
|
|
361
|
+
|
|
362
|
+
const handler = diffHandlers[channel?.toUpperCase()];
|
|
363
|
+
return handler ? handler(oldData, newData) : false;
|
|
351
364
|
};
|
|
352
365
|
/**
|
|
353
366
|
* Checks differences between old and new SMS data
|