tango-app-api-payment-subscription 3.0.47-dev → 3.0.49-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.
|
|
3
|
+
"version": "3.0.49-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.
|
|
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: '
|
|
46
|
-
logSubType: '
|
|
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: '
|
|
429
|
-
logSubType: '
|
|
430
|
-
changes: [
|
|
431
|
-
eventType: '
|
|
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,16 +447,15 @@ export const updateSubscription = async ( req, res ) => {
|
|
|
446
447
|
clientId: requestBody.clientId,
|
|
447
448
|
clientNotification: false,
|
|
448
449
|
adminNotification: true,
|
|
449
|
-
|
|
450
|
-
|
|
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: '
|
|
454
|
+
logType: 'subscription',
|
|
455
|
+
logSubType: 'subscription',
|
|
456
456
|
showPushNotification: true,
|
|
457
|
-
changes: [
|
|
458
|
-
eventType: '
|
|
457
|
+
changes: [ `${convertTitleCase( item.name )} subscribed` ],
|
|
458
|
+
eventType: '',
|
|
459
459
|
date: new Date(),
|
|
460
460
|
};
|
|
461
461
|
insertOpenSearchData( appConfig.opensearch.activityLog, productObj );
|
|
@@ -637,10 +637,10 @@ export const unsubscribeProduct = async ( req, res ) => {
|
|
|
637
637
|
userName: req.user?.userName,
|
|
638
638
|
email: req.user?.email,
|
|
639
639
|
date: new Date(),
|
|
640
|
-
logType: '
|
|
641
|
-
logSubType: '
|
|
642
|
-
changes: [
|
|
643
|
-
eventType: '
|
|
640
|
+
logType: 'subscription',
|
|
641
|
+
logSubType: 'unsubscribedRequest',
|
|
642
|
+
changes: [ `${req.body.clientId} Unsubscribed Request ` ],
|
|
643
|
+
eventType: 'create',
|
|
644
644
|
};
|
|
645
645
|
insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
|
|
646
646
|
|
|
@@ -671,10 +671,10 @@ export const trialExtendRequest = async ( req, res ) => {
|
|
|
671
671
|
userName: req.user?.userName,
|
|
672
672
|
email: req.user?.email,
|
|
673
673
|
date: new Date(),
|
|
674
|
-
logType: '
|
|
675
|
-
logSubType: '
|
|
676
|
-
changes: [
|
|
677
|
-
eventType: '
|
|
674
|
+
logType: 'subscription',
|
|
675
|
+
logSubType: 'trialExtendRequest',
|
|
676
|
+
changes: [ `${convertTitleCase( req.body.product )} trial Extend Request` ],
|
|
677
|
+
eventType: 'create',
|
|
678
678
|
};
|
|
679
679
|
insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
|
|
680
680
|
|
|
@@ -707,10 +707,10 @@ export const trialRequest = async ( req, res ) => {
|
|
|
707
707
|
userName: req.user?.userName,
|
|
708
708
|
email: req.user?.email,
|
|
709
709
|
date: new Date(),
|
|
710
|
-
logType: '
|
|
711
|
-
logSubType: '
|
|
712
|
-
changes: [
|
|
713
|
-
eventType: '
|
|
710
|
+
logType: 'subscription',
|
|
711
|
+
logSubType: 'trialRequest',
|
|
712
|
+
changes: [ `${convertTitleCase( req.body.product )} trial Request` ],
|
|
713
|
+
eventType: 'create',
|
|
714
714
|
};
|
|
715
715
|
insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
|
|
716
716
|
|
|
@@ -778,8 +778,8 @@ export const updateInvoiceDetails = async ( req, res ) => {
|
|
|
778
778
|
userName: req.user?.userName,
|
|
779
779
|
email: req.user?.email,
|
|
780
780
|
date: new Date(),
|
|
781
|
-
logType: '
|
|
782
|
-
logSubType: '
|
|
781
|
+
logType: 'subscription',
|
|
782
|
+
logSubType: 'updatePaymentInvoice',
|
|
783
783
|
changes: [ 'Pro Rate', 'Payment Type', 'Payment Cycle', 'Currency Type', 'Invoice To', 'Payment Agreement To', 'Invoice On', 'Extend Payment PeriodDays' ],
|
|
784
784
|
eventType: 'update',
|
|
785
785
|
};
|
|
@@ -887,17 +887,18 @@ export const trialApproval = async ( req, res ) => {
|
|
|
887
887
|
clientId: requestData.clientId,
|
|
888
888
|
clientNotification: false,
|
|
889
889
|
adminNotification: true,
|
|
890
|
-
logSubType: '
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
//
|
|
890
|
+
logSubType: 'startTrial',
|
|
891
|
+
description: 'Subscription - Your 14 Days free trial has been started',
|
|
892
|
+
// category: 'Brand Activity Log',
|
|
893
|
+
// features: 'Subscription',
|
|
894
|
+
title: 'Subscription',
|
|
894
895
|
alertCta: [],
|
|
895
896
|
markasRead: false,
|
|
896
897
|
logType: 'Start Trial',
|
|
897
898
|
showPushNotification: true,
|
|
898
899
|
date: new Date(),
|
|
899
|
-
changes: [
|
|
900
|
-
eventType: '
|
|
900
|
+
changes: [ `${convertTitleCase( requestData.name )} trial started` ],
|
|
901
|
+
eventType: '',
|
|
901
902
|
};
|
|
902
903
|
insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
|
|
903
904
|
let clientProducts = await paymentService.findOne( { clientId: requestData.clientId }, { planDetails: 1 } );
|
|
@@ -1049,17 +1050,18 @@ export const trialExtendRequestApproval = async ( req, res ) => {
|
|
|
1049
1050
|
clientId: req.body.clientId,
|
|
1050
1051
|
clientNotification: false,
|
|
1051
1052
|
adminNotification: true,
|
|
1052
|
-
logSubType:
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
//
|
|
1053
|
+
logSubType: 'trialExtended',
|
|
1054
|
+
description: `Your Trial has been extended for ${req.body.days} days, explore the service with no extra charge and keep unlocking better insights`,
|
|
1055
|
+
// category: 'Brand Activity Log',
|
|
1056
|
+
// features: 'Subscription',
|
|
1057
|
+
title: 'Subscription',
|
|
1056
1058
|
alertCta: [],
|
|
1057
1059
|
markasRead: false,
|
|
1058
|
-
logType: '
|
|
1060
|
+
logType: 'subscription',
|
|
1059
1061
|
showPushNotification: true,
|
|
1060
1062
|
date: new Date(),
|
|
1061
|
-
changes: [
|
|
1062
|
-
eventType: '
|
|
1063
|
+
changes: [ `${data.product} trial Extended` ],
|
|
1064
|
+
eventType: '',
|
|
1063
1065
|
};
|
|
1064
1066
|
insertOpenSearchData( appConfig.opensearch.activityLog, notifyObj );
|
|
1065
1067
|
// const logObj = {
|
|
@@ -1110,6 +1112,18 @@ export const productSubscribe = async ( req, res ) => {
|
|
|
1110
1112
|
let productList = product.map( ( item ) => item.productName );
|
|
1111
1113
|
for ( let item of req.body.product ) {
|
|
1112
1114
|
if ( productList.includes( item.name ) && item.type == 'unsubscribe' ) {
|
|
1115
|
+
let logObj = {
|
|
1116
|
+
userName: req.user?.userName,
|
|
1117
|
+
email: req.user?.email,
|
|
1118
|
+
clientId: clientInfo.clientId,
|
|
1119
|
+
logSubType: 'productUnsubscribe',
|
|
1120
|
+
logType: 'subscription',
|
|
1121
|
+
date: new Date(),
|
|
1122
|
+
changes: [ `${convertTitleCase( item.name )} product unsubscribed` ],
|
|
1123
|
+
eventType: '',
|
|
1124
|
+
timestamp: new Date(),
|
|
1125
|
+
};
|
|
1126
|
+
insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
|
|
1113
1127
|
await storeService.addremoveElement( { clientId: clientInfo.clientId, product: { $in: item.name } }, { $pull: { product: item.name } } );
|
|
1114
1128
|
await clientRequestService.deleteOne( { clientId: clientInfo.clientId, status: 'pending', name: item.name } );
|
|
1115
1129
|
}
|
|
@@ -1121,17 +1135,19 @@ export const productSubscribe = async ( req, res ) => {
|
|
|
1121
1135
|
clientId: clientInfo.clientId,
|
|
1122
1136
|
clientNotification: false,
|
|
1123
1137
|
adminNotification: true,
|
|
1124
|
-
logSubType: '
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
//
|
|
1138
|
+
logSubType: 'startTrial',
|
|
1139
|
+
description: 'Subscription - Your 14 Days free trial has been started',
|
|
1140
|
+
// category: 'Brand Activity Log',
|
|
1141
|
+
// features: 'Subscription',
|
|
1142
|
+
title: 'Start Trial',
|
|
1128
1143
|
alertCta: [],
|
|
1129
1144
|
markasRead: false,
|
|
1130
|
-
logType: '
|
|
1145
|
+
logType: 'subscription',
|
|
1131
1146
|
showPushNotification: true,
|
|
1132
1147
|
date: new Date(),
|
|
1133
|
-
changes: [
|
|
1134
|
-
eventType: '
|
|
1148
|
+
changes: [ `${convertTitleCase( item.name )} trial started` ],
|
|
1149
|
+
eventType: '',
|
|
1150
|
+
timestamp: new Date(),
|
|
1135
1151
|
};
|
|
1136
1152
|
insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
|
|
1137
1153
|
product.push( {
|
|
@@ -1151,17 +1167,18 @@ export const productSubscribe = async ( req, res ) => {
|
|
|
1151
1167
|
clientId: clientInfo.clientId,
|
|
1152
1168
|
clientNotification: false,
|
|
1153
1169
|
adminNotification: true,
|
|
1154
|
-
logSubType: '
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
//
|
|
1170
|
+
logSubType: 'productSubscribed',
|
|
1171
|
+
description: 'Your subscription is now active! Get ready to maximize your instore sales potential with the Tangoeye suite',
|
|
1172
|
+
// category: 'Brand Activity Log',
|
|
1173
|
+
// features: 'Subscription',
|
|
1174
|
+
title: 'Subscription',
|
|
1158
1175
|
alertCta: [],
|
|
1159
1176
|
markasRead: false,
|
|
1160
|
-
logType: '
|
|
1177
|
+
logType: 'subscription',
|
|
1161
1178
|
showPushNotification: true,
|
|
1162
1179
|
date: new Date(),
|
|
1163
|
-
changes: [
|
|
1164
|
-
eventType: '
|
|
1180
|
+
changes: [ `${convertTitleCase( item.name )} prodcut Subscribed` ],
|
|
1181
|
+
eventType: '',
|
|
1165
1182
|
};
|
|
1166
1183
|
insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
|
|
1167
1184
|
product.push( {
|
|
@@ -1322,10 +1339,10 @@ export const unsubscribeApproval = async ( req, res ) => {
|
|
|
1322
1339
|
userName: req.user?.userName,
|
|
1323
1340
|
email: req.user?.email,
|
|
1324
1341
|
date: new Date(),
|
|
1325
|
-
logType: '
|
|
1326
|
-
logSubType: '
|
|
1327
|
-
changes: [
|
|
1328
|
-
eventType: '
|
|
1342
|
+
logType: 'subscription',
|
|
1343
|
+
logSubType: 'unsubscribedApproved',
|
|
1344
|
+
changes: [ `${requestData.clientId} unsubscribed` ],
|
|
1345
|
+
eventType: '',
|
|
1329
1346
|
};
|
|
1330
1347
|
insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
|
|
1331
1348
|
return res.sendSuccess( 'updated Successfully' );
|
|
@@ -1553,6 +1570,18 @@ export const addStoreProduct = async ( req, res ) => {
|
|
|
1553
1570
|
storeProduct.push( item.name );
|
|
1554
1571
|
}
|
|
1555
1572
|
if ( item.type == 'unsubscribe' ) {
|
|
1573
|
+
let logObj = {
|
|
1574
|
+
userName: req.user?.userName,
|
|
1575
|
+
email: req.user?.email,
|
|
1576
|
+
clientId: req.body.clientId,
|
|
1577
|
+
logSubType: 'productUnsubscribed',
|
|
1578
|
+
logType: 'subscription',
|
|
1579
|
+
date: new Date(),
|
|
1580
|
+
changes: [ ` ${req.body.store.toString()} ${convertTitleCase( item.name )} product unsubscribed` ],
|
|
1581
|
+
eventType: '',
|
|
1582
|
+
|
|
1583
|
+
};
|
|
1584
|
+
insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
|
|
1556
1585
|
removedProduct.push( item.name );
|
|
1557
1586
|
}
|
|
1558
1587
|
if ( !productList.includes( item.name ) ) {
|
|
@@ -1597,17 +1626,16 @@ export const addStoreProduct = async ( req, res ) => {
|
|
|
1597
1626
|
clientId: req.body.clientId,
|
|
1598
1627
|
clientNotification: false,
|
|
1599
1628
|
adminNotification: true,
|
|
1600
|
-
logSubType: '
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
// title: 'Start Trial',
|
|
1629
|
+
logSubType: 'startTrial',
|
|
1630
|
+
description: 'Subscription - Your 14 Days free trial has been started',
|
|
1631
|
+
title: 'Start Trial',
|
|
1604
1632
|
alertCta: [],
|
|
1605
1633
|
markasRead: false,
|
|
1606
|
-
logType: '
|
|
1634
|
+
logType: 'subscription',
|
|
1607
1635
|
showPushNotification: true,
|
|
1608
1636
|
date: new Date(),
|
|
1609
|
-
changes: [
|
|
1610
|
-
eventType: '
|
|
1637
|
+
changes: [ `${convertTitleCase( item.name )} trial started` ],
|
|
1638
|
+
eventType: '',
|
|
1611
1639
|
|
|
1612
1640
|
};
|
|
1613
1641
|
insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
|
|
@@ -1625,17 +1653,16 @@ export const addStoreProduct = async ( req, res ) => {
|
|
|
1625
1653
|
clientId: req.body.clientId,
|
|
1626
1654
|
clientNotification: false,
|
|
1627
1655
|
adminNotification: true,
|
|
1628
|
-
logSubType: '
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
// title: 'Subscribed',
|
|
1656
|
+
logSubType: 'productSubscription',
|
|
1657
|
+
description: 'Your subscription is now active! Get ready to maximize your instore sales potential with the Tangoeye suite',
|
|
1658
|
+
title: 'Subscription',
|
|
1632
1659
|
alertCta: [],
|
|
1633
1660
|
markasRead: false,
|
|
1634
|
-
logType: '
|
|
1661
|
+
logType: 'subscription',
|
|
1635
1662
|
showPushNotification: true,
|
|
1636
1663
|
date: new Date(),
|
|
1637
|
-
changes: [
|
|
1638
|
-
eventType: '
|
|
1664
|
+
changes: [ `${convertTitleCase( item.name )} product subscribed` ],
|
|
1665
|
+
eventType: '',
|
|
1639
1666
|
};
|
|
1640
1667
|
insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
|
|
1641
1668
|
}
|
|
@@ -2109,8 +2136,8 @@ export const pricingListUpdate = async ( req, res ) => {
|
|
|
2109
2136
|
userName: req.user?.userName,
|
|
2110
2137
|
email: req.user?.email,
|
|
2111
2138
|
date: new Date(),
|
|
2112
|
-
logType: '
|
|
2113
|
-
logSubType: '
|
|
2139
|
+
logType: 'subscription',
|
|
2140
|
+
logSubType: 'updateProductPricing',
|
|
2114
2141
|
changes: keys,
|
|
2115
2142
|
eventType: 'update',
|
|
2116
2143
|
};
|
|
@@ -2283,8 +2310,8 @@ export const updatedRevisedPrice = async ( req, res ) => {
|
|
|
2283
2310
|
userName: req.user?.userName,
|
|
2284
2311
|
email: req.user?.email,
|
|
2285
2312
|
date: new Date(),
|
|
2286
|
-
logType: '
|
|
2287
|
-
logSubType: '
|
|
2313
|
+
logType: 'subscription',
|
|
2314
|
+
logSubType: 'revisedPriceUpdation',
|
|
2288
2315
|
changes: [ 'amount', 'revisedAmount', 'discount' ],
|
|
2289
2316
|
eventType: 'update',
|
|
2290
2317
|
};
|
|
@@ -2363,17 +2390,17 @@ export const getRemindClients = async ( req, res ) => {
|
|
|
2363
2390
|
clientId: client.clientId,
|
|
2364
2391
|
clientNotification: false,
|
|
2365
2392
|
adminNotification: true,
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
// title: 'Trial reminder',
|
|
2393
|
+
description: 'Subscription - Your Free trial is about to expire in 3 days. Pleas make sure to subscribe to the products',
|
|
2394
|
+
logSubType: 'trialReminder',
|
|
2395
|
+
title: 'Subscription',
|
|
2370
2396
|
alertCta: [ { buttonName: 'Subscribe now', redirectionUrl: 'manage/settings/payment-subscription' }, { buttonName: 'Remind me later', redirectionUrl: 'cancel' } ],
|
|
2371
2397
|
markasRead: false,
|
|
2372
|
-
logType: '
|
|
2398
|
+
logType: 'subscription',
|
|
2373
2399
|
showPushNotification: true,
|
|
2374
2400
|
date: new Date(),
|
|
2375
2401
|
userName: userDetails?.userName,
|
|
2376
2402
|
email: userDetails?.email,
|
|
2403
|
+
changes: [ `${data.product} trial is going to expired.` ],
|
|
2377
2404
|
};
|
|
2378
2405
|
insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
|
|
2379
2406
|
const templateHtml = fs.readFileSync( path.resolve( path.dirname( '' ) ) + '/src/hbs/trialReminderEmail.hbs', 'utf8' );
|
|
@@ -2681,7 +2708,7 @@ export const updateInvoiceStatus = async ( req, res ) => {
|
|
|
2681
2708
|
email: req.user?.email,
|
|
2682
2709
|
date: new Date(),
|
|
2683
2710
|
logType: 'invoice',
|
|
2684
|
-
logSubType: '
|
|
2711
|
+
logSubType: 'InvoiceStatus',
|
|
2685
2712
|
changes: [ 'amount', 'paymentType', 'status' ],
|
|
2686
2713
|
eventType: 'update',
|
|
2687
2714
|
};
|
|
@@ -3049,9 +3076,12 @@ export const invoiceRevised = async ( req, res ) => {
|
|
|
3049
3076
|
|
|
3050
3077
|
export const clientNotificationList = async ( req, res ) => {
|
|
3051
3078
|
try {
|
|
3079
|
+
let from = ( req.query.offset - 1 ) * req.query.limit;
|
|
3052
3080
|
let query;
|
|
3053
3081
|
if ( req.user.role == 'superadmin' ) {
|
|
3054
3082
|
query = {
|
|
3083
|
+
from: from,
|
|
3084
|
+
size: req.query.limit,
|
|
3055
3085
|
query: {
|
|
3056
3086
|
bool: {
|
|
3057
3087
|
must: [
|
|
@@ -3062,7 +3092,7 @@ export const clientNotificationList = async ( req, res ) => {
|
|
|
3062
3092
|
],
|
|
3063
3093
|
},
|
|
3064
3094
|
},
|
|
3065
|
-
_source: [ '
|
|
3095
|
+
_source: [ 'title', 'alertCta', 'clientId', 'markasRead', 'showPushNotification', 'date', 'description' ],
|
|
3066
3096
|
};
|
|
3067
3097
|
} else {
|
|
3068
3098
|
query = {
|
|
@@ -3076,14 +3106,14 @@ export const clientNotificationList = async ( req, res ) => {
|
|
|
3076
3106
|
],
|
|
3077
3107
|
},
|
|
3078
3108
|
},
|
|
3079
|
-
_source: [ '
|
|
3109
|
+
_source: [ 'title', 'alertCta', 'clientId', 'markasRead', 'showPushNotification', 'date', 'description' ],
|
|
3080
3110
|
};
|
|
3081
3111
|
}
|
|
3082
3112
|
let result = await getOpenSearchData( appConfig.opensearch.activityLog, query );
|
|
3083
3113
|
if ( !result || !result.body.hits.hits.length ) {
|
|
3084
3114
|
return res.sendError( 'no data found', 204 );
|
|
3085
3115
|
}
|
|
3086
|
-
return res.sendSuccess( result.body.hits.hits );
|
|
3116
|
+
return res.sendSuccess( { count: result.body.hits.total.value, result: result.body.hits.hits } );
|
|
3087
3117
|
} catch ( e ) {
|
|
3088
3118
|
logger.error( { error: e, function: 'clientNotificationList' } );
|
|
3089
3119
|
return res.sendError( e, 500 );
|
|
@@ -3093,7 +3123,7 @@ export const clientNotificationList = async ( req, res ) => {
|
|
|
3093
3123
|
export const updateNotification = async ( req, res ) => {
|
|
3094
3124
|
try {
|
|
3095
3125
|
let openSearchDetails = await getOpenSearchById( appConfig.opensearch.activityLog, req.params.notificationId );
|
|
3096
|
-
if ( openSearchDetails
|
|
3126
|
+
if ( openSearchDetails && openSearchDetails?.statusCode == 200 && openSearchDetails?.body?._source ) {
|
|
3097
3127
|
const document = {
|
|
3098
3128
|
doc: {
|
|
3099
3129
|
markasRead: true,
|
|
@@ -3101,9 +3131,11 @@ export const updateNotification = async ( req, res ) => {
|
|
|
3101
3131
|
};
|
|
3102
3132
|
let updateResult = await updateOpenSearchData( appConfig.opensearch.activityLog, req.params.notificationId, document );
|
|
3103
3133
|
if ( updateResult?.statusCode == 200 && updateResult?.body?.result == 'updated' ) {
|
|
3104
|
-
return res.sendSuccess( 'Notification Updated
|
|
3134
|
+
return res.sendSuccess( 'Notification Updated Successfully' );
|
|
3105
3135
|
}
|
|
3106
3136
|
return res.sendError( 'Something went wrong', 500 );
|
|
3137
|
+
} else {
|
|
3138
|
+
return res.sendError( 'no data found', 204 );
|
|
3107
3139
|
}
|
|
3108
3140
|
} catch ( e ) {
|
|
3109
3141
|
logger.error( { error: e, function: 'updateNotification' } );
|
|
@@ -3114,7 +3146,7 @@ export const updateNotification = async ( req, res ) => {
|
|
|
3114
3146
|
export const updatePushNotification = async ( req, res ) => {
|
|
3115
3147
|
try {
|
|
3116
3148
|
let openSearchDetails = await getOpenSearchById( appConfig.opensearch.activityLog, req.params.notificationId );
|
|
3117
|
-
if ( openSearchDetails.statusCode == 200 && openSearchDetails?.body?._source ) {
|
|
3149
|
+
if ( openSearchDetails && openSearchDetails.statusCode == 200 && openSearchDetails?.body?._source ) {
|
|
3118
3150
|
const document = {
|
|
3119
3151
|
doc: {
|
|
3120
3152
|
showPushNotification: false,
|
|
@@ -3122,12 +3154,22 @@ export const updatePushNotification = async ( req, res ) => {
|
|
|
3122
3154
|
};
|
|
3123
3155
|
let updateResult = await updateOpenSearchData( appConfig.opensearch.activityLog, req.params.notificationId, document );
|
|
3124
3156
|
if ( updateResult?.statusCode == 200 && updateResult?.body?.result == 'updated' ) {
|
|
3125
|
-
return res.sendSuccess( 'Notification Updated
|
|
3157
|
+
return res.sendSuccess( 'Notification Updated Successfully' );
|
|
3126
3158
|
}
|
|
3127
3159
|
return res.sendError( 'Something went wrong', 500 );
|
|
3160
|
+
} else {
|
|
3161
|
+
return res.sendError( 'no data found', 204 );
|
|
3128
3162
|
}
|
|
3129
3163
|
} catch ( e ) {
|
|
3130
3164
|
logger.error( { error: e, function: 'updatePushNotification' } );
|
|
3131
3165
|
return res.sendError( e, 500 );
|
|
3132
3166
|
}
|
|
3133
3167
|
};
|
|
3168
|
+
|
|
3169
|
+
|
|
3170
|
+
function convertTitleCase( data ) {
|
|
3171
|
+
let [ firstWord, secondWord ] = data.replace( /([a-z])([A-Z])/g, '$1 $2' ).split( ' ' );
|
|
3172
|
+
firstWord = firstWord.charAt( 0 ).toUpperCase() + firstWord.slice( 1 );
|
|
3173
|
+
data = firstWord + ' ' + secondWord;
|
|
3174
|
+
return data;
|
|
3175
|
+
}
|
|
@@ -256,3 +256,12 @@ export const validateIdSchema = joi.object( {
|
|
|
256
256
|
export const validateId = {
|
|
257
257
|
params: validateIdSchema,
|
|
258
258
|
};
|
|
259
|
+
|
|
260
|
+
export const notificationSchema = {
|
|
261
|
+
limit: joi.number().required(),
|
|
262
|
+
offset: joi.number().required(),
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
export const notificationParams = {
|
|
266
|
+
query: notificationSchema,
|
|
267
|
+
};
|
|
@@ -160,7 +160,7 @@ paymentSubscriptionRouter.post( '/invoice/create', validateClient, paymentContro
|
|
|
160
160
|
paymentSubscriptionRouter.post( '/invoiceGenerate', paymentController.invoiceGenerate );
|
|
161
161
|
paymentSubscriptionRouter.post( '/dailyPricing/insert', validate( validationDtos.dailyPricingParams ), paymentController.dailyPricingInsert );
|
|
162
162
|
paymentSubscriptionRouter.get( '/invoiceRevised/:invoiceId', validate( validationDtos.invoiceRevisedParams ), paymentController.invoiceRevised );
|
|
163
|
-
paymentSubscriptionRouter.get( '/notificationList', isAllowedSessionHandler, paymentController.clientNotificationList );
|
|
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
166
|
|