tango-app-api-client 3.0.0 → 3.0.2
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 +7 -3
- package/src/controllers/client.controllers.js +577 -3
- package/src/dtos/client.dtos.js +231 -0
- package/src/routes/client.routes.js +24 -6
- package/src/service/camera.service.js +9 -0
- package/src/service/client.service.js +239 -8
- package/src/service/store.service.js +9 -0
- package/src/service/user.service.js +9 -0
- package/src/services/client.services.js +263 -0
- package/src/validations/client.validations.js +22 -2
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import clientModel from 'tango-api-schema/schema/client.model.js';
|
|
2
|
+
import leadModel from 'tango-api-schema/schema/lead.model.js';
|
|
3
|
+
import storeModel from 'tango-api-schema/schema/store.model.js';
|
|
4
|
+
import userModel from 'tango-api-schema/schema/user.model.js';
|
|
5
|
+
// import { createQueue, getQueueUrl } from 'tango-app-api-middleware';
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
export function update( query, record ) {
|
|
9
|
+
return leadModel.updateMany( query, { $set: record } );
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function findOne( query, field ) {
|
|
13
|
+
return leadModel.findOne( query, field );
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function getClientCount( query ) {
|
|
17
|
+
return clientModel.countDocuments( query );
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function insert( record ) {
|
|
21
|
+
return clientModel.insertMany( record );
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function find( query, field ) {
|
|
25
|
+
return clientModel.find( query, field );
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export async function createAuditQueue( queueName ) {
|
|
29
|
+
try {
|
|
30
|
+
// const isExist = await getQueueUrl( `${queueName}${config.aws.sqs.queueType}` );
|
|
31
|
+
// if ( isExist.statusCode ) {
|
|
32
|
+
// const addQueue = await createQueue( `${queueName}${config.aws.sqs.queueType}` );
|
|
33
|
+
// if ( addQueue.QueueUrl ) {
|
|
34
|
+
// logger.info(
|
|
35
|
+
// 'Queueue Created'
|
|
36
|
+
// , { queueName: addQueue.QueueUrl, addQueue },
|
|
37
|
+
// );
|
|
38
|
+
// } else {
|
|
39
|
+
// logger.error( { error: 'Queue creation failed', function: 'createAuditQueue' } );
|
|
40
|
+
// }
|
|
41
|
+
// } else {
|
|
42
|
+
// logger.error( { error: 'Queue already exisit', message: queueName, function: 'createAuditQueue' } );
|
|
43
|
+
// }
|
|
44
|
+
return true;
|
|
45
|
+
} catch ( error ) {
|
|
46
|
+
return false;
|
|
47
|
+
logger.error( { error: error, message: queueName, function: 'createAuditQueue' } );
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
export function getClientData( { id } ) {
|
|
53
|
+
return clientModel.findOne( { clientId: id } );
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function getUserData( { id } ) {
|
|
57
|
+
return userModel.findOne( { _id: id }, { email: 1, countryCode: 1, mobileNumber: 1 } );
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function brandInfoUpdate( { clientId, registeredCompanyName, industry, clientType, registeredAddress, headQuarters, website, status, logo } ) {
|
|
61
|
+
return clientModel.updateOne( { clientId: clientId },
|
|
62
|
+
{
|
|
63
|
+
$set: {
|
|
64
|
+
'profileDetails.registeredCompanyName': registeredCompanyName,
|
|
65
|
+
'profileDetails.industry': industry,
|
|
66
|
+
'profileDetails.clientType': clientType,
|
|
67
|
+
'profileDetails.registeredAddress': registeredAddress,
|
|
68
|
+
'profileDetails.headQuarters': headQuarters,
|
|
69
|
+
'profileDetails.website': website,
|
|
70
|
+
'profileDetails.logo': logo,
|
|
71
|
+
'status': status,
|
|
72
|
+
},
|
|
73
|
+
} );
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function billingDetailsUpdate( { clientId, tradeName, gstNumber, authorityName, authorityEmail, billingAddress, gstCertificate } ) {
|
|
77
|
+
return clientModel.updateOne( { clientId: clientId },
|
|
78
|
+
{
|
|
79
|
+
$set: {
|
|
80
|
+
'billingDetails.tradeName': tradeName,
|
|
81
|
+
'billingDetails.gstNumber': gstNumber,
|
|
82
|
+
'billingDetails.authorityName': authorityName,
|
|
83
|
+
'billingDetails.authorityEmail': authorityEmail,
|
|
84
|
+
'billingDetails.billingAddress': billingAddress,
|
|
85
|
+
'document.gst.number': gstNumber,
|
|
86
|
+
'document.gst.path': gstCertificate,
|
|
87
|
+
},
|
|
88
|
+
} );
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export function signatoryDetailsUpdate( { clientId, name, email, number, designation } ) {
|
|
92
|
+
return clientModel.updateOne( { clientId: clientId },
|
|
93
|
+
{
|
|
94
|
+
$set: {
|
|
95
|
+
'signatoryDetail.name': name,
|
|
96
|
+
'signatoryDetail.email': email,
|
|
97
|
+
'signatoryDetail.number': number,
|
|
98
|
+
'signatoryDetail.designation': designation,
|
|
99
|
+
},
|
|
100
|
+
} );
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export function ticketConfigurationUpdate( {
|
|
104
|
+
clientId, MinFilesCount, accuracyPercentage, downTimeType, infraDownTime, installationReAssign, isRcaTicketAssign,
|
|
105
|
+
isRefreshAlert, isStatusCheckAlert, rcaTicketAssign, reTrain, refreshAlert, sendToAdmin, sendToUser, statusCheckAlert,
|
|
106
|
+
} ) {
|
|
107
|
+
return clientModel.updateOne( { clientId: clientId },
|
|
108
|
+
{
|
|
109
|
+
$set: {
|
|
110
|
+
'ticketConfigs.installationReAssign': installationReAssign,
|
|
111
|
+
'ticketConfigs.alertSentTo.admin': sendToAdmin,
|
|
112
|
+
'ticketConfigs.alertSentTo.user': sendToUser,
|
|
113
|
+
'ticketConfigs.downTimeType': downTimeType,
|
|
114
|
+
'ticketConfigs.infraDownTime': infraDownTime,
|
|
115
|
+
'ticketConfigs.MinFilesCount': MinFilesCount,
|
|
116
|
+
'ticketConfigs.isRcaTicketAssign': isRcaTicketAssign,
|
|
117
|
+
'ticketConfigs.rcaTicketAssign': rcaTicketAssign,
|
|
118
|
+
'ticketConfigs.isRefreshAlert': isRefreshAlert,
|
|
119
|
+
'ticketConfigs.refreshAlert': refreshAlert,
|
|
120
|
+
'ticketConfigs.isStatusCheckAlert': isStatusCheckAlert,
|
|
121
|
+
'ticketConfigs.statusCheckAlert': statusCheckAlert,
|
|
122
|
+
'ticketConfigs.reTrain': reTrain,
|
|
123
|
+
'ticketConfigs.accuracyPercentage': accuracyPercentage,
|
|
124
|
+
},
|
|
125
|
+
} );
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export function featureConfigurationUpdate( {
|
|
129
|
+
clientId, billableCalculation, bouncedLimitCondition, bouncedLimitValue,
|
|
130
|
+
close, conversionCalculation, conversionCondition,
|
|
131
|
+
conversionValue, infraAlertCondition, infraAlertValue, isFootfallDirectory,
|
|
132
|
+
isNormalized, isPasserByData, missedOpportunityCalculation, open,
|
|
133
|
+
} ) {
|
|
134
|
+
return clientModel.updateOne( { clientId: clientId },
|
|
135
|
+
{
|
|
136
|
+
$set: {
|
|
137
|
+
'featureConfigs.open': open,
|
|
138
|
+
'featureConfigs.close': close,
|
|
139
|
+
'featureConfigs.infraAlert.condition': infraAlertCondition,
|
|
140
|
+
'featureConfigs.infraAlert.value': infraAlertValue,
|
|
141
|
+
'featureConfigs.bouncedLimit.condition': bouncedLimitCondition,
|
|
142
|
+
'featureConfigs.bouncedLimit.value': bouncedLimitValue,
|
|
143
|
+
'featureConfigs.conversion.condition': conversionCondition,
|
|
144
|
+
'featureConfigs.conversion.value': conversionValue,
|
|
145
|
+
'featureConfigs.billableCalculation': billableCalculation,
|
|
146
|
+
'featureConfigs.missedOpportunityCalculation': missedOpportunityCalculation,
|
|
147
|
+
'featureConfigs.conversionCalculation': conversionCalculation,
|
|
148
|
+
'featureConfigs.isNormalized': isNormalized,
|
|
149
|
+
'featureConfigs.isPasserByData': isPasserByData,
|
|
150
|
+
'featureConfigs.isFootfallDirectory': isFootfallDirectory,
|
|
151
|
+
},
|
|
152
|
+
} );
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export function domainDetailsConfigurationUpdate( { clientId, domainName, isEnable } ) {
|
|
156
|
+
return clientModel.updateOne( { clientId: clientId },
|
|
157
|
+
{
|
|
158
|
+
$set: {
|
|
159
|
+
'ssoLogin.domainName': domainName,
|
|
160
|
+
'ssoLogin.isEnable': isEnable,
|
|
161
|
+
},
|
|
162
|
+
} );
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export function userConfigurationUpdate( { clientId, csm, ops } ) {
|
|
166
|
+
return clientModel.updateOne( { clientId: clientId },
|
|
167
|
+
{
|
|
168
|
+
$set: {
|
|
169
|
+
'assignedUsers.csm': csm,
|
|
170
|
+
'assignedUsers.ops': ops,
|
|
171
|
+
},
|
|
172
|
+
} );
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export function documentsUpdate( { clientId, gstNumber, panNumber, cinNumber, addressDoc, gstDoc, panDoc, cinDoc } ) {
|
|
176
|
+
return clientModel.updateOne( { clientId: clientId },
|
|
177
|
+
{
|
|
178
|
+
$set: {
|
|
179
|
+
'document.addressProof.path': addressDoc,
|
|
180
|
+
'document.gst.number': gstNumber,
|
|
181
|
+
'document.gst.path': gstDoc,
|
|
182
|
+
'document.pan.number': panNumber,
|
|
183
|
+
'document.pan.path': panDoc,
|
|
184
|
+
'document.pan.number': panNumber,
|
|
185
|
+
'document.pan.path': panDoc,
|
|
186
|
+
'document.cin.number': cinNumber,
|
|
187
|
+
'document.cin.path': cinDoc,
|
|
188
|
+
},
|
|
189
|
+
} );
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export function auditConfigurationGet( { storeId } ) {
|
|
193
|
+
return storeModel.findOne( { storeId: storeId },
|
|
194
|
+
{
|
|
195
|
+
'auditConfigs.count': 1,
|
|
196
|
+
'auditConfigs.iteration': 1,
|
|
197
|
+
'auditConfigs.ratio': 1,
|
|
198
|
+
'storeId': 1,
|
|
199
|
+
'_id': 0,
|
|
200
|
+
} );
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export function auditConfigurationUpdate( { storeId, count, iteration, ratio } ) {
|
|
204
|
+
return storeModel.updateOne( { storeId: storeId },
|
|
205
|
+
{
|
|
206
|
+
$set: {
|
|
207
|
+
'auditConfigs.count': count,
|
|
208
|
+
'auditConfigs.iteration': iteration,
|
|
209
|
+
'auditConfigs.ratio': ratio,
|
|
210
|
+
},
|
|
211
|
+
} );
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export function CsmUsersGet( ) {
|
|
215
|
+
return userModel.aggregate( [
|
|
216
|
+
{
|
|
217
|
+
$match: {
|
|
218
|
+
$and: [
|
|
219
|
+
{
|
|
220
|
+
$or: [
|
|
221
|
+
{
|
|
222
|
+
role: 'user',
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
role: 'admin',
|
|
226
|
+
},
|
|
227
|
+
],
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
userType: 'tango',
|
|
231
|
+
},
|
|
232
|
+
],
|
|
233
|
+
},
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
$project: {
|
|
237
|
+
userName: 1,
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
] );
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
export function OpsUsersGet( ) {
|
|
244
|
+
return userModel.aggregate( [
|
|
245
|
+
{
|
|
246
|
+
$match: {
|
|
247
|
+
$and: [
|
|
248
|
+
{
|
|
249
|
+
role: 'user',
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
userType: 'tango',
|
|
253
|
+
},
|
|
254
|
+
],
|
|
255
|
+
},
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
$project: {
|
|
259
|
+
userName: 1,
|
|
260
|
+
},
|
|
261
|
+
},
|
|
262
|
+
] );
|
|
263
|
+
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import model from 'tango-api-schema';
|
|
2
|
+
import { findOneClient } from '../service/client.service.js';
|
|
2
3
|
|
|
3
4
|
export async function isclientNameExists( req, res, next ) {
|
|
4
5
|
try {
|
|
5
6
|
const inputData = req.body;
|
|
6
|
-
const
|
|
7
|
-
if (
|
|
7
|
+
const client = await model.clientModel.findOne( { clientName: inputData?.clientName } );
|
|
8
|
+
if ( client ) {
|
|
8
9
|
return res.sendError( 'clientName is exists', 403 );
|
|
9
10
|
}
|
|
10
11
|
return next();
|
|
@@ -13,3 +14,22 @@ export async function isclientNameExists( req, res, next ) {
|
|
|
13
14
|
return res.sendError( error, 500 );
|
|
14
15
|
}
|
|
15
16
|
}
|
|
17
|
+
|
|
18
|
+
export async function isclientIdExists( req, res, next ) {
|
|
19
|
+
try {
|
|
20
|
+
const inputData = req.query;
|
|
21
|
+
const query = {
|
|
22
|
+
clientId: inputData?.clientId,
|
|
23
|
+
};
|
|
24
|
+
const client = await findOneClient( query );
|
|
25
|
+
if ( !client ) {
|
|
26
|
+
return res.sendError( { error: `client doesn't exists` }, 204 );
|
|
27
|
+
}
|
|
28
|
+
req.query.clientName = client.clientName;
|
|
29
|
+
req.query.userId = client.userId;
|
|
30
|
+
return next();
|
|
31
|
+
} catch ( error ) {
|
|
32
|
+
logger.error( { error: error, function: 'isclientIdExists' } );
|
|
33
|
+
return res.sendError( error, 500 );
|
|
34
|
+
}
|
|
35
|
+
}
|