tango-app-api-analysis-traffic 3.0.0-alpha.11 → 3.0.0-alpha.13
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
|
@@ -2,6 +2,7 @@ import { logger, download } from 'tango-app-api-middleware';
|
|
|
2
2
|
import * as clientService from '../services/clients.services.js';
|
|
3
3
|
import {
|
|
4
4
|
aggregateStore,
|
|
5
|
+
findOneStore,
|
|
5
6
|
} from '../services/stores.service.js';
|
|
6
7
|
import { aggregateUserAssignedStore, findOneUserAssignedStore } from '../services/userAssignedStore.service.js';
|
|
7
8
|
import { aggregateGroup } from '../services/group.service.js';
|
|
@@ -27,8 +28,8 @@ async function LamdaServiceCall( url, data ) {
|
|
|
27
28
|
const json = await response.json();
|
|
28
29
|
return json;
|
|
29
30
|
} catch ( error ) {
|
|
30
|
-
console.log( 'error =>', error );
|
|
31
31
|
logger.error( { error: error, message: data, function: 'LamdaServiceCall' } );
|
|
32
|
+
return false;
|
|
32
33
|
}
|
|
33
34
|
}
|
|
34
35
|
|
|
@@ -394,6 +395,26 @@ export const performanceMatrixV1 = async ( req, res ) => {
|
|
|
394
395
|
}
|
|
395
396
|
};
|
|
396
397
|
|
|
398
|
+
export const zoneDwellTimeSplitV1 = async ( req, res ) => {
|
|
399
|
+
try {
|
|
400
|
+
let reqestData = req.body;
|
|
401
|
+
let LamdaURL = 'https://7tfzazsi6lcejnjdzijv7bwg7y0yxhdx.lambda-url.ap-south-1.on.aws/';
|
|
402
|
+
let resultData = await LamdaServiceCall( LamdaURL, reqestData );
|
|
403
|
+
if ( resultData ) {
|
|
404
|
+
if ( resultData.status_code == '200' ) {
|
|
405
|
+
return res.sendSuccess( resultData );
|
|
406
|
+
} else {
|
|
407
|
+
return res.sendError( 'No Content', 204 );
|
|
408
|
+
}
|
|
409
|
+
} else {
|
|
410
|
+
return res.sendError( 'No Content', 204 );
|
|
411
|
+
}
|
|
412
|
+
} catch ( error ) {
|
|
413
|
+
logger.error( { error: error, message: req.query, function: 'trafficCards' } );
|
|
414
|
+
return res.sendError( { error: error }, 500 );
|
|
415
|
+
}
|
|
416
|
+
};
|
|
417
|
+
|
|
397
418
|
export const storesMapV1 = async ( req, res ) => {
|
|
398
419
|
try {
|
|
399
420
|
let reqestData = req.body;
|
|
@@ -479,7 +500,6 @@ export const storesMapV1 = async ( req, res ) => {
|
|
|
479
500
|
}
|
|
480
501
|
}
|
|
481
502
|
} catch ( error ) {
|
|
482
|
-
console.log( 'storesMapV1 error =>', error );
|
|
483
503
|
logger.error( { error: error, message: req.query, function: 'storesMapV1' } );
|
|
484
504
|
return res.sendError( { error: error }, 500 );
|
|
485
505
|
}
|
|
@@ -605,8 +625,7 @@ export const headerGroupsV1 = async ( req, res ) => {
|
|
|
605
625
|
return res.sendError( 'No Group', 400 );
|
|
606
626
|
}
|
|
607
627
|
} catch ( error ) {
|
|
608
|
-
|
|
609
|
-
logger.error( { error: error, message: req.query, function: 'trafficCards' } );
|
|
628
|
+
logger.error( { error: error, message: req.query, function: 'headerGroupsV1' } );
|
|
610
629
|
return res.sendError( { error: error }, 500 );
|
|
611
630
|
}
|
|
612
631
|
};
|
|
@@ -710,7 +729,6 @@ export const headerStoresV1 = async ( req, res ) => {
|
|
|
710
729
|
return res.sendError( 'No Stores', 400 );
|
|
711
730
|
}
|
|
712
731
|
} catch ( error ) {
|
|
713
|
-
console.log( 'headerStoresV1 =>', error );
|
|
714
732
|
logger.error( { error: error, message: req.query, function: 'headerStoresV1' } );
|
|
715
733
|
return res.sendError( { error: error }, 500 );
|
|
716
734
|
}
|
|
@@ -775,7 +793,6 @@ async function getAllStores( getUserEmail, getClientId, getUserType, getRole ) {
|
|
|
775
793
|
return false;
|
|
776
794
|
}
|
|
777
795
|
} catch ( error ) {
|
|
778
|
-
console.log( 'getAllStores =>', error );
|
|
779
796
|
logger.error( { error: error, message: req.query, function: 'getAllStores' } );
|
|
780
797
|
}
|
|
781
798
|
};
|
|
@@ -811,8 +828,8 @@ async function getAssignedStores( clientId, userEmail, assignedType ) {
|
|
|
811
828
|
return false;
|
|
812
829
|
}
|
|
813
830
|
} catch ( error ) {
|
|
814
|
-
console.log( 'getAssignedStores error =>', error );
|
|
815
831
|
logger.error( { error: error, message: data, function: 'getAssignedStores' } );
|
|
832
|
+
return false;
|
|
816
833
|
}
|
|
817
834
|
}
|
|
818
835
|
|
|
@@ -878,8 +895,8 @@ async function getAssignedGroupStores( clientId, userEmail, assignedType ) {
|
|
|
878
895
|
return false;
|
|
879
896
|
}
|
|
880
897
|
} catch ( error ) {
|
|
881
|
-
console.log( 'getAssignedGroupStores error =>', error );
|
|
882
898
|
logger.error( { error: error, message: data, function: 'getAssignedGroupStores' } );
|
|
899
|
+
return false;
|
|
883
900
|
}
|
|
884
901
|
}
|
|
885
902
|
|
|
@@ -913,8 +930,8 @@ async function getAssignedAllStores( userClientId ) {
|
|
|
913
930
|
return false;
|
|
914
931
|
}
|
|
915
932
|
} catch ( error ) {
|
|
916
|
-
console.log( 'getAssignedAllStores error =>', error );
|
|
917
933
|
logger.error( { error: error, message: data, function: 'getAssignedAllStores' } );
|
|
934
|
+
return false;
|
|
918
935
|
}
|
|
919
936
|
}
|
|
920
937
|
|
|
@@ -953,8 +970,8 @@ async function getGroupStores( userClientId, groupList ) {
|
|
|
953
970
|
return false;
|
|
954
971
|
}
|
|
955
972
|
} catch ( error ) {
|
|
956
|
-
console.log( 'getGroupStores error =>', error );
|
|
957
973
|
logger.error( { error: error, message: data, function: 'getGroupStores' } );
|
|
974
|
+
return false;
|
|
958
975
|
}
|
|
959
976
|
}
|
|
960
977
|
|
|
@@ -994,8 +1011,8 @@ async function getLocationStores( userClientId, cityList ) {
|
|
|
994
1011
|
return false;
|
|
995
1012
|
}
|
|
996
1013
|
} catch ( error ) {
|
|
997
|
-
console.log( 'getLocationStores error =>', error );
|
|
998
1014
|
logger.error( { error: error, message: data, function: 'getLocationStores' } );
|
|
1015
|
+
return false;
|
|
999
1016
|
}
|
|
1000
1017
|
}
|
|
1001
1018
|
|
|
@@ -1028,8 +1045,8 @@ async function getGroupIds( userClientId ) {
|
|
|
1028
1045
|
return false;
|
|
1029
1046
|
}
|
|
1030
1047
|
} catch ( error ) {
|
|
1031
|
-
console.log( 'getGroupIds error =>', error );
|
|
1032
1048
|
logger.error( { error: error, message: data, function: 'getGroupIds' } );
|
|
1049
|
+
return false;
|
|
1033
1050
|
}
|
|
1034
1051
|
}
|
|
1035
1052
|
|
|
@@ -1068,8 +1085,8 @@ async function getAssignedGroupIds( userClientId, getUserEmail ) {
|
|
|
1068
1085
|
return false;
|
|
1069
1086
|
}
|
|
1070
1087
|
} catch ( error ) {
|
|
1071
|
-
console.log( 'getAssignedGroupIds error =>', error );
|
|
1072
1088
|
logger.error( { error: error, message: data, function: 'getAssignedGroupIds' } );
|
|
1089
|
+
return false;
|
|
1073
1090
|
}
|
|
1074
1091
|
}
|
|
1075
1092
|
|
|
@@ -1091,8 +1108,8 @@ async function getCityStores( userClientId, getUserEmail, getRole, requestCity,
|
|
|
1091
1108
|
return false;
|
|
1092
1109
|
}
|
|
1093
1110
|
} catch ( error ) {
|
|
1094
|
-
console.log( 'getAssignedGroupIds error =>', error );
|
|
1095
1111
|
logger.error( { error: error, message: data, function: 'getAssignedGroupIds' } );
|
|
1112
|
+
return false;
|
|
1096
1113
|
}
|
|
1097
1114
|
}
|
|
1098
1115
|
|
|
@@ -1191,8 +1208,8 @@ async function getGroupStoresIds( userClientId, storeIds, getRole, getUserType,
|
|
|
1191
1208
|
return false;
|
|
1192
1209
|
}
|
|
1193
1210
|
} catch ( error ) {
|
|
1194
|
-
console.log( 'getGroupIds error =>', error );
|
|
1195
1211
|
logger.error( { error: error, message: data, function: 'getGroupIds' } );
|
|
1212
|
+
return false;
|
|
1196
1213
|
}
|
|
1197
1214
|
}
|
|
1198
1215
|
|
|
@@ -1233,3 +1250,64 @@ export async function isAllowedClient( req, res, next ) {
|
|
|
1233
1250
|
return res.sendError( error, 500 );
|
|
1234
1251
|
}
|
|
1235
1252
|
}
|
|
1253
|
+
|
|
1254
|
+
export const getMySubscription = async ( req, res ) => {
|
|
1255
|
+
try {
|
|
1256
|
+
let reqestData = req.body;
|
|
1257
|
+
let getClientData = await clientService.findOne( { clientId: reqestData.clientId }, { planDetails: 1 } );
|
|
1258
|
+
if ( getClientData ) {
|
|
1259
|
+
if ( getClientData.planDetails && getClientData.planDetails.product && getClientData.planDetails.product.length>0 ) {
|
|
1260
|
+
let clientSubscription = {};
|
|
1261
|
+
clientSubscription.subscriptionType = getClientData.planDetails.subscriptionType;
|
|
1262
|
+
clientSubscription.product = getClientData.planDetails.product;
|
|
1263
|
+
let storeSubscription = {};
|
|
1264
|
+
if ( reqestData.storeId && reqestData.storeId.length>0 ) {
|
|
1265
|
+
let getStoreData = await findOneStore( { clientId: reqestData.clientId, storeId: { $in: reqestData.storeId[0] } }, { product: 1 } );
|
|
1266
|
+
if ( getStoreData ) {
|
|
1267
|
+
storeSubscription.product = getStoreData.product;
|
|
1268
|
+
} else {
|
|
1269
|
+
storeSubscription.product = [];
|
|
1270
|
+
}
|
|
1271
|
+
} else {
|
|
1272
|
+
storeSubscription.product = [];
|
|
1273
|
+
}
|
|
1274
|
+
let resultData = { clientSubscription, storeSubscription };
|
|
1275
|
+
return res.sendSuccess( resultData );
|
|
1276
|
+
} else {
|
|
1277
|
+
return res.sendError( 'Not Subscribe', 400 );
|
|
1278
|
+
}
|
|
1279
|
+
} else {
|
|
1280
|
+
return res.sendError( 'Invalid Client Id', 400 );
|
|
1281
|
+
}
|
|
1282
|
+
} catch ( error ) {
|
|
1283
|
+
logger.error( { error: error, message: req.query, function: 'getMySubscription' } );
|
|
1284
|
+
return res.sendError( { error: error }, 500 );
|
|
1285
|
+
}
|
|
1286
|
+
};
|
|
1287
|
+
|
|
1288
|
+
// async function getGeocodedAddress( lat, lng ) {
|
|
1289
|
+
// try {
|
|
1290
|
+
// const apiKey = 'AIzaSyDlOezgwQO0JviD0aizrCuN1FY9tcWfR3o'; // Use this if you're using dotenv
|
|
1291
|
+
// const url = `https://maps.googleapis.com/maps/api/geocode/json?latlng=${lat},${lng}&key=${apiKey}`;
|
|
1292
|
+
|
|
1293
|
+
// const requestOptions = {
|
|
1294
|
+
// method: 'GET',
|
|
1295
|
+
// headers: {
|
|
1296
|
+
// 'Content-Type': 'application/json',
|
|
1297
|
+
// },
|
|
1298
|
+
// };
|
|
1299
|
+
// const response = await fetch( url, requestOptions );
|
|
1300
|
+
// console.log( 'response =>', response );
|
|
1301
|
+
// if ( !response.ok ) {
|
|
1302
|
+
// throw new Error( `Response status: ${response.status}` );
|
|
1303
|
+
// return false;
|
|
1304
|
+
// }
|
|
1305
|
+
// const json = await response.json();
|
|
1306
|
+
// return json;
|
|
1307
|
+
// } catch ( error ) {
|
|
1308
|
+
// console.log( 'getGeocodedAddress error =>', error );
|
|
1309
|
+
// logger.error( { error: error, message: data, function: 'getGeocodedAddress' } );
|
|
1310
|
+
// }
|
|
1311
|
+
// }
|
|
1312
|
+
// let getGEO = await getGeocodedAddress( 12.900260100404893, 80.23384232089138 );
|
|
1313
|
+
// console.log( 'getGEO =>', getGEO );
|
|
@@ -198,3 +198,12 @@ export const validateHeaderSchema = joi.object( {
|
|
|
198
198
|
export const validateHeaderParams = {
|
|
199
199
|
body: validateHeaderSchema,
|
|
200
200
|
};
|
|
201
|
+
|
|
202
|
+
export const getMyProductSchema = joi.object( {
|
|
203
|
+
clientId: joi.string().required(),
|
|
204
|
+
storeId: joi.array().optional().empty(),
|
|
205
|
+
} );
|
|
206
|
+
|
|
207
|
+
export const getMyProductParams = {
|
|
208
|
+
body: getMyProductSchema,
|
|
209
|
+
};
|
|
@@ -46,11 +46,13 @@ import {
|
|
|
46
46
|
footfallTrendV1,
|
|
47
47
|
storeOperationV1,
|
|
48
48
|
performanceMatrixV1,
|
|
49
|
+
zoneDwellTimeSplitV1,
|
|
49
50
|
storesMapV1,
|
|
50
51
|
headerStoresV1,
|
|
51
52
|
headerLocationsV1,
|
|
52
53
|
headerGroupsV1,
|
|
53
54
|
isAllowedClient,
|
|
55
|
+
getMySubscription,
|
|
54
56
|
} from '../controllers/tangoTrafficV1.controllers.js';
|
|
55
57
|
|
|
56
58
|
|
|
@@ -157,6 +159,11 @@ analysisTrafficRouter
|
|
|
157
159
|
{ featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
|
|
158
160
|
],
|
|
159
161
|
} ), validate( validationDtos.validateperformanceMatrixParams ), performanceMatrixV1 )
|
|
162
|
+
.post( '/zoneDwellTimeSplit_v1', isAllowedSessionHandler, isAllowedClient, authorize( {
|
|
163
|
+
userType: [ 'tango', 'client' ], access: [
|
|
164
|
+
{ featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
|
|
165
|
+
],
|
|
166
|
+
} ), validate( validationDtos.validateStoreOperationParams ), zoneDwellTimeSplitV1 )
|
|
160
167
|
.post( '/storesMap_v1', isAllowedSessionHandler, isAllowedClient, authorize( {
|
|
161
168
|
userType: [ 'tango', 'client' ], access: [
|
|
162
169
|
{ featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
|
|
@@ -176,6 +183,7 @@ analysisTrafficRouter
|
|
|
176
183
|
userType: [ 'tango', 'client' ], access: [
|
|
177
184
|
{ featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
|
|
178
185
|
],
|
|
179
|
-
} ), validate( validationDtos.validateHeaderParams ), headerStoresV1 )
|
|
186
|
+
} ), validate( validationDtos.validateHeaderParams ), headerStoresV1 )
|
|
187
|
+
.post( '/getMySubscription', isAllowedSessionHandler, validate( validationDtos.getMyProductParams ), getMySubscription );
|
|
180
188
|
|
|
181
189
|
export default analysisTrafficRouter;
|