tango-app-api-analysis-traffic 3.0.0-alpha.12 → 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
|
|
|
@@ -499,7 +500,6 @@ export const storesMapV1 = async ( req, res ) => {
|
|
|
499
500
|
}
|
|
500
501
|
}
|
|
501
502
|
} catch ( error ) {
|
|
502
|
-
console.log( 'storesMapV1 error =>', error );
|
|
503
503
|
logger.error( { error: error, message: req.query, function: 'storesMapV1' } );
|
|
504
504
|
return res.sendError( { error: error }, 500 );
|
|
505
505
|
}
|
|
@@ -625,8 +625,7 @@ export const headerGroupsV1 = async ( req, res ) => {
|
|
|
625
625
|
return res.sendError( 'No Group', 400 );
|
|
626
626
|
}
|
|
627
627
|
} catch ( error ) {
|
|
628
|
-
|
|
629
|
-
logger.error( { error: error, message: req.query, function: 'trafficCards' } );
|
|
628
|
+
logger.error( { error: error, message: req.query, function: 'headerGroupsV1' } );
|
|
630
629
|
return res.sendError( { error: error }, 500 );
|
|
631
630
|
}
|
|
632
631
|
};
|
|
@@ -730,7 +729,6 @@ export const headerStoresV1 = async ( req, res ) => {
|
|
|
730
729
|
return res.sendError( 'No Stores', 400 );
|
|
731
730
|
}
|
|
732
731
|
} catch ( error ) {
|
|
733
|
-
console.log( 'headerStoresV1 =>', error );
|
|
734
732
|
logger.error( { error: error, message: req.query, function: 'headerStoresV1' } );
|
|
735
733
|
return res.sendError( { error: error }, 500 );
|
|
736
734
|
}
|
|
@@ -795,7 +793,6 @@ async function getAllStores( getUserEmail, getClientId, getUserType, getRole ) {
|
|
|
795
793
|
return false;
|
|
796
794
|
}
|
|
797
795
|
} catch ( error ) {
|
|
798
|
-
console.log( 'getAllStores =>', error );
|
|
799
796
|
logger.error( { error: error, message: req.query, function: 'getAllStores' } );
|
|
800
797
|
}
|
|
801
798
|
};
|
|
@@ -831,8 +828,8 @@ async function getAssignedStores( clientId, userEmail, assignedType ) {
|
|
|
831
828
|
return false;
|
|
832
829
|
}
|
|
833
830
|
} catch ( error ) {
|
|
834
|
-
console.log( 'getAssignedStores error =>', error );
|
|
835
831
|
logger.error( { error: error, message: data, function: 'getAssignedStores' } );
|
|
832
|
+
return false;
|
|
836
833
|
}
|
|
837
834
|
}
|
|
838
835
|
|
|
@@ -898,8 +895,8 @@ async function getAssignedGroupStores( clientId, userEmail, assignedType ) {
|
|
|
898
895
|
return false;
|
|
899
896
|
}
|
|
900
897
|
} catch ( error ) {
|
|
901
|
-
console.log( 'getAssignedGroupStores error =>', error );
|
|
902
898
|
logger.error( { error: error, message: data, function: 'getAssignedGroupStores' } );
|
|
899
|
+
return false;
|
|
903
900
|
}
|
|
904
901
|
}
|
|
905
902
|
|
|
@@ -933,8 +930,8 @@ async function getAssignedAllStores( userClientId ) {
|
|
|
933
930
|
return false;
|
|
934
931
|
}
|
|
935
932
|
} catch ( error ) {
|
|
936
|
-
console.log( 'getAssignedAllStores error =>', error );
|
|
937
933
|
logger.error( { error: error, message: data, function: 'getAssignedAllStores' } );
|
|
934
|
+
return false;
|
|
938
935
|
}
|
|
939
936
|
}
|
|
940
937
|
|
|
@@ -973,8 +970,8 @@ async function getGroupStores( userClientId, groupList ) {
|
|
|
973
970
|
return false;
|
|
974
971
|
}
|
|
975
972
|
} catch ( error ) {
|
|
976
|
-
console.log( 'getGroupStores error =>', error );
|
|
977
973
|
logger.error( { error: error, message: data, function: 'getGroupStores' } );
|
|
974
|
+
return false;
|
|
978
975
|
}
|
|
979
976
|
}
|
|
980
977
|
|
|
@@ -1014,8 +1011,8 @@ async function getLocationStores( userClientId, cityList ) {
|
|
|
1014
1011
|
return false;
|
|
1015
1012
|
}
|
|
1016
1013
|
} catch ( error ) {
|
|
1017
|
-
console.log( 'getLocationStores error =>', error );
|
|
1018
1014
|
logger.error( { error: error, message: data, function: 'getLocationStores' } );
|
|
1015
|
+
return false;
|
|
1019
1016
|
}
|
|
1020
1017
|
}
|
|
1021
1018
|
|
|
@@ -1048,8 +1045,8 @@ async function getGroupIds( userClientId ) {
|
|
|
1048
1045
|
return false;
|
|
1049
1046
|
}
|
|
1050
1047
|
} catch ( error ) {
|
|
1051
|
-
console.log( 'getGroupIds error =>', error );
|
|
1052
1048
|
logger.error( { error: error, message: data, function: 'getGroupIds' } );
|
|
1049
|
+
return false;
|
|
1053
1050
|
}
|
|
1054
1051
|
}
|
|
1055
1052
|
|
|
@@ -1088,8 +1085,8 @@ async function getAssignedGroupIds( userClientId, getUserEmail ) {
|
|
|
1088
1085
|
return false;
|
|
1089
1086
|
}
|
|
1090
1087
|
} catch ( error ) {
|
|
1091
|
-
console.log( 'getAssignedGroupIds error =>', error );
|
|
1092
1088
|
logger.error( { error: error, message: data, function: 'getAssignedGroupIds' } );
|
|
1089
|
+
return false;
|
|
1093
1090
|
}
|
|
1094
1091
|
}
|
|
1095
1092
|
|
|
@@ -1111,8 +1108,8 @@ async function getCityStores( userClientId, getUserEmail, getRole, requestCity,
|
|
|
1111
1108
|
return false;
|
|
1112
1109
|
}
|
|
1113
1110
|
} catch ( error ) {
|
|
1114
|
-
console.log( 'getAssignedGroupIds error =>', error );
|
|
1115
1111
|
logger.error( { error: error, message: data, function: 'getAssignedGroupIds' } );
|
|
1112
|
+
return false;
|
|
1116
1113
|
}
|
|
1117
1114
|
}
|
|
1118
1115
|
|
|
@@ -1211,8 +1208,8 @@ async function getGroupStoresIds( userClientId, storeIds, getRole, getUserType,
|
|
|
1211
1208
|
return false;
|
|
1212
1209
|
}
|
|
1213
1210
|
} catch ( error ) {
|
|
1214
|
-
console.log( 'getGroupIds error =>', error );
|
|
1215
1211
|
logger.error( { error: error, message: data, function: 'getGroupIds' } );
|
|
1212
|
+
return false;
|
|
1216
1213
|
}
|
|
1217
1214
|
}
|
|
1218
1215
|
|
|
@@ -1254,6 +1251,40 @@ export async function isAllowedClient( req, res, next ) {
|
|
|
1254
1251
|
}
|
|
1255
1252
|
}
|
|
1256
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
|
+
|
|
1257
1288
|
// async function getGeocodedAddress( lat, lng ) {
|
|
1258
1289
|
// try {
|
|
1259
1290
|
// const apiKey = 'AIzaSyDlOezgwQO0JviD0aizrCuN1FY9tcWfR3o'; // Use this if you're using dotenv
|
|
@@ -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
|
+
};
|
|
@@ -52,6 +52,7 @@ import {
|
|
|
52
52
|
headerLocationsV1,
|
|
53
53
|
headerGroupsV1,
|
|
54
54
|
isAllowedClient,
|
|
55
|
+
getMySubscription,
|
|
55
56
|
} from '../controllers/tangoTrafficV1.controllers.js';
|
|
56
57
|
|
|
57
58
|
|
|
@@ -182,6 +183,7 @@ analysisTrafficRouter
|
|
|
182
183
|
userType: [ 'tango', 'client' ], access: [
|
|
183
184
|
{ featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
|
|
184
185
|
],
|
|
185
|
-
} ), validate( validationDtos.validateHeaderParams ), headerStoresV1 )
|
|
186
|
+
} ), validate( validationDtos.validateHeaderParams ), headerStoresV1 )
|
|
187
|
+
.post( '/getMySubscription', isAllowedSessionHandler, validate( validationDtos.getMyProductParams ), getMySubscription );
|
|
186
188
|
|
|
187
189
|
export default analysisTrafficRouter;
|