tango-app-api-analysis-traffic 3.0.0-alpha.13 → 3.0.0-alpha.15
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,4 +1,4 @@
|
|
|
1
|
-
import { logger, download } from 'tango-app-api-middleware';
|
|
1
|
+
import { logger, download, signedUrl } from 'tango-app-api-middleware';
|
|
2
2
|
import * as clientService from '../services/clients.services.js';
|
|
3
3
|
import {
|
|
4
4
|
aggregateStore,
|
|
@@ -9,6 +9,7 @@ import { aggregateGroup } from '../services/group.service.js';
|
|
|
9
9
|
import dayjs from 'dayjs';
|
|
10
10
|
import mongoose from 'mongoose';
|
|
11
11
|
const ObjectId = mongoose.Types.ObjectId;
|
|
12
|
+
import { findCamera } from '../services/camera.service.js';
|
|
12
13
|
|
|
13
14
|
// Lamda Service Call //
|
|
14
15
|
async function LamdaServiceCall( url, data ) {
|
|
@@ -1258,13 +1259,46 @@ export const getMySubscription = async ( req, res ) => {
|
|
|
1258
1259
|
if ( getClientData ) {
|
|
1259
1260
|
if ( getClientData.planDetails && getClientData.planDetails.product && getClientData.planDetails.product.length>0 ) {
|
|
1260
1261
|
let clientSubscription = {};
|
|
1262
|
+
let clientProducts = {
|
|
1263
|
+
tangoTraffic: false,
|
|
1264
|
+
tangoZone: false,
|
|
1265
|
+
tangoTrax: false,
|
|
1266
|
+
};
|
|
1261
1267
|
clientSubscription.subscriptionType = getClientData.planDetails.subscriptionType;
|
|
1262
|
-
|
|
1268
|
+
let actualProduct = getClientData.planDetails.product;
|
|
1269
|
+
for ( let clientIndex = 0; clientIndex < actualProduct.length; clientIndex++ ) {
|
|
1270
|
+
if ( actualProduct[clientIndex].productName == 'tangoTraffic' ) {
|
|
1271
|
+
clientProducts.tangoTraffic = true;
|
|
1272
|
+
}
|
|
1273
|
+
if ( actualProduct[clientIndex].productName == 'tangoZone' ) {
|
|
1274
|
+
clientProducts.tangoZone = true;
|
|
1275
|
+
}
|
|
1276
|
+
if ( actualProduct[clientIndex].tangoTrax == 'tangoTrax' ) {
|
|
1277
|
+
clientProducts.tangoTrax = true;
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
clientSubscription.product = clientProducts;
|
|
1263
1281
|
let storeSubscription = {};
|
|
1282
|
+
let storeProducts = {
|
|
1283
|
+
tangoTraffic: false,
|
|
1284
|
+
tangoZone: false,
|
|
1285
|
+
tangoTrax: false,
|
|
1286
|
+
};
|
|
1264
1287
|
if ( reqestData.storeId && reqestData.storeId.length>0 ) {
|
|
1265
1288
|
let getStoreData = await findOneStore( { clientId: reqestData.clientId, storeId: { $in: reqestData.storeId[0] } }, { product: 1 } );
|
|
1266
1289
|
if ( getStoreData ) {
|
|
1267
|
-
|
|
1290
|
+
for ( let storeIndex = 0; storeIndex < getStoreData.product.length; storeIndex++ ) {
|
|
1291
|
+
if ( getStoreData.product[storeIndex] == 'tangoTraffic' ) {
|
|
1292
|
+
storeProducts.tangoTraffic = true;
|
|
1293
|
+
}
|
|
1294
|
+
if ( getStoreData.product[storeIndex] == 'tangoZone' ) {
|
|
1295
|
+
storeProducts.tangoZone = true;
|
|
1296
|
+
}
|
|
1297
|
+
if ( getStoreData.product[storeIndex] == 'tangoTrax' ) {
|
|
1298
|
+
storeProducts.tangoTrax = true;
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
storeSubscription.product = storeProducts;
|
|
1268
1302
|
} else {
|
|
1269
1303
|
storeSubscription.product = [];
|
|
1270
1304
|
}
|
|
@@ -1285,6 +1319,37 @@ export const getMySubscription = async ( req, res ) => {
|
|
|
1285
1319
|
}
|
|
1286
1320
|
};
|
|
1287
1321
|
|
|
1322
|
+
export const getStoreCameraImage = async ( req, res ) => {
|
|
1323
|
+
try {
|
|
1324
|
+
let reqestData = req.body;
|
|
1325
|
+
if ( reqestData.storeId && reqestData.storeId.length > 0 ) {
|
|
1326
|
+
const bucket= JSON.parse( process.env.BUCKET );
|
|
1327
|
+
if ( bucket && bucket.baseImage && bucket.baseImage != '' ) {
|
|
1328
|
+
const camera = await findCamera( { storeId: reqestData.storeId[0], isUp: true, isActivated: true }, { thumbnailImage: 1 } );
|
|
1329
|
+
if ( camera && camera.thumbnailImage && camera.thumbnailImage != '' ) {
|
|
1330
|
+
const params = {
|
|
1331
|
+
file_path: camera.thumbnailImage,
|
|
1332
|
+
Bucket: bucket.baseImage,
|
|
1333
|
+
};
|
|
1334
|
+
let cameraBaseImage = await signedUrl( params );
|
|
1335
|
+
let resultData = { cameraBaseImage: cameraBaseImage };
|
|
1336
|
+
|
|
1337
|
+
return res.sendSuccess( resultData );
|
|
1338
|
+
} else {
|
|
1339
|
+
return res.sendError( 'No Camera', 400 );
|
|
1340
|
+
}
|
|
1341
|
+
} else {
|
|
1342
|
+
return res.sendError( 'Bucket Name Missing', 400 );
|
|
1343
|
+
}
|
|
1344
|
+
} else {
|
|
1345
|
+
return res.sendError( 'Store Id rewuired', 400 );
|
|
1346
|
+
}
|
|
1347
|
+
} catch ( error ) {
|
|
1348
|
+
logger.error( { error: error, message: req.query, function: 'getMySubscription' } );
|
|
1349
|
+
return res.sendError( { error: error }, 500 );
|
|
1350
|
+
}
|
|
1351
|
+
};
|
|
1352
|
+
|
|
1288
1353
|
// async function getGeocodedAddress( lat, lng ) {
|
|
1289
1354
|
// try {
|
|
1290
1355
|
// const apiKey = 'AIzaSyDlOezgwQO0JviD0aizrCuN1FY9tcWfR3o'; // Use this if you're using dotenv
|
|
@@ -207,3 +207,12 @@ export const getMyProductSchema = joi.object( {
|
|
|
207
207
|
export const getMyProductParams = {
|
|
208
208
|
body: getMyProductSchema,
|
|
209
209
|
};
|
|
210
|
+
|
|
211
|
+
export const getStoreCameraImageSchema = joi.object( {
|
|
212
|
+
clientId: joi.string().required(),
|
|
213
|
+
storeId: joi.array().optional().empty(),
|
|
214
|
+
} );
|
|
215
|
+
|
|
216
|
+
export const getStoreCameraImageParams = {
|
|
217
|
+
body: getStoreCameraImageSchema,
|
|
218
|
+
};
|
|
@@ -53,6 +53,7 @@ import {
|
|
|
53
53
|
headerGroupsV1,
|
|
54
54
|
isAllowedClient,
|
|
55
55
|
getMySubscription,
|
|
56
|
+
getStoreCameraImage,
|
|
56
57
|
} from '../controllers/tangoTrafficV1.controllers.js';
|
|
57
58
|
|
|
58
59
|
|
|
@@ -184,6 +185,7 @@ analysisTrafficRouter
|
|
|
184
185
|
{ featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
|
|
185
186
|
],
|
|
186
187
|
} ), validate( validationDtos.validateHeaderParams ), headerStoresV1 )
|
|
187
|
-
.post( '/getMySubscription', isAllowedSessionHandler, validate( validationDtos.getMyProductParams ), getMySubscription )
|
|
188
|
+
.post( '/getMySubscription', isAllowedSessionHandler, validate( validationDtos.getMyProductParams ), getMySubscription )
|
|
189
|
+
.post( '/getStoreCameraImage', isAllowedSessionHandler, validate( validationDtos.getStoreCameraImageParams ), getStoreCameraImage );
|
|
188
190
|
|
|
189
191
|
export default analysisTrafficRouter;
|