tango-app-api-infra 3.1.29 → 3.1.30

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-infra",
3
- "version": "3.1.29",
3
+ "version": "3.1.30",
4
4
  "description": "infra",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -69,6 +69,19 @@ export async function createTicket( req, res ) {
69
69
  showToClient: req.body.showToClient,
70
70
  processType: ( auditInputData?.data?.length && auditOutputData?.data?.length ) ? 'audit' : 'reduction',
71
71
  };
72
+
73
+ const reqData = {
74
+ 'dateString': dayjs( new Date( req.body.Date ) ).format( 'YYYY-MM-DD' ),
75
+ 'storeId': req.body.storeId,
76
+ };
77
+
78
+
79
+ const getFootfall = await postApi( `${JSON.parse( process.env.URL ).oldapidomain}/getFootfall`, reqData );
80
+
81
+ if ( getFootfall?.data?.length ) {
82
+ req.body.dataMismatch['reportedFootfall'] = getFootfall.data[0].footfall_count;
83
+ }
84
+
72
85
  req.body.issueDate = new Date( req.body.Date );
73
86
  req.body.ticketId = 'TE_DM_' + new Date().valueOf();
74
87
  let create = await createTangoTicket( req.body );
@@ -118,6 +131,25 @@ export async function createTicket( req, res ) {
118
131
  }
119
132
  }
120
133
 
134
+ async function postApi( url, data ) {
135
+ const requestOptions = {
136
+ method: 'POST',
137
+ headers: {
138
+ 'Content-Type': 'application/json',
139
+ 'Authorization': 'Bearer d47433f8-9a33-47c7-ba43-1a0fbac28f66',
140
+ },
141
+ body: JSON.stringify( data ),
142
+ };
143
+
144
+ try {
145
+ const response = await fetch( url, requestOptions );
146
+ const data = await response.json();
147
+ return data;
148
+ } catch ( error ) {
149
+ logger.error( { error: error, message: data, function: 'postApi' } );
150
+ }
151
+ }
152
+
121
153
  export async function updateMat( req, res ) {
122
154
  try {
123
155
  let updateValue = {};
@@ -912,6 +912,12 @@ export async function getInfraIssues( req, res ) {
912
912
  camera[index].thumbnailImage = await signedUrl( { Bucket: JSON.parse( process.env.BUCKET ).baseImage, file_path: camera[index].thumbnailImage } );
913
913
  }
914
914
  }
915
+
916
+ // for ( let i =0; i< mergeValue.length; i++ ) {
917
+ // let issueDateChanged = new Date( mergeValue[i].issueDate );
918
+ // mergeValue[i].issueDate = dayjs( issueDateChanged ).format( 'DD-MM-YYYY' );
919
+ // }
920
+
915
921
  logger.info( { message: camera } );
916
922
  return res.sendSuccess( { result: mergeValue, streams: camera, highCountTicketDetails: getHighCountTicket[0] || defaultValue } );
917
923
  } catch ( error ) {