tango-app-api-payment-subscription 3.0.48-dev → 3.0.50-dev

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tango-app-api-payment-subscription",
3
- "version": "3.0.48-dev",
3
+ "version": "3.0.50-dev",
4
4
  "description": "paymentSubscription",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -26,7 +26,7 @@
26
26
  "nodemon": "^3.1.0",
27
27
  "swagger-ui-express": "^5.0.0",
28
28
  "tango-api-schema": "^2.0.103",
29
- "tango-app-api-middleware": "^1.0.75-dev",
29
+ "tango-app-api-middleware": "^1.0.72-test",
30
30
  "winston": "^3.12.0",
31
31
  "winston-daily-rotate-file": "^5.0.0"
32
32
  },
@@ -42,8 +42,8 @@ export const addBilling = async ( req, res ) => {
42
42
  userName: req.user?.userName,
43
43
  email: req.user?.email,
44
44
  date: new Date(),
45
- logType: 'billing',
46
- logSubType: 'billingInfo Updated',
45
+ logType: 'subscription',
46
+ logSubType: 'billingInfoUpdated',
47
47
  changes: [ 'Billing Address', 'Gst Number' ],
48
48
  eventType: 'update',
49
49
  };
@@ -425,10 +425,11 @@ export const updateSubscription = async ( req, res ) => {
425
425
  userName: req.user?.userName,
426
426
  email: req.user?.email,
427
427
  date: new Date(),
428
- logType: 'billing',
429
- logSubType: 'Trial Request',
430
- changes: [ 'Name', 'Description', 'Category' ],
431
- eventType: 'insert',
428
+ logType: 'subscription',
429
+ logSubType: 'trialRequest',
430
+ changes: [ `${convertTitleCase( item.name )} Trial Request` ],
431
+ eventType: 'create',
432
+ timestamp: new Date(),
432
433
  };
433
434
  insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
434
435
  }
@@ -446,22 +447,39 @@ export const updateSubscription = async ( req, res ) => {
446
447
  clientId: requestBody.clientId,
447
448
  clientNotification: false,
448
449
  adminNotification: true,
449
- logSubType: 'Your subscription is now active! Get ready to maximize your instore sales potential with the Tangoeye suite',
450
- category: 'Brand Activity Log',
451
- features: 'Subscription',
452
- // title: 'Subscribed',
450
+ title: 'Subscription',
451
+ description: 'Your subscription is now active! Get ready to maximize your instore sales potential with the Tangoeye suite',
453
452
  alertCta: [],
454
453
  markasRead: false,
455
- logType: 'Subscribed',
454
+ logType: 'subscription',
455
+ logSubType: 'subscription',
456
456
  showPushNotification: true,
457
- changes: [ 'Plan Details', 'Price', 'Price Type' ],
458
- eventType: 'update',
457
+ changes: [ `${convertTitleCase( item.name )} subscribed` ],
458
+ eventType: '',
459
459
  date: new Date(),
460
460
  };
461
461
  insertOpenSearchData( appConfig.opensearch.activityLog, productObj );
462
462
  } else {
463
463
  clientProducts[existsIndex].status = 'live';
464
464
  clientProducts[existsIndex].subscribedDate = new Date();
465
+ let productObj = {
466
+ userName: req.user?.userName,
467
+ email: req.user?.email,
468
+ clientId: requestBody.clientId,
469
+ clientNotification: false,
470
+ adminNotification: true,
471
+ title: 'Subscription',
472
+ description: 'Your subscription is now active! Get ready to maximize your instore sales potential with the Tangoeye suite',
473
+ alertCta: [],
474
+ markasRead: false,
475
+ logType: 'subscription',
476
+ logSubType: 'subscription',
477
+ showPushNotification: true,
478
+ changes: [ `${convertTitleCase( item.name )} subscribed` ],
479
+ eventType: '',
480
+ date: new Date(),
481
+ };
482
+ insertOpenSearchData( appConfig.opensearch.activityLog, productObj );
465
483
  }
466
484
  subscriptionCount = subscriptionCount + 1;
467
485
  }
@@ -637,10 +655,10 @@ export const unsubscribeProduct = async ( req, res ) => {
637
655
  userName: req.user?.userName,
638
656
  email: req.user?.email,
639
657
  date: new Date(),
640
- logType: 'billing',
641
- logSubType: 'Unsubscribed Request',
642
- changes: [ 'Reason', 'Description', 'Category' ],
643
- eventType: 'insert',
658
+ logType: 'subscription',
659
+ logSubType: 'unsubscribedRequest',
660
+ changes: [ `${req.body.clientId} Unsubscribed Request ` ],
661
+ eventType: 'create',
644
662
  };
645
663
  insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
646
664
 
@@ -671,10 +689,10 @@ export const trialExtendRequest = async ( req, res ) => {
671
689
  userName: req.user?.userName,
672
690
  email: req.user?.email,
673
691
  date: new Date(),
674
- logType: 'billing',
675
- logSubType: 'Trial Extend Request',
676
- changes: [ 'Name', 'Description', 'Category' ],
677
- eventType: 'insert',
692
+ logType: 'subscription',
693
+ logSubType: 'trialExtendRequest',
694
+ changes: [ `${convertTitleCase( req.body.product )} trial Extend Request` ],
695
+ eventType: 'create',
678
696
  };
679
697
  insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
680
698
 
@@ -707,10 +725,10 @@ export const trialRequest = async ( req, res ) => {
707
725
  userName: req.user?.userName,
708
726
  email: req.user?.email,
709
727
  date: new Date(),
710
- logType: 'billing',
711
- logSubType: 'Trial Request',
712
- changes: [ 'Name', 'Description', 'Category' ],
713
- eventType: 'insert',
728
+ logType: 'subscription',
729
+ logSubType: 'trialRequest',
730
+ changes: [ `${convertTitleCase( req.body.product )} trial Request` ],
731
+ eventType: 'create',
714
732
  };
715
733
  insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
716
734
 
@@ -778,8 +796,8 @@ export const updateInvoiceDetails = async ( req, res ) => {
778
796
  userName: req.user?.userName,
779
797
  email: req.user?.email,
780
798
  date: new Date(),
781
- logType: 'billing',
782
- logSubType: 'Update Payment and Invoice Details',
799
+ logType: 'subscription',
800
+ logSubType: 'updatePaymentInvoice',
783
801
  changes: [ 'Pro Rate', 'Payment Type', 'Payment Cycle', 'Currency Type', 'Invoice To', 'Payment Agreement To', 'Invoice On', 'Extend Payment PeriodDays' ],
784
802
  eventType: 'update',
785
803
  };
@@ -887,17 +905,18 @@ export const trialApproval = async ( req, res ) => {
887
905
  clientId: requestData.clientId,
888
906
  clientNotification: false,
889
907
  adminNotification: true,
890
- logSubType: 'Subscription - Your 14 Days free trial has been started',
891
- category: 'Brand Activity Log',
892
- features: 'Subscription',
893
- // title: 'Start Trial',
908
+ logSubType: 'startTrial',
909
+ description: 'Subscription - Your 14 Days free trial has been started',
910
+ // category: 'Brand Activity Log',
911
+ // features: 'Subscription',
912
+ title: 'Subscription',
894
913
  alertCta: [],
895
914
  markasRead: false,
896
915
  logType: 'Start Trial',
897
916
  showPushNotification: true,
898
917
  date: new Date(),
899
- changes: [ 'Plan Details' ],
900
- eventType: 'update',
918
+ changes: [ `${convertTitleCase( requestData.name )} trial started` ],
919
+ eventType: '',
901
920
  };
902
921
  insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
903
922
  let clientProducts = await paymentService.findOne( { clientId: requestData.clientId }, { planDetails: 1 } );
@@ -1021,9 +1040,9 @@ export const trialExtendRequestApproval = async ( req, res ) => {
1021
1040
  requestData.save();
1022
1041
  }
1023
1042
  let userDetails = await userService.findOne( { clientId: req.body.clientId, role: 'superadmin' } );
1043
+ let [ firstWord, secondWord ] = req.body.product.replace( /([a-z])([A-Z])/g, '$1 $2' ).split( ' ' );
1044
+ firstWord = firstWord.charAt( 0 ).toUpperCase() + firstWord.slice( 1 );
1024
1045
  if ( userDetails ) {
1025
- let [ firstWord, secondWord ] = req.body.product.replace( /([a-z])([A-Z])/g, '$1 $2' ).split( ' ' );
1026
- firstWord = firstWord.charAt( 0 ).toUpperCase() + firstWord.slice( 1 );
1027
1046
  let data = {
1028
1047
  userName: userDetails.userName,
1029
1048
  product: firstWord + ' ' + secondWord,
@@ -1049,17 +1068,18 @@ export const trialExtendRequestApproval = async ( req, res ) => {
1049
1068
  clientId: req.body.clientId,
1050
1069
  clientNotification: false,
1051
1070
  adminNotification: true,
1052
- logSubType: `Your Trial has been extended for ${req.body.days} days, explore the service with no extra charge and keep unlocking better insights`,
1053
- category: 'Brand Activity Log',
1054
- features: 'Subscription',
1055
- // title: 'Trial Extend',
1071
+ logSubType: 'trialExtended',
1072
+ description: `Your Trial has been extended for ${req.body.days} days, explore the service with no extra charge and keep unlocking better insights`,
1073
+ // category: 'Brand Activity Log',
1074
+ // features: 'Subscription',
1075
+ title: 'Subscription',
1056
1076
  alertCta: [],
1057
1077
  markasRead: false,
1058
- logType: 'Trial Extend',
1078
+ logType: 'subscription',
1059
1079
  showPushNotification: true,
1060
1080
  date: new Date(),
1061
- changes: [ 'status' ],
1062
- eventType: 'update',
1081
+ changes: [ `${firstWord + ' ' + secondWord} trial Extended` ],
1082
+ eventType: '',
1063
1083
  };
1064
1084
  insertOpenSearchData( appConfig.opensearch.activityLog, notifyObj );
1065
1085
  // const logObj = {
@@ -1110,6 +1130,18 @@ export const productSubscribe = async ( req, res ) => {
1110
1130
  let productList = product.map( ( item ) => item.productName );
1111
1131
  for ( let item of req.body.product ) {
1112
1132
  if ( productList.includes( item.name ) && item.type == 'unsubscribe' ) {
1133
+ let logObj = {
1134
+ userName: req.user?.userName,
1135
+ email: req.user?.email,
1136
+ clientId: clientInfo.clientId,
1137
+ logSubType: 'productUnsubscribe',
1138
+ logType: 'subscription',
1139
+ date: new Date(),
1140
+ changes: [ `${convertTitleCase( item.name )} product unsubscribed` ],
1141
+ eventType: '',
1142
+ timestamp: new Date(),
1143
+ };
1144
+ insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
1113
1145
  await storeService.addremoveElement( { clientId: clientInfo.clientId, product: { $in: item.name } }, { $pull: { product: item.name } } );
1114
1146
  await clientRequestService.deleteOne( { clientId: clientInfo.clientId, status: 'pending', name: item.name } );
1115
1147
  }
@@ -1121,17 +1153,19 @@ export const productSubscribe = async ( req, res ) => {
1121
1153
  clientId: clientInfo.clientId,
1122
1154
  clientNotification: false,
1123
1155
  adminNotification: true,
1124
- logSubType: 'Subscription - Your 14 Days free trial has been started',
1125
- category: 'Brand Activity Log',
1126
- features: 'Subscription',
1127
- // title: 'Start Trial',
1156
+ logSubType: 'startTrial',
1157
+ description: 'Subscription - Your 14 Days free trial has been started',
1158
+ // category: 'Brand Activity Log',
1159
+ // features: 'Subscription',
1160
+ title: 'Start Trial',
1128
1161
  alertCta: [],
1129
1162
  markasRead: false,
1130
- logType: 'Start Trial',
1163
+ logType: 'subscription',
1131
1164
  showPushNotification: true,
1132
1165
  date: new Date(),
1133
- changes: [ 'Plan Details' ],
1134
- eventType: 'update',
1166
+ changes: [ `${convertTitleCase( item.name )} trial started` ],
1167
+ eventType: '',
1168
+ timestamp: new Date(),
1135
1169
  };
1136
1170
  insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
1137
1171
  product.push( {
@@ -1151,17 +1185,18 @@ export const productSubscribe = async ( req, res ) => {
1151
1185
  clientId: clientInfo.clientId,
1152
1186
  clientNotification: false,
1153
1187
  adminNotification: true,
1154
- logSubType: 'Your subscription is now active! Get ready to maximize your instore sales potential with the Tangoeye suite',
1155
- category: 'Brand Activity Log',
1156
- features: 'Subscription',
1157
- // title: 'Subscribed',
1188
+ logSubType: 'productSubscribed',
1189
+ description: 'Your subscription is now active! Get ready to maximize your instore sales potential with the Tangoeye suite',
1190
+ // category: 'Brand Activity Log',
1191
+ // features: 'Subscription',
1192
+ title: 'Subscription',
1158
1193
  alertCta: [],
1159
1194
  markasRead: false,
1160
- logType: 'Subscribed',
1195
+ logType: 'subscription',
1161
1196
  showPushNotification: true,
1162
1197
  date: new Date(),
1163
- changes: [ 'Plan Details' ],
1164
- eventType: 'update',
1198
+ changes: [ `${convertTitleCase( item.name )} prodcut Subscribed` ],
1199
+ eventType: '',
1165
1200
  };
1166
1201
  insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
1167
1202
  product.push( {
@@ -1322,10 +1357,10 @@ export const unsubscribeApproval = async ( req, res ) => {
1322
1357
  userName: req.user?.userName,
1323
1358
  email: req.user?.email,
1324
1359
  date: new Date(),
1325
- logType: 'billing',
1326
- logSubType: 'Unsubscribed Approved',
1327
- changes: [ 'status' ],
1328
- eventType: 'update',
1360
+ logType: 'subscription',
1361
+ logSubType: 'unsubscribedApproved',
1362
+ changes: [ `${requestData.clientId} unsubscribed` ],
1363
+ eventType: '',
1329
1364
  };
1330
1365
  insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
1331
1366
  return res.sendSuccess( 'updated Successfully' );
@@ -1553,6 +1588,18 @@ export const addStoreProduct = async ( req, res ) => {
1553
1588
  storeProduct.push( item.name );
1554
1589
  }
1555
1590
  if ( item.type == 'unsubscribe' ) {
1591
+ let logObj = {
1592
+ userName: req.user?.userName,
1593
+ email: req.user?.email,
1594
+ clientId: req.body.clientId,
1595
+ logSubType: 'productUnsubscribed',
1596
+ logType: 'subscription',
1597
+ date: new Date(),
1598
+ changes: [ ` ${req.body.store.toString()} ${convertTitleCase( item.name )} product unsubscribed` ],
1599
+ eventType: '',
1600
+
1601
+ };
1602
+ insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
1556
1603
  removedProduct.push( item.name );
1557
1604
  }
1558
1605
  if ( !productList.includes( item.name ) ) {
@@ -1597,17 +1644,16 @@ export const addStoreProduct = async ( req, res ) => {
1597
1644
  clientId: req.body.clientId,
1598
1645
  clientNotification: false,
1599
1646
  adminNotification: true,
1600
- logSubType: 'Subscription - Your 14 Days free trial has been started',
1601
- category: 'Brand Activity Log',
1602
- features: 'Subscription',
1603
- // title: 'Start Trial',
1647
+ logSubType: 'startTrial',
1648
+ description: 'Subscription - Your 14 Days free trial has been started',
1649
+ title: 'Start Trial',
1604
1650
  alertCta: [],
1605
1651
  markasRead: false,
1606
- logType: 'Start Trial',
1652
+ logType: 'subscription',
1607
1653
  showPushNotification: true,
1608
1654
  date: new Date(),
1609
- changes: [ 'product' ],
1610
- eventType: 'update',
1655
+ changes: [ `${convertTitleCase( item.name )} trial started` ],
1656
+ eventType: '',
1611
1657
 
1612
1658
  };
1613
1659
  insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
@@ -1625,17 +1671,16 @@ export const addStoreProduct = async ( req, res ) => {
1625
1671
  clientId: req.body.clientId,
1626
1672
  clientNotification: false,
1627
1673
  adminNotification: true,
1628
- logSubType: 'Your subscription is now active! Get ready to maximize your instore sales potential with the Tangoeye suite',
1629
- category: 'Brand Activity Log',
1630
- features: 'Subscription',
1631
- // title: 'Subscribed',
1674
+ logSubType: 'productSubscription',
1675
+ description: 'Your subscription is now active! Get ready to maximize your instore sales potential with the Tangoeye suite',
1676
+ title: 'Subscription',
1632
1677
  alertCta: [],
1633
1678
  markasRead: false,
1634
- logType: 'Subscribed',
1679
+ logType: 'subscription',
1635
1680
  showPushNotification: true,
1636
1681
  date: new Date(),
1637
- changes: [ 'product' ],
1638
- eventType: 'update',
1682
+ changes: [ `${convertTitleCase( item.name )} product subscribed` ],
1683
+ eventType: '',
1639
1684
  };
1640
1685
  insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
1641
1686
  }
@@ -2109,8 +2154,8 @@ export const pricingListUpdate = async ( req, res ) => {
2109
2154
  userName: req.user?.userName,
2110
2155
  email: req.user?.email,
2111
2156
  date: new Date(),
2112
- logType: 'billing',
2113
- logSubType: 'Update Product Pricing Details',
2157
+ logType: 'subscription',
2158
+ logSubType: 'updateProductPricing',
2114
2159
  changes: keys,
2115
2160
  eventType: 'update',
2116
2161
  };
@@ -2283,8 +2328,8 @@ export const updatedRevisedPrice = async ( req, res ) => {
2283
2328
  userName: req.user?.userName,
2284
2329
  email: req.user?.email,
2285
2330
  date: new Date(),
2286
- logType: 'billing',
2287
- logSubType: 'Revised Price Updation',
2331
+ logType: 'subscription',
2332
+ logSubType: 'revisedPriceUpdation',
2288
2333
  changes: [ 'amount', 'revisedAmount', 'discount' ],
2289
2334
  eventType: 'update',
2290
2335
  };
@@ -2363,17 +2408,17 @@ export const getRemindClients = async ( req, res ) => {
2363
2408
  clientId: client.clientId,
2364
2409
  clientNotification: false,
2365
2410
  adminNotification: true,
2366
- logSubType: 'Subscription - Your Free trial is about to expire in 3 days. Pleas make sure to subscribe to the products',
2367
- category: 'Brand Activity Log',
2368
- features: 'Subscription',
2369
- // title: 'Trial reminder',
2370
- alertCta: [ { buttonName: 'Subscribe now', redirectionUrl: 'manage/settings/payment-subscription' }, { buttonName: 'Remind me later', redirectionUrl: 'cancel' } ],
2411
+ description: 'Subscription - Your Free trial is about to expire in 3 days. Pleas make sure to subscribe to the products',
2412
+ logSubType: 'trialReminder',
2413
+ title: 'Subscription',
2414
+ alertCta: [ { buttonName: 'Subscribe now', redirectionUrl: 'manage/settings/payment-subscription', product: data.product, clientId: client.clientId }, { buttonName: 'Remind me later', redirectionUrl: 'remind' } ],
2371
2415
  markasRead: false,
2372
- logType: 'Trial reminder',
2416
+ logType: 'subscription',
2373
2417
  showPushNotification: true,
2374
2418
  date: new Date(),
2375
2419
  userName: userDetails?.userName,
2376
2420
  email: userDetails?.email,
2421
+ changes: [ `${data.product} trial is going to expired.` ],
2377
2422
  };
2378
2423
  insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
2379
2424
  const templateHtml = fs.readFileSync( path.resolve( path.dirname( '' ) ) + '/src/hbs/trialReminderEmail.hbs', 'utf8' );
@@ -2681,7 +2726,7 @@ export const updateInvoiceStatus = async ( req, res ) => {
2681
2726
  email: req.user?.email,
2682
2727
  date: new Date(),
2683
2728
  logType: 'invoice',
2684
- logSubType: 'Invoice Status Updated to Paid',
2729
+ logSubType: 'InvoiceStatus',
2685
2730
  changes: [ 'amount', 'paymentType', 'status' ],
2686
2731
  eventType: 'update',
2687
2732
  };
@@ -3050,6 +3095,13 @@ export const invoiceRevised = async ( req, res ) => {
3050
3095
  export const clientNotificationList = async ( req, res ) => {
3051
3096
  try {
3052
3097
  let from = ( req.query.offset - 1 ) * req.query.limit;
3098
+ let start = new Date();
3099
+ let userTimezoneOffset = start.getTimezoneOffset() * 60000;
3100
+ start = new Date( start.getTime() - userTimezoneOffset );
3101
+ start.setUTCHours( 0, 0, 0, 0 );
3102
+ let end = new Date();
3103
+ end = new Date( end.getTime() - userTimezoneOffset );
3104
+ end.setUTCHours( 23, 59, 59, 59 );
3053
3105
  let query;
3054
3106
  if ( req.user.role == 'superadmin' ) {
3055
3107
  query = {
@@ -3062,10 +3114,18 @@ export const clientNotificationList = async ( req, res ) => {
3062
3114
  // { match: { logType: 'notification' } },
3063
3115
  { match: { adminNotification: true } },
3064
3116
  { match: { markasRead: false } },
3117
+ { range: { date: { gte: start, lte: end } } },
3065
3118
  ],
3066
3119
  },
3067
3120
  },
3068
- _source: [ 'logType', 'alertCta', 'clientId', 'markasRead', 'showPushNotification', 'date', 'logSubType' ],
3121
+ sort: [
3122
+ {
3123
+ date: {
3124
+ order: 'desc',
3125
+ },
3126
+ },
3127
+ ],
3128
+ _source: [ 'title', 'alertCta', 'clientId', 'markasRead', 'showPushNotification', 'date', 'description' ],
3069
3129
  };
3070
3130
  } else {
3071
3131
  query = {
@@ -3076,10 +3136,18 @@ export const clientNotificationList = async ( req, res ) => {
3076
3136
  // { match: { type: 'notification' } },
3077
3137
  { match: { clientNotification: true } },
3078
3138
  { match: { markasRead: false } },
3139
+ { range: { date: { gte: start, lte: end } } },
3079
3140
  ],
3080
3141
  },
3081
3142
  },
3082
- _source: [ 'logType', 'alertCta', 'clientId', 'markasRead', 'showPushNotification', 'date', 'logSubType' ],
3143
+ sort: [
3144
+ {
3145
+ date: {
3146
+ order: 'desc',
3147
+ },
3148
+ },
3149
+ ],
3150
+ _source: [ 'title', 'alertCta', 'clientId', 'markasRead', 'showPushNotification', 'date', 'description' ],
3083
3151
  };
3084
3152
  }
3085
3153
  let result = await getOpenSearchData( appConfig.opensearch.activityLog, query );
@@ -3096,7 +3164,7 @@ export const clientNotificationList = async ( req, res ) => {
3096
3164
  export const updateNotification = async ( req, res ) => {
3097
3165
  try {
3098
3166
  let openSearchDetails = await getOpenSearchById( appConfig.opensearch.activityLog, req.params.notificationId );
3099
- if ( openSearchDetails.statusCode == 200 && openSearchDetails?.body?._source ) {
3167
+ if ( openSearchDetails && openSearchDetails?.statusCode == 200 && openSearchDetails?.body?._source ) {
3100
3168
  const document = {
3101
3169
  doc: {
3102
3170
  markasRead: true,
@@ -3104,9 +3172,11 @@ export const updateNotification = async ( req, res ) => {
3104
3172
  };
3105
3173
  let updateResult = await updateOpenSearchData( appConfig.opensearch.activityLog, req.params.notificationId, document );
3106
3174
  if ( updateResult?.statusCode == 200 && updateResult?.body?.result == 'updated' ) {
3107
- return res.sendSuccess( 'Notification Updated SUccessfully' );
3175
+ return res.sendSuccess( 'Notification Updated Successfully' );
3108
3176
  }
3109
3177
  return res.sendError( 'Something went wrong', 500 );
3178
+ } else {
3179
+ return res.sendError( 'no data found', 204 );
3110
3180
  }
3111
3181
  } catch ( e ) {
3112
3182
  logger.error( { error: e, function: 'updateNotification' } );
@@ -3117,7 +3187,7 @@ export const updateNotification = async ( req, res ) => {
3117
3187
  export const updatePushNotification = async ( req, res ) => {
3118
3188
  try {
3119
3189
  let openSearchDetails = await getOpenSearchById( appConfig.opensearch.activityLog, req.params.notificationId );
3120
- if ( openSearchDetails.statusCode == 200 && openSearchDetails?.body?._source ) {
3190
+ if ( openSearchDetails && openSearchDetails.statusCode == 200 && openSearchDetails?.body?._source ) {
3121
3191
  const document = {
3122
3192
  doc: {
3123
3193
  showPushNotification: false,
@@ -3125,12 +3195,42 @@ export const updatePushNotification = async ( req, res ) => {
3125
3195
  };
3126
3196
  let updateResult = await updateOpenSearchData( appConfig.opensearch.activityLog, req.params.notificationId, document );
3127
3197
  if ( updateResult?.statusCode == 200 && updateResult?.body?.result == 'updated' ) {
3128
- return res.sendSuccess( 'Notification Updated SUccessfully' );
3198
+ return res.sendSuccess( 'Notification Updated Successfully' );
3129
3199
  }
3130
3200
  return res.sendError( 'Something went wrong', 500 );
3201
+ } else {
3202
+ return res.sendError( 'no data found', 204 );
3131
3203
  }
3132
3204
  } catch ( e ) {
3133
3205
  logger.error( { error: e, function: 'updatePushNotification' } );
3134
3206
  return res.sendError( e, 500 );
3135
3207
  }
3136
3208
  };
3209
+
3210
+ export const updateRemind = async ( req, res ) => {
3211
+ try {
3212
+ let openSearchDetails = await getOpenSearchById( appConfig.opensearch.activityLog, req.params.notificationId );
3213
+ if ( openSearchDetails && openSearchDetails.statusCode == 200 && openSearchDetails?.body?._source ) {
3214
+ let date = new Date( new Date( openSearchDetails.body._source.date ).getTime() + 24 * 60 * 60 * 1000 );
3215
+ openSearchDetails.body._source.date = date;
3216
+ openSearchDetails.body._source.markasRead = false;
3217
+ insertOpenSearchData( appConfig.opensearch.activityLog, openSearchDetails.body._source );
3218
+ return res.sendSuccess( 'Notification Updated Successfully' );
3219
+ } else {
3220
+ return res.sendError( 'no data found', 204 );
3221
+ }
3222
+ } catch ( e ) {
3223
+ logger.error( { error: e, function: 'updatePushNotification' } );
3224
+ return res.sendError( e, 500 );
3225
+ }
3226
+ };
3227
+
3228
+
3229
+ function convertTitleCase( data ) {
3230
+ let [ firstWord, secondWord ] = data.replace( /([a-z])([A-Z])/g, '$1 $2' ).split( ' ' );
3231
+ firstWord = firstWord.charAt( 0 ).toUpperCase() + firstWord.slice( 1 );
3232
+ data = firstWord + ' ' + secondWord;
3233
+ return data;
3234
+ }
3235
+
3236
+
@@ -163,4 +163,5 @@ paymentSubscriptionRouter.get( '/invoiceRevised/:invoiceId', validate( validatio
163
163
  paymentSubscriptionRouter.get( '/notificationList', isAllowedSessionHandler, validate( validationDtos.notificationParams ), paymentController.clientNotificationList );
164
164
  paymentSubscriptionRouter.put( '/notification/update/:notificationId', isAllowedSessionHandler, validate( validationDtos.validateId ), paymentController.updateNotification );
165
165
  paymentSubscriptionRouter.put( '/pushNotification/update/:notificationId', isAllowedSessionHandler, validate( validationDtos.validateId ), paymentController.updatePushNotification );
166
+ paymentSubscriptionRouter.post( '/updateRemind/:notificationId', isAllowedSessionHandler, validate( validationDtos.validateId ), paymentController.updateRemind );
166
167