cityworks 0.0.1 → 0.0.5
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/README.md +2 -2
- package/package.json +7 -7
- package/src/inspection.ts +659 -45
- package/src/request.ts +470 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ This API wrapper for Cityworks follows the Cityworks release schedule as closely
|
|
|
4
4
|
|
|
5
5
|
Require the class:
|
|
6
6
|
|
|
7
|
-
var cityworks = require('
|
|
7
|
+
var cityworks = require('cityworks');
|
|
8
8
|
|
|
9
9
|
Configure the instance that is then available:
|
|
10
10
|
|
|
@@ -19,7 +19,7 @@ Authenticate with the Cityworks install:
|
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
Get the currently valid
|
|
22
|
+
Get the currently valid token in order to store it in a session or cookie:
|
|
23
23
|
|
|
24
24
|
cityworks.getToken();
|
|
25
25
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cityworks",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "A Cityworks API wrapper",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"umd:main": "dist/index.umd.js",
|
|
@@ -20,21 +20,22 @@
|
|
|
20
20
|
"url": "git+https://github.com/walker/cityworks.git"
|
|
21
21
|
},
|
|
22
22
|
"keywords": [
|
|
23
|
-
"
|
|
23
|
+
"cityworks",
|
|
24
24
|
"api",
|
|
25
25
|
"wrapper",
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
26
|
+
"government",
|
|
27
|
+
"local",
|
|
28
|
+
"asset"
|
|
29
29
|
],
|
|
30
30
|
"author": "Walker",
|
|
31
31
|
"license": "MIT",
|
|
32
32
|
"bugs": {
|
|
33
33
|
"url": "https://github.com/walker/cityworks/issues"
|
|
34
34
|
},
|
|
35
|
-
"homepage": "https://github.
|
|
35
|
+
"homepage": "https://walker.github.io/cityworks/",
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"chai": "*",
|
|
38
|
+
"chai-as-promised": "^7.1.1",
|
|
38
39
|
"dotenv": "^10.0.0",
|
|
39
40
|
"jsdoc-to-markdown": "^7.0.1",
|
|
40
41
|
"microbundle": "^0.13.3",
|
|
@@ -44,7 +45,6 @@
|
|
|
44
45
|
"winston": "^3.3.3"
|
|
45
46
|
},
|
|
46
47
|
"dependencies": {
|
|
47
|
-
"chai-as-promised": "^7.1.1",
|
|
48
48
|
"lodash": "^4.17.21",
|
|
49
49
|
"reversible-map": "^1.0.1"
|
|
50
50
|
}
|
package/src/inspection.ts
CHANGED
|
@@ -7,43 +7,133 @@ export class Inspection {
|
|
|
7
7
|
/**
|
|
8
8
|
* Construct activity link object for Inspection functions
|
|
9
9
|
*
|
|
10
|
-
* @param {
|
|
10
|
+
* @param {Object} cw - Feed in the cityworks object instance so that this instance has access to the runRequest from the recursively-linked Cityworks instance
|
|
11
11
|
* @return {Object} Returns object that is this module
|
|
12
12
|
*/
|
|
13
13
|
constructor(cw) {
|
|
14
|
-
this.cw = cw
|
|
14
|
+
this.cw = cw
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
-
* Create new inspection
|
|
18
|
+
* Create new inspection
|
|
19
19
|
*
|
|
20
|
-
* @
|
|
21
|
-
* @
|
|
20
|
+
* @category Inspections
|
|
21
|
+
* @param {Object} insp_data - See /{subdirectory}/apidocs/#/data-type-info;dataType=InspectionBase on your Cityworks instance
|
|
22
|
+
* @return {Object} Returns Promise that represents an object describing the newly-created inspection
|
|
22
23
|
*/
|
|
23
24
|
create(insp_data: Object) {
|
|
24
25
|
return new Promise((resolve, reject) => {
|
|
25
|
-
if(
|
|
26
|
-
reject(new CWError(1, 'EntityType and InspTemplateId properties must be provided.', {'provided': insp_data}))
|
|
26
|
+
if(!_.has(insp_data, 'EntityType') || !_.has(insp_data, 'InspTemplateId')) {
|
|
27
|
+
reject(new CWError(1, 'EntityType and InspTemplateId properties must be provided.', {'provided': insp_data}))
|
|
27
28
|
} else {
|
|
28
29
|
this.cw.runRequest('Ams/Inspection/Create', insp_data).then(r => {
|
|
29
|
-
resolve(r.Value)
|
|
30
|
+
resolve(r.Value)
|
|
30
31
|
}).catch(e => {
|
|
31
|
-
reject(e)
|
|
32
|
+
reject(e)
|
|
32
33
|
});
|
|
33
34
|
}
|
|
34
35
|
});
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
/**
|
|
38
|
-
*
|
|
39
|
+
* Create inspections from an array of entities
|
|
40
|
+
*
|
|
41
|
+
* @category Inspections
|
|
42
|
+
* @param {Object} insp_data - See /{subdirectory}/apidocs/#/data-type-info;dataType=InspectionBase on your Cityworks instance
|
|
43
|
+
* @return {Object} Returns Promise that represents a collection of objects describing the newly-created inspections
|
|
44
|
+
*/
|
|
45
|
+
createFromEntities(insp_data: Object) {
|
|
46
|
+
return new Promise((resolve, reject) => {
|
|
47
|
+
if(!_.has(insp_data, 'EntityType') || !_.has(insp_data, 'InspTemplateId')) {
|
|
48
|
+
reject(new CWError(1, 'EntityType and InspTemplateId properties must be provided.', {'provided': insp_data}));
|
|
49
|
+
} else {
|
|
50
|
+
this.cw.runRequest('Ams/Inspection/CreateFromEntities', insp_data).then(r => {
|
|
51
|
+
resolve(r.Value);
|
|
52
|
+
}).catch(e => {
|
|
53
|
+
reject(e);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Create an inspection from a parent inspection (TODO: what parent!?)
|
|
61
|
+
*
|
|
62
|
+
* @category Inspections
|
|
63
|
+
* @param {object} insp_data - See /{subdirectory}/apidocs/#/data-type-info;dataType=InspectionBase on your Cityworks instance
|
|
64
|
+
* @return {Object} Returns object that represents an object describing the newly-created inspection
|
|
65
|
+
*/
|
|
66
|
+
createFromParent(insp_data: Object) {
|
|
67
|
+
return new Promise((resolve, reject) => {
|
|
68
|
+
// see if it's just InspectionId
|
|
69
|
+
if(!_.has(insp_data, 'EntityType') || !_.has(insp_data, 'InspTemplateId') || !_.has(insp_data, 'InspectionId')) {
|
|
70
|
+
reject(new CWError(1, 'EntityType and InspTemplateId properties must be provided.', {'provided': insp_data}));
|
|
71
|
+
} else {
|
|
72
|
+
this.cw.runRequest('Ams/Inspection/CreateFromParent', insp_data).then(r => {
|
|
73
|
+
resolve(r.Value);
|
|
74
|
+
}).catch(e => {
|
|
75
|
+
reject(e);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Create an inspection from a service request
|
|
83
|
+
*
|
|
84
|
+
* @category Inspections
|
|
85
|
+
* @param {object} insp_data - See /{subdirectory}/apidocs/#/data-type-info;dataType=InspectionBase on your Cityworks instance
|
|
86
|
+
* @return {Object} Returns object that represents an object describing the newly-created inspection
|
|
87
|
+
*/
|
|
88
|
+
createFromServiceRequest(insp_data: Object) {
|
|
89
|
+
return new Promise((resolve, reject) => {
|
|
90
|
+
if(!_.has(insp_data, 'EntityType') || !_.has(insp_data, 'InspTemplateId') || !_.has(insp_data, 'RequestId')) {
|
|
91
|
+
reject(new CWError(1, 'EntityType and InspTemplateId properties must be provided.', {'provided': insp_data}));
|
|
92
|
+
} else {
|
|
93
|
+
this.cw.runRequest('Ams/Inspection/CreateFromServiceRequest', insp_data).then(r => {
|
|
94
|
+
resolve(r.Value);
|
|
95
|
+
}).catch(e => {
|
|
96
|
+
reject(e);
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Create an inspection from a work order
|
|
39
104
|
*
|
|
105
|
+
* @category Inspections
|
|
40
106
|
* @param {object} insp_data - See /{subdirectory}/apidocs/#/data-type-info;dataType=InspectionBase on your Cityworks instance
|
|
41
|
-
* @return {Object} Returns object that represents an object describing the
|
|
107
|
+
* @return {Object} Returns object that represents an object describing the newly-created inspection
|
|
108
|
+
*/
|
|
109
|
+
createFromWorkOrder(insp_data: Object) {
|
|
110
|
+
return new Promise((resolve, reject) => {
|
|
111
|
+
// Are they both actually required?!?!
|
|
112
|
+
// WorkOrderId
|
|
113
|
+
// WorkOrderSid ...do with only SID first then check
|
|
114
|
+
if(!_.has(insp_data, 'EntityType') || !_.has(insp_data, 'InspTemplateId') || !_.has(insp_data, 'WorkOrderSid')) {
|
|
115
|
+
reject(new CWError(1, 'EntityType and InspTemplateId properties must be provided.', {'provided': insp_data}));
|
|
116
|
+
} else {
|
|
117
|
+
this.cw.runRequest('Ams/Inspection/CreateFromWorkOrder', insp_data).then(r => {
|
|
118
|
+
resolve(r.Value);
|
|
119
|
+
}).catch(e => {
|
|
120
|
+
reject(e);
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Update an inspection
|
|
128
|
+
*
|
|
129
|
+
* @category Inspections
|
|
130
|
+
* @param {object} insp_data - See /{subdirectory}/apidocs/#/data-type-info;dataType=InspectionBase on the Cityworks instance
|
|
131
|
+
* @return {Object} Returns Promise that represents an object describing the updated inspection
|
|
42
132
|
*/
|
|
43
133
|
update(insp_data: Object) {
|
|
44
134
|
return new Promise((resolve, reject) => {
|
|
45
135
|
return new Promise((resolve, reject) => {
|
|
46
|
-
if(
|
|
136
|
+
if(!_.has(insp_data, 'InspectionId')) {
|
|
47
137
|
reject(new CWError(1, 'InspectionId must be provided.', {'provided': insp_data}));
|
|
48
138
|
} else {
|
|
49
139
|
this.cw.runRequest('Ams/Inspection/Update', insp_data).then(r => {
|
|
@@ -57,10 +147,11 @@ export class Inspection {
|
|
|
57
147
|
}
|
|
58
148
|
|
|
59
149
|
/**
|
|
60
|
-
* Get an inspection by
|
|
150
|
+
* Get an inspection by ID
|
|
61
151
|
*
|
|
152
|
+
* @category Inspections
|
|
62
153
|
* @param {number} inspectionId - The inspection ID to retrieve
|
|
63
|
-
* @return {Object} Returns
|
|
154
|
+
* @return {Object} Returns Promise that represents an object describing the inspection
|
|
64
155
|
*/
|
|
65
156
|
getById(inspectionId: number) {
|
|
66
157
|
return new Promise((resolve, reject) => {
|
|
@@ -76,10 +167,11 @@ export class Inspection {
|
|
|
76
167
|
}
|
|
77
168
|
|
|
78
169
|
/**
|
|
79
|
-
* Get inspections by
|
|
170
|
+
* Get inspections by array of IDs
|
|
80
171
|
*
|
|
81
|
-
* @
|
|
82
|
-
* @
|
|
172
|
+
* @category Inspections
|
|
173
|
+
* @param {Array<number>} inspectionIds - The inspection IDs to retrieve
|
|
174
|
+
* @return {Object} Returns Promise that represents a collection of Objects describing the inspections
|
|
83
175
|
*/
|
|
84
176
|
getByIds(inspectionIds: Array<number>) {
|
|
85
177
|
return new Promise((resolve, reject) => {
|
|
@@ -94,9 +186,117 @@ export class Inspection {
|
|
|
94
186
|
});
|
|
95
187
|
}
|
|
96
188
|
|
|
189
|
+
/**
|
|
190
|
+
* Cancel inspections
|
|
191
|
+
*
|
|
192
|
+
* @category Inspections
|
|
193
|
+
* @param {Array<number>} inspectionIds - An array of the IDs to cancel the matched inspections
|
|
194
|
+
* @param {string} [cancelReason] - A reason for cancelling the inspection(s)
|
|
195
|
+
* @param {datetime} [dateCancelled] - The date/time that it should be indicated the inspection was cancelled
|
|
196
|
+
* @return {Object} Returns object that represents a collection of inspections
|
|
197
|
+
*/
|
|
198
|
+
cancel(inspectionIds: Array<number>, cancelReason?: string, dateCancelled?: Date) {
|
|
199
|
+
return new Promise((resolve, reject) => {
|
|
200
|
+
var m = new Date();
|
|
201
|
+
var data: {InspectionIds: Array<number>, CancelReason?: string, DateCancelled?: Date} = { InspectionIds: inspectionIds };
|
|
202
|
+
if(typeof(cancelReason)!=='undefined') {
|
|
203
|
+
data.CancelReason = cancelReason;
|
|
204
|
+
}
|
|
205
|
+
if(typeof(dateCancelled)!=='undefined') {
|
|
206
|
+
data.DateCancelled = dateCancelled;
|
|
207
|
+
}
|
|
208
|
+
this.cw.runRequest('Ams/Inspection/Cancel', data).then(r => {
|
|
209
|
+
resolve(r.Value);
|
|
210
|
+
}).catch(e => {
|
|
211
|
+
reject(e);
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Uncancel inspections
|
|
218
|
+
*
|
|
219
|
+
* @category Requests
|
|
220
|
+
* @param {Array<number>} inspectionIds - An array of the IDs to uncancel the matched requests
|
|
221
|
+
* @return {Object} Returns object that represents a collection of requests
|
|
222
|
+
*/
|
|
223
|
+
uncancel(inspectionIds: Array<number>) {
|
|
224
|
+
return new Promise((resolve, reject) => {
|
|
225
|
+
var data = {
|
|
226
|
+
InspectionIds: inspectionIds
|
|
227
|
+
};
|
|
228
|
+
this.cw.runRequest('Ams/Inspection/Uncancel', data).then(r => {
|
|
229
|
+
resolve(r.Value);
|
|
230
|
+
}).catch(e => {
|
|
231
|
+
reject(e);
|
|
232
|
+
});
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Close inspections
|
|
238
|
+
*
|
|
239
|
+
* @category Inspections
|
|
240
|
+
* @param {Array<number>} inspectionIds - An array of the IDs to close the matched inspections
|
|
241
|
+
* @return {Object} Returns object that represents a collection of inspections
|
|
242
|
+
*/
|
|
243
|
+
close(inspectionIds: Array<number>) {
|
|
244
|
+
return new Promise((resolve, reject) => {
|
|
245
|
+
var data = {
|
|
246
|
+
InspectionIds: inspectionIds
|
|
247
|
+
};
|
|
248
|
+
this.cw.runRequest('Ams/Inspection/Close', data).then(r => {
|
|
249
|
+
resolve(r.Value);
|
|
250
|
+
}).catch(e => {
|
|
251
|
+
reject(e);
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Reopen closed inspections
|
|
258
|
+
*
|
|
259
|
+
* @category Inspections
|
|
260
|
+
* @param {Array<number>} inspectionIds - An array of the IDs to reopen the matched inspections
|
|
261
|
+
* @return {Object} Returns object that represents a collection of inspections
|
|
262
|
+
*/
|
|
263
|
+
reopen(inspectionIds: Array<number>) {
|
|
264
|
+
return new Promise((resolve, reject) => {
|
|
265
|
+
var data = {
|
|
266
|
+
InspectionIds: inspectionIds
|
|
267
|
+
};
|
|
268
|
+
this.cw.runRequest('Ams/Inspection/Reopen', data).then(r => {
|
|
269
|
+
resolve(r.Value);
|
|
270
|
+
}).catch(e => {
|
|
271
|
+
reject(e);
|
|
272
|
+
});
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Delete inspections
|
|
278
|
+
*
|
|
279
|
+
* @category Inspections
|
|
280
|
+
* @param {Array<number>} inspectionIds - An array of the IDs to delete the matched inspections
|
|
281
|
+
* @return {Object} Returns object that represents a collection of inspection Ids which have been deleted
|
|
282
|
+
*/
|
|
283
|
+
delete(inspectionIds: Array<number>) {
|
|
284
|
+
return new Promise((resolve, reject) => {
|
|
285
|
+
var data = {
|
|
286
|
+
InspectionIds: inspectionIds
|
|
287
|
+
};
|
|
288
|
+
this.cw.runRequest('Ams/Inspection/Delete', data).then(r => {
|
|
289
|
+
resolve(r.Value);
|
|
290
|
+
}).catch(e => {
|
|
291
|
+
reject(e);
|
|
292
|
+
});
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
|
|
97
296
|
/**
|
|
98
297
|
* Search for inspections
|
|
99
298
|
*
|
|
299
|
+
* @category Inspections
|
|
100
300
|
* @param {Object} searchData - An array of the IDs to retrieve the matched inspections, see instance docs: /{subdirectory}/apidocs/#/service-info/Ams/Inspection
|
|
101
301
|
* @return {Object} Returns object that represents an array of the matching inspection IDs
|
|
102
302
|
*/
|
|
@@ -114,6 +314,7 @@ export class Inspection {
|
|
|
114
314
|
/**
|
|
115
315
|
* Get list of statuses
|
|
116
316
|
*
|
|
317
|
+
* @category Inspection Options
|
|
117
318
|
* @return {Object} Returns object that represents an array of all possible statuses for an Inspection
|
|
118
319
|
*/
|
|
119
320
|
statuses() {
|
|
@@ -126,6 +327,371 @@ export class Inspection {
|
|
|
126
327
|
});
|
|
127
328
|
}
|
|
128
329
|
|
|
330
|
+
/**
|
|
331
|
+
* Get inspection submit to list
|
|
332
|
+
*
|
|
333
|
+
* @category Inspection Options
|
|
334
|
+
* @param {boolean} [includeInactiveEmployees] - whether to include inactive employees in the return. Defaults to false.
|
|
335
|
+
* @param {boolean} [domainIds] - which domains to include in the return, default to All domains
|
|
336
|
+
* @return {Object} Returns object that represents a collection of all possible employees for an Inspection's SubmitTo
|
|
337
|
+
*/
|
|
338
|
+
submitTos(includeInactiveEmployees: boolean = false, domainIds?: Array<number>) {
|
|
339
|
+
return new Promise((resolve, reject) => {
|
|
340
|
+
var data: {IncludeInactiveEmployees?: boolean, DomainIds?: Array<number>} = {};
|
|
341
|
+
if(includeInactiveEmployees) {
|
|
342
|
+
data.IncludeInactiveEmployees = true;
|
|
343
|
+
}
|
|
344
|
+
if(typeof(domainIds)!=='undefined') {
|
|
345
|
+
data.DomainIds = domainIds;
|
|
346
|
+
}
|
|
347
|
+
this.cw.runRequest('Ams/Inspection/SubmitTos', data).then(r => {
|
|
348
|
+
resolve(r.Value);
|
|
349
|
+
}).catch(e => {
|
|
350
|
+
reject(e);
|
|
351
|
+
});
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* Add an entity to an existing inspection
|
|
358
|
+
* This method requires an Entity/Asset to be specified. You can either specify the Entity Type and its UID or a WorkOrderEntityBase Object.
|
|
359
|
+
*
|
|
360
|
+
* @category Inspections
|
|
361
|
+
* @param {Object} entity - Either of two attribute combinations are valid: entityType & entityUid OR Entity as a fully-inflated WorkOrderEntity (WorkOrderEntityBase) object.
|
|
362
|
+
* @param {number} inspectionId - An Inspection ID to attach the entity/asset to.
|
|
363
|
+
* @param {boolean} updateXY - Provide a boolean to whether the inspection's X/Y coordinates should be updated. Default is true.
|
|
364
|
+
* @param {Object} facility - Add Facility_Id for the Facility Identifier and Level_id for the Facility Level Identifier. Defaults to empty so that no facility is specified.
|
|
365
|
+
* @return {Object} Returns object that represents an object which describes an Inspection Entity
|
|
366
|
+
*/
|
|
367
|
+
connectAsset(entity: {EntityType?: string, EntityUid?: string, Entity?: Object}, inspectionId: number, updateXY: boolean = true, facility: {Facility_Id?: string, Level_Id?: string} = {}) {
|
|
368
|
+
return new Promise((resolve, reject) => {
|
|
369
|
+
var data: {InspectionId: number, EntityType?: string, EntityUid?: string, Entity?: Object, Facility_Id?: string, Level_Id?: string} = {
|
|
370
|
+
InspectionId: inspectionId
|
|
371
|
+
};
|
|
372
|
+
if(_.has(entity, 'EntityType') && _.has(entity, 'EntityUid')) {
|
|
373
|
+
data.EntityType = entity.EntityType;
|
|
374
|
+
data.EntityUid = entity.EntityUid;
|
|
375
|
+
} else if(_.has(entity, 'Entity')) {
|
|
376
|
+
data.Entity = entity.Entity;
|
|
377
|
+
} else {
|
|
378
|
+
// Throw error, no entity/asset provided
|
|
379
|
+
}
|
|
380
|
+
if(_.has(facility, 'Facility_Id')) {
|
|
381
|
+
data.Facility_Id = facility.Facility_Id;
|
|
382
|
+
}
|
|
383
|
+
if(_.has(facility, 'Level_Id')) {
|
|
384
|
+
data.Level_Id = facility.Level_Id;
|
|
385
|
+
}
|
|
386
|
+
this.cw.runRequest('Ams/Inspection/AddEntity', data).then(r => {
|
|
387
|
+
resolve(r.Value);
|
|
388
|
+
}).catch(e => {
|
|
389
|
+
// 4 NotAuthorizedToUpdateInspection
|
|
390
|
+
// 9 InvalidActivityMapLogicXY
|
|
391
|
+
// 21 ErrorUnknownEntityType
|
|
392
|
+
// 30 InvalidField
|
|
393
|
+
// 60 WarningItemNotFound
|
|
394
|
+
// 68 MoveInvalidCityworksWkid
|
|
395
|
+
reject(e);
|
|
396
|
+
});
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* Get the answers for inspections
|
|
402
|
+
*
|
|
403
|
+
* @category Inspections
|
|
404
|
+
* @param {Array<number>} inspections - An Array of one or more Inspection IDs
|
|
405
|
+
* @return {Object} Returns Promise that represents a collection of Inspection Answers
|
|
406
|
+
*/
|
|
407
|
+
getAnswers(inspections: Array<number>) {
|
|
408
|
+
return new Promise((resolve, reject) => {
|
|
409
|
+
var data: {InspectionId?: number, InspectionIds?: Array<number>} = {}
|
|
410
|
+
if(inspections.length==0) {
|
|
411
|
+
data.InspectionId = inspections[0]
|
|
412
|
+
} else {
|
|
413
|
+
data.InspectionIds = inspections
|
|
414
|
+
}
|
|
415
|
+
this.cw.runRequest('Ams/Inspection/Answers', data).then(r => {
|
|
416
|
+
resolve(r.Value)
|
|
417
|
+
}).catch(e => {
|
|
418
|
+
reject(e)
|
|
419
|
+
})
|
|
420
|
+
})
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* Get the audit log for a specific Inspection
|
|
425
|
+
*
|
|
426
|
+
* @category Inspections
|
|
427
|
+
* @param {number} inspectionId - An Inspection ID to get the audit log for
|
|
428
|
+
* @return {Object} Returns Promise that represents a collection of Cityworks Metadata Objects
|
|
429
|
+
*/
|
|
430
|
+
getAuditLog(inspectionId: number) {
|
|
431
|
+
return new Promise((resolve, reject) => {
|
|
432
|
+
var data = {InspectionId: inspectionId}
|
|
433
|
+
this.cw.runRequest('Ams/Inspection/AuditLog', data).then(r => {
|
|
434
|
+
resolve(r.Value)
|
|
435
|
+
}).catch(e => {
|
|
436
|
+
reject(e)
|
|
437
|
+
})
|
|
438
|
+
})
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* Create a search definition. Save the definition by setting SaveDefinition = true and supplying a SearchName.
|
|
443
|
+
*
|
|
444
|
+
* @category Inspections
|
|
445
|
+
* @param {Object} searchData - Search data variables. See /{subdirectory}/apidocs/#/service-info/Ams/Inspection
|
|
446
|
+
* @param {number} [searchName] - What to name your search (if it should be saved)
|
|
447
|
+
* @param {number} [sharedWithin] - What group or domain to share the search to.
|
|
448
|
+
* @param {boolean} saveDefinition - Whether or not to save the search definition. Defaults to true when a search name is specified.
|
|
449
|
+
* @param {boolean} enableEurl - Whether or not to enable EURL for the saved search. Defaults to true.
|
|
450
|
+
* @return {Object} Returns Promise that represents a collection of Cityworks Metadata Objects
|
|
451
|
+
*/
|
|
452
|
+
createSearchDefinition(searchData: Object, searchName?: string, sharedWithin?: number, saveDefinition: boolean = true, enableEurl: boolean = true) {
|
|
453
|
+
return new Promise((resolve, reject) => {
|
|
454
|
+
var data = searchData
|
|
455
|
+
if(_.isString(searchName)) {
|
|
456
|
+
_.set(data, 'SearchName', searchName)
|
|
457
|
+
_.set(data, 'SaveDefinition', saveDefinition)
|
|
458
|
+
_.set(data, 'EnableEurl', enableEurl)
|
|
459
|
+
// not sure how to handle sharedWithin...
|
|
460
|
+
// _.set(data, 'SharedWithin', sharedWithin)
|
|
461
|
+
}
|
|
462
|
+
this.cw.runRequest('Ams/Inspection/CreateSearchDefinition', data).then(r => {
|
|
463
|
+
resolve(r.Value)
|
|
464
|
+
}).catch(e => {
|
|
465
|
+
reject(e)
|
|
466
|
+
})
|
|
467
|
+
})
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* Get cycle from
|
|
472
|
+
*
|
|
473
|
+
* @category Inspection Options
|
|
474
|
+
* @return {Object} Returns Promise that represents ... I have no idea what this endpoint does
|
|
475
|
+
*/
|
|
476
|
+
getCycleFrom() {
|
|
477
|
+
return new Promise((resolve, reject) => {
|
|
478
|
+
this.cw.runRequest('Ams/Inspection/CycleFrom', {}).then(r => {
|
|
479
|
+
resolve(r.Value)
|
|
480
|
+
}).catch(e => {
|
|
481
|
+
reject(e)
|
|
482
|
+
})
|
|
483
|
+
})
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* Get cycle intervals
|
|
488
|
+
*
|
|
489
|
+
* @category Inspection Options
|
|
490
|
+
* @return {Object} Returns Promise that represents a Dictionary of the cycle intervals available
|
|
491
|
+
*/
|
|
492
|
+
getCycleIntervals() {
|
|
493
|
+
return new Promise((resolve, reject) => {
|
|
494
|
+
this.cw.runRequest('Ams/Inspection/CycleIntervals', {}).then(r => {
|
|
495
|
+
resolve(r.Value)
|
|
496
|
+
}).catch(e => {
|
|
497
|
+
reject(e)
|
|
498
|
+
})
|
|
499
|
+
})
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
/**
|
|
503
|
+
* Get cycle types
|
|
504
|
+
*
|
|
505
|
+
* @category Inspection Options
|
|
506
|
+
* @return {Object} Returns Promise that represents a Dictionary of the cycle types available
|
|
507
|
+
*/
|
|
508
|
+
getCycleTypes() {
|
|
509
|
+
return new Promise((resolve, reject) => {
|
|
510
|
+
this.cw.runRequest('Ams/Inspection/CycleTypes', {}).then(r => {
|
|
511
|
+
resolve(r.Value)
|
|
512
|
+
}).catch(e => {
|
|
513
|
+
reject(e)
|
|
514
|
+
})
|
|
515
|
+
})
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
/**
|
|
519
|
+
* Get districts
|
|
520
|
+
*
|
|
521
|
+
* @category Inspection Options
|
|
522
|
+
* @return {Object} Returns Promise that represents an Array of the districts
|
|
523
|
+
*/
|
|
524
|
+
getDistricts() {
|
|
525
|
+
return new Promise((resolve, reject) => {
|
|
526
|
+
this.cw.runRequest('Ams/Inspection/Districts', {}).then(r => {
|
|
527
|
+
resolve(r.Value)
|
|
528
|
+
}).catch(e => {
|
|
529
|
+
reject(e)
|
|
530
|
+
})
|
|
531
|
+
})
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* Move inspection by InspectionId. Must provide well known id (WKID) or well known text (WKT)
|
|
537
|
+
*
|
|
538
|
+
* @category Inspections
|
|
539
|
+
* @param {number} inspectionId - The ID of the inspection that should be moved
|
|
540
|
+
* @param {number} x - The X coordinate for the move
|
|
541
|
+
* @param {number} y - The Y coordinate for the move
|
|
542
|
+
* @param {Object} projection_info - An object which must include either WKID: Int32 or WKT: String. Can also include VcsWKID.
|
|
543
|
+
* @param {number} [z] - the optional z coordinate for the move
|
|
544
|
+
* @return {Object} Returns Promise which represents a GISPoint object
|
|
545
|
+
*/
|
|
546
|
+
move(inspectionId: number, x: number, y: number, projection_info?: Object, z?: number) {
|
|
547
|
+
return new Promise((resolve, reject) => {
|
|
548
|
+
var data = {
|
|
549
|
+
InspectionId: inspectionId,
|
|
550
|
+
x: x,
|
|
551
|
+
y: y
|
|
552
|
+
}
|
|
553
|
+
if(typeof z != 'undefined') {
|
|
554
|
+
_.set(data, 'z', z)
|
|
555
|
+
}
|
|
556
|
+
if(typeof projection_info != 'undefined') {
|
|
557
|
+
if(_.has(projection_info, 'WKID')) {
|
|
558
|
+
_.set(data, 'WKID', _.get(projection_info, 'WKID'))
|
|
559
|
+
} else if(_.has(projection_info, 'WKT')) {
|
|
560
|
+
_.set(data, 'WKT', _.get(projection_info, 'WKT'))
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
if(_.has(projection_info, 'VcsWKID')) {
|
|
564
|
+
_.set(data, 'VcsWKID', _.get(projection_info, 'VcsWKID'))
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
this.cw.runRequest('Ams/Inspection/Move', {}).then(r => {
|
|
568
|
+
resolve(r.Value)
|
|
569
|
+
}).catch(e => {
|
|
570
|
+
reject(e)
|
|
571
|
+
})
|
|
572
|
+
})
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
/////
|
|
576
|
+
// INSPECTION TEMPLATES
|
|
577
|
+
/////
|
|
578
|
+
|
|
579
|
+
/**
|
|
580
|
+
* Get inspection templates
|
|
581
|
+
*
|
|
582
|
+
* @category Inspection Templates
|
|
583
|
+
* @param {Array<string>} [entityTypes] - The Entity Type(s) to return potential inspections for
|
|
584
|
+
* @param {boolean} [canCreate] - If true, only return templates the user can create, ignored if false or null, default is true
|
|
585
|
+
* @param {Object} [options] - An object which can include: [IncludeInactive]: boolean, MaximumDateModified: Date, MinimumDateModified: Date, TemplateIds: Array<number>
|
|
586
|
+
* @return {Object} Returns Promise that represents a collection of all possible employees for an Inspection's SubmitTo
|
|
587
|
+
*/
|
|
588
|
+
getTemplates(entityTypes?: Array<string>, canCreate?: boolean, options?: {IncludeInactive?: boolean, MaximumDateModified?: Date, MinimumDateModified?: Date, TemplateIds?: Array<number>}) {
|
|
589
|
+
return new Promise((resolve, reject) => {
|
|
590
|
+
var data: {EntityTypes?: Array<string>, CanCreate?: boolean, IncludeInactive?: boolean, MaximumDateModified?: Date, MinimumDateModified?: Date, TemplateIds?: Array<number>} = {};
|
|
591
|
+
if(typeof(entityTypes)!=='undefined') {
|
|
592
|
+
data.EntityTypes = entityTypes;
|
|
593
|
+
}
|
|
594
|
+
data.CanCreate = typeof(canCreate)!=='undefined' ? canCreate : true;
|
|
595
|
+
if(typeof(options)==='object') {
|
|
596
|
+
_.forIn(options, (v, k) => {
|
|
597
|
+
data[k] = v;
|
|
598
|
+
});
|
|
599
|
+
}
|
|
600
|
+
this.cw.runRequest('Ams/InspectionTemplate/Templates', data).then(r => {
|
|
601
|
+
resolve(r.Value);
|
|
602
|
+
}).catch(e => {
|
|
603
|
+
reject(e);
|
|
604
|
+
});
|
|
605
|
+
});
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
/**
|
|
609
|
+
* Get a list of templates by IDs
|
|
610
|
+
*
|
|
611
|
+
* @category Inspection Templates
|
|
612
|
+
* @param {Array<number>} inspectionIds - An array of the IDs to retrieve the matched inspections
|
|
613
|
+
* @param {Object} [options] - An object which can include: [IncludeInactive]: boolean, MaximumDateModified: Date, MinimumDateModified: Date, TemplateIds: Array<number>
|
|
614
|
+
* @return {Object} Returns object that represents an object describing the inspection
|
|
615
|
+
*/
|
|
616
|
+
getTemplatesByIds(inspTemplateIds: Array<number>, options?: {MaximumDateModified?: Date, MinimumDateModified?: Date}) {
|
|
617
|
+
return new Promise((resolve, reject) => {
|
|
618
|
+
var data = {
|
|
619
|
+
InspTemplateIds: inspTemplateIds
|
|
620
|
+
}
|
|
621
|
+
if(typeof(options)==='object') {
|
|
622
|
+
_.forIn(options, (v, k) => {
|
|
623
|
+
data[k] = v;
|
|
624
|
+
});
|
|
625
|
+
}
|
|
626
|
+
this.cw.runRequest('Ams/InspectionTemplate/ByIds', data).then(r => {
|
|
627
|
+
resolve(r.Value);
|
|
628
|
+
}).catch(e => {
|
|
629
|
+
reject(e);
|
|
630
|
+
});
|
|
631
|
+
});
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
/**
|
|
635
|
+
* Get entity types for inspection template(s)
|
|
636
|
+
*
|
|
637
|
+
* @category Inspection Templates
|
|
638
|
+
* @param {Array<number>} inspTemplateIds - An array of the IDs to reopen the matched inspections
|
|
639
|
+
* @return {Object} Returns object that represents an array of Entity Types
|
|
640
|
+
*/
|
|
641
|
+
getTemplateEntityTypes(inspTemplateIds: Array<number>) {
|
|
642
|
+
return new Promise((resolve, reject) => {
|
|
643
|
+
var data = {
|
|
644
|
+
InspTemplateIds: inspTemplateIds
|
|
645
|
+
};
|
|
646
|
+
this.cw.runRequest('Ams/InspectionTemplate/EntityTypes', data).then(r => {
|
|
647
|
+
resolve(r.Value);
|
|
648
|
+
}).catch(e => {
|
|
649
|
+
reject(e);
|
|
650
|
+
});
|
|
651
|
+
});
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
/**
|
|
655
|
+
* Get the questions and answers for inspection template(s)
|
|
656
|
+
*
|
|
657
|
+
* @category Inspection Templates
|
|
658
|
+
* @param {Array<number>} inspTemplateIds - An array of the IDs to reopen the matched inspections
|
|
659
|
+
* @return {Object} Returns object that represents an array which contains a list of InspQuestionPanel for the template
|
|
660
|
+
*/
|
|
661
|
+
getQA(inspTemplateIds: Array<number>) {
|
|
662
|
+
return new Promise((resolve, reject) => {
|
|
663
|
+
var data = {
|
|
664
|
+
InspTemplateIds: inspTemplateIds
|
|
665
|
+
};
|
|
666
|
+
this.cw.runRequest('Ams/InspectionTemplate/QA', data).then(r => {
|
|
667
|
+
resolve(r.Value);
|
|
668
|
+
}).catch(e => {
|
|
669
|
+
reject(e);
|
|
670
|
+
});
|
|
671
|
+
});
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
/**
|
|
675
|
+
* Get inspection template question conditions
|
|
676
|
+
*
|
|
677
|
+
* @category Inspection Templates
|
|
678
|
+
* @param {Array<number>} inspTemplateIds - An array of template IDs to get the matched inspection template Question conditions for
|
|
679
|
+
* @return {Object} Returns object that represents an array which contains a dictionary of InspQuestion IDs to configs
|
|
680
|
+
*/
|
|
681
|
+
getQConditions(inspTemplateIds: Array<number>) {
|
|
682
|
+
return new Promise((resolve, reject) => {
|
|
683
|
+
var data = {
|
|
684
|
+
InspTemplateIds: inspTemplateIds
|
|
685
|
+
};
|
|
686
|
+
this.cw.runRequest('Ams/InspectionTemplate/QuestionConditions', data).then(r => {
|
|
687
|
+
resolve(r.Value);
|
|
688
|
+
}).catch(e => {
|
|
689
|
+
reject(e);
|
|
690
|
+
});
|
|
691
|
+
});
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
|
|
129
695
|
// Attachments
|
|
130
696
|
|
|
131
697
|
// AddInspectionAttachment InspAttachment
|
|
@@ -142,35 +708,83 @@ export class Inspection {
|
|
|
142
708
|
// "AttachmentType": null
|
|
143
709
|
// }
|
|
144
710
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
711
|
+
/**
|
|
712
|
+
* Delete inspection attachments
|
|
713
|
+
*
|
|
714
|
+
* @category Inspection Attachments
|
|
715
|
+
* @param {Array<number>} attachmentIds - An array of inspection attachment IDs to delete
|
|
716
|
+
* @return {Object} Returns object that represents a boolean for action resolution
|
|
717
|
+
*/
|
|
718
|
+
deleteAttachments(attachmentIds: Array<number>) {
|
|
719
|
+
return new Promise((resolve, reject) => {
|
|
720
|
+
var data = {
|
|
721
|
+
AttachmentIds: attachmentIds
|
|
722
|
+
};
|
|
723
|
+
this.cw.runRequest('Ams/Attachments/DeleteInspectionAttachments', data).then(r => {
|
|
724
|
+
resolve(r.Value);
|
|
725
|
+
}).catch(e => {
|
|
726
|
+
reject(e);
|
|
727
|
+
});
|
|
728
|
+
});
|
|
729
|
+
}
|
|
152
730
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
731
|
+
/**
|
|
732
|
+
* Download an inspection attachment
|
|
733
|
+
*
|
|
734
|
+
* @category Inspection Attachments
|
|
735
|
+
* @param {number} attachmentId - ID of an inspection attachment to download
|
|
736
|
+
* @return {Object} Returns object that represents a file stream
|
|
737
|
+
*/
|
|
738
|
+
downloadAttachment(attachmentId: number) {
|
|
739
|
+
return new Promise((resolve, reject) => {
|
|
740
|
+
var data = {
|
|
741
|
+
AttachmentId: attachmentId
|
|
742
|
+
};
|
|
743
|
+
this.cw.runRequest('Ams/Attachments/DownloadInspectionAttachment', data).then(r => {
|
|
744
|
+
// TODO, pass file through // resolve(r.Value);
|
|
745
|
+
}).catch(e => {
|
|
746
|
+
reject(e);
|
|
747
|
+
});
|
|
748
|
+
});
|
|
749
|
+
}
|
|
160
750
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
751
|
+
/**
|
|
752
|
+
* Get inspection attachment by ID
|
|
753
|
+
*
|
|
754
|
+
* @category Inspection Attachments
|
|
755
|
+
* @param {number} attachmentId - An attachment ID to get info for
|
|
756
|
+
* @return {Object} Returns object that represents an object that describes the matched inspection attachment
|
|
757
|
+
*/
|
|
758
|
+
getAttachmentById(attachmentId: number) {
|
|
759
|
+
return new Promise((resolve, reject) => {
|
|
760
|
+
var data = {
|
|
761
|
+
AttachmentId: attachmentId
|
|
762
|
+
};
|
|
763
|
+
this.cw.runRequest('Ams/Attachments/InspectionAttachmentById', data).then(r => {
|
|
764
|
+
resolve(r.Value);
|
|
765
|
+
}).catch(e => {
|
|
766
|
+
reject(e);
|
|
767
|
+
});
|
|
768
|
+
});
|
|
769
|
+
}
|
|
168
770
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
771
|
+
/**
|
|
772
|
+
* Get inspection attachment by ID
|
|
773
|
+
*
|
|
774
|
+
* @category Inspection Attachments
|
|
775
|
+
* @param {Array<number>} inspectionIds - An array of inspection IDs to get attachments for
|
|
776
|
+
* @return {Object} Returns object that represents a collection of attachments from the matched inspections
|
|
777
|
+
*/
|
|
778
|
+
getAttachments(inspectionIds: Array<number>) {
|
|
779
|
+
return new Promise((resolve, reject) => {
|
|
780
|
+
var data = {
|
|
781
|
+
InspectionIds: inspectionIds
|
|
782
|
+
};
|
|
783
|
+
this.cw.runRequest('Ams/Attachments/InspectionAttachments', data).then(r => {
|
|
784
|
+
resolve(r.Value);
|
|
785
|
+
}).catch(e => {
|
|
786
|
+
reject(e);
|
|
787
|
+
});
|
|
788
|
+
});
|
|
789
|
+
}
|
|
176
790
|
}
|
package/src/request.ts
CHANGED
|
@@ -7,11 +7,480 @@ export class Request {
|
|
|
7
7
|
/**
|
|
8
8
|
* Construct activity link object for Request functions
|
|
9
9
|
*
|
|
10
|
-
* @param {
|
|
10
|
+
* @param {Object} cw - Feed in the cityworks object instance so that this instance has access to the runRequest from the recursively-linked Cityworks instance
|
|
11
11
|
* @return {Object} Returns object that is this module
|
|
12
12
|
*/
|
|
13
13
|
constructor(cw) {
|
|
14
14
|
this.cw = cw;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Create new requests
|
|
19
|
+
*
|
|
20
|
+
* @category Requests
|
|
21
|
+
* @param {Object} sr_data - See /{subdirectory}/apidocs/#/data-type-info;dataType=RequestBase on the Cityworks instance
|
|
22
|
+
* @return {Object} Returns Promise that represents an object describing the newly-created request
|
|
23
|
+
*/
|
|
24
|
+
create(sr_data: Object) {
|
|
25
|
+
return new Promise((resolve, reject) => {
|
|
26
|
+
if(!_.has(sr_data, 'ProblemSid')) {
|
|
27
|
+
reject(new CWError(1, 'ProblemSid must be provided.', {'provided': sr_data}))
|
|
28
|
+
} else {
|
|
29
|
+
this.cw.runRequest('Ams/ServiceRequest/Create', sr_data).then(r => {
|
|
30
|
+
resolve(r.Value)
|
|
31
|
+
}).catch(e => {
|
|
32
|
+
reject(e)
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Update a request
|
|
40
|
+
*
|
|
41
|
+
* @category Requests
|
|
42
|
+
* @param {object} sr_data - See /{subdirectory}/apidocs/#/data-type-info;dataType=RequestBase on the Cityworks instance
|
|
43
|
+
* @return {Object} Returns Promise that represents an object describing the updated request
|
|
44
|
+
*/
|
|
45
|
+
update(sr_data: Object) {
|
|
46
|
+
return new Promise((resolve, reject) => {
|
|
47
|
+
return new Promise((resolve, reject) => {
|
|
48
|
+
if(!_.has(sr_data, 'RequestId')) {
|
|
49
|
+
reject(new CWError(1, 'RequestId must be provided.', {'provided': sr_data}));
|
|
50
|
+
} else {
|
|
51
|
+
this.cw.runRequest('Ams/ServiceRequest/Update', sr_data).then(r => {
|
|
52
|
+
resolve(r.Value);
|
|
53
|
+
}).catch(e => {
|
|
54
|
+
reject(e);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Change a request's problem code
|
|
63
|
+
*
|
|
64
|
+
* @category Requests
|
|
65
|
+
* @param {number} requestId - The request ID to change
|
|
66
|
+
* @param {number} problemSid - The request's new ProblemSID
|
|
67
|
+
* @return {Object} Returns Promise that represents an object describing the updated request
|
|
68
|
+
*/
|
|
69
|
+
changeProblem(requestId: number, problemSid: number) {
|
|
70
|
+
return new Promise((resolve, reject) => {
|
|
71
|
+
return new Promise((resolve, reject) => {
|
|
72
|
+
var data = {
|
|
73
|
+
RequestId: requestId,
|
|
74
|
+
ProblemSid: problemSid
|
|
75
|
+
}
|
|
76
|
+
this.cw.runRequest('Ams/ServiceRequest/ChangeProblem', data).then(r => {
|
|
77
|
+
resolve(r.Value);
|
|
78
|
+
}).catch(e => {
|
|
79
|
+
reject(e);
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Get a request by ID
|
|
87
|
+
*
|
|
88
|
+
* @category Requests
|
|
89
|
+
* @param {number} requestId - The ID of the reuqest to retrieve
|
|
90
|
+
* @return {Object} Returns Promise that represents an object describing the request
|
|
91
|
+
*/
|
|
92
|
+
getById(requestId: number) {
|
|
93
|
+
return new Promise((resolve, reject) => {
|
|
94
|
+
var data = {
|
|
95
|
+
RequestId: requestId
|
|
96
|
+
}
|
|
97
|
+
this.cw.runRequest('Ams/ServiceRequest/ById', data).then(r => {
|
|
98
|
+
resolve(r.Value);
|
|
99
|
+
}).catch(e => {
|
|
100
|
+
reject(e);
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Get requests by array of IDs
|
|
107
|
+
*
|
|
108
|
+
* @category Requests
|
|
109
|
+
* @param {Array<number>} requestIds - The request IDs to retrieve
|
|
110
|
+
* @return {Object} Returns Promise that represents a collection of Objects describing the requests
|
|
111
|
+
*/
|
|
112
|
+
getByIds(requestIds: Array<number>) {
|
|
113
|
+
return new Promise((resolve, reject) => {
|
|
114
|
+
var data = {
|
|
115
|
+
RequestIds: requestIds
|
|
116
|
+
}
|
|
117
|
+
this.cw.runRequest('Ams/ServiceRequest/ByIds', data).then(r => {
|
|
118
|
+
resolve(r.Value);
|
|
119
|
+
}).catch(e => {
|
|
120
|
+
reject(e);
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Get the audit log for a specific request
|
|
127
|
+
*
|
|
128
|
+
* @category Requests
|
|
129
|
+
* @param {number} requestId - A Request ID to get the audit log for
|
|
130
|
+
* @return {Object} Returns Promise that represents a collection of Cityworks Metadata Objects
|
|
131
|
+
*/
|
|
132
|
+
getAuditLog(requestId: number) {
|
|
133
|
+
return new Promise((resolve, reject) => {
|
|
134
|
+
var data = {RequestId: requestId}
|
|
135
|
+
this.cw.runRequest('Ams/ServiceRequest/AuditLog', data).then(r => {
|
|
136
|
+
resolve(r.Value)
|
|
137
|
+
}).catch(e => {
|
|
138
|
+
reject(e)
|
|
139
|
+
})
|
|
140
|
+
})
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Get custom fields for provided requests
|
|
145
|
+
*
|
|
146
|
+
* @category Requests
|
|
147
|
+
* @param {Array<number>} requestIds - The RequestIds whose custom fields should be returned
|
|
148
|
+
* @return {Object} Returns Promise that represents a collection of custom fields
|
|
149
|
+
*/
|
|
150
|
+
getCustomFields(requestIds: Array<number>) {
|
|
151
|
+
return new Promise((resolve, reject) => {
|
|
152
|
+
var data = {
|
|
153
|
+
RequestIds: requestIds,
|
|
154
|
+
}
|
|
155
|
+
this.cw.runRequest('Ams/ServiceRequest/CustomFields', data).then(r => {
|
|
156
|
+
resolve(r.Value)
|
|
157
|
+
}).catch(e => {
|
|
158
|
+
reject(e)
|
|
159
|
+
})
|
|
160
|
+
})
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Cancel requests
|
|
165
|
+
*
|
|
166
|
+
* @category Requests
|
|
167
|
+
* @param {Array<number>} requestIds - An array of the IDs to cancel the matched requests
|
|
168
|
+
* @param {string} [cancelReason] - A reason for cancelling the request(s)
|
|
169
|
+
* @param {datetime} [dateCancelled] - The date/time that it should be indicated the request was cancelled
|
|
170
|
+
* @return {Object} Returns object that represents a collection of requests
|
|
171
|
+
*/
|
|
172
|
+
cancel(requestIds: Array<number>, cancelReason?: string, dateCancelled?: Date) {
|
|
173
|
+
return new Promise((resolve, reject) => {
|
|
174
|
+
var m = new Date();
|
|
175
|
+
var data: {RequestIds: Array<number>, CancelReason?: string, DateCancelled?: Date} = { RequestIds: requestIds };
|
|
176
|
+
if(typeof(cancelReason)!=='undefined') {
|
|
177
|
+
data.CancelReason = cancelReason;
|
|
178
|
+
}
|
|
179
|
+
if(typeof(dateCancelled)!=='undefined') {
|
|
180
|
+
data.DateCancelled = dateCancelled;
|
|
181
|
+
}
|
|
182
|
+
this.cw.runRequest('Ams/ServiceRequest/Cancel', data).then(r => {
|
|
183
|
+
resolve(r.Value);
|
|
184
|
+
}).catch(e => {
|
|
185
|
+
reject(e);
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Uncancel requests
|
|
192
|
+
*
|
|
193
|
+
* @category Requests
|
|
194
|
+
* @param {Array<number>} requestIds - An array of the IDs to uncancel the matched requests
|
|
195
|
+
* @return {Object} Returns object that represents a collection of requests
|
|
196
|
+
*/
|
|
197
|
+
uncancel(requestIds: Array<number>) {
|
|
198
|
+
return new Promise((resolve, reject) => {
|
|
199
|
+
var data = {
|
|
200
|
+
RequestIds: requestIds
|
|
201
|
+
};
|
|
202
|
+
this.cw.runRequest('Ams/ServiceRequest/Uncancel', data).then(r => {
|
|
203
|
+
resolve(r.Value);
|
|
204
|
+
}).catch(e => {
|
|
205
|
+
reject(e);
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Close requests
|
|
212
|
+
*
|
|
213
|
+
* @category Requests
|
|
214
|
+
* @param {Array<number>} requestIds - An array of the IDs to close the matched requests
|
|
215
|
+
* @return {Object} Returns object that represents a collection of requests
|
|
216
|
+
*/
|
|
217
|
+
close(requestIds: Array<number>) {
|
|
218
|
+
return new Promise((resolve, reject) => {
|
|
219
|
+
var data = {
|
|
220
|
+
RequestIds: requestIds
|
|
221
|
+
};
|
|
222
|
+
this.cw.runRequest('Ams/ServiceRequest/Close', data).then(r => {
|
|
223
|
+
resolve(r.Value);
|
|
224
|
+
}).catch(e => {
|
|
225
|
+
reject(e);
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Reopen closed requests
|
|
232
|
+
*
|
|
233
|
+
* @category Requests
|
|
234
|
+
* @param {Array<number>} requestIds - An array of the IDs to reopen the matched requests
|
|
235
|
+
* @return {Object} Returns object that represents a collection of requests
|
|
236
|
+
*/
|
|
237
|
+
reopen(requestIds: Array<number>) {
|
|
238
|
+
return new Promise((resolve, reject) => {
|
|
239
|
+
var data = {
|
|
240
|
+
RequestIds: requestIds
|
|
241
|
+
};
|
|
242
|
+
this.cw.runRequest('Ams/ServiceRequest/Reopen', data).then(r => {
|
|
243
|
+
resolve(r.Value);
|
|
244
|
+
}).catch(e => {
|
|
245
|
+
reject(e);
|
|
246
|
+
});
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Delete requests
|
|
252
|
+
*
|
|
253
|
+
* @category Requests
|
|
254
|
+
* @param {Array<number>} requestIds - An array of the IDs to delete the matched requests
|
|
255
|
+
* @return {Object} Returns object that represents a collection of request Ids which have been deleted
|
|
256
|
+
*/
|
|
257
|
+
delete(inspectionIds: Array<number>) {
|
|
258
|
+
return new Promise((resolve, reject) => {
|
|
259
|
+
var data = {
|
|
260
|
+
InspectionIds: inspectionIds
|
|
261
|
+
};
|
|
262
|
+
this.cw.runRequest('Ams/Inspection/Delete', data).then(r => {
|
|
263
|
+
resolve(r.Value);
|
|
264
|
+
}).catch(e => {
|
|
265
|
+
reject(e);
|
|
266
|
+
});
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Get a list of problem nodes for a domain
|
|
272
|
+
*
|
|
273
|
+
* @category Request Categorization
|
|
274
|
+
* @param {number} domainId - The domain ID for which to retrieve problem nodes.
|
|
275
|
+
* @param {boolean} viewOnly - Return only view only problem nodes. Defaults to false.
|
|
276
|
+
* @param {Object} [displayMode] - Object that should contain two properties if you provide it: DisplayTextMode: string (C = Code, D = Description, CD = Code ~ Description). DisplayTextDelimeter: string, only impacts CD display text mode.
|
|
277
|
+
* @param {boolean} includeCancelled - Return only cancelled problem nodes as well. Defaults to false.
|
|
278
|
+
* @return {Object} Returns Promise that represents a collection of problem node objects.
|
|
279
|
+
*/
|
|
280
|
+
getProblemNodes(domainId: number, viewOnly: boolean = false, displayMode?: Object, includeCancelled: boolean = false) {
|
|
281
|
+
return new Promise((resolve, reject) => {
|
|
282
|
+
var data = {
|
|
283
|
+
DomainId: domainId,
|
|
284
|
+
IncludeCancelled: includeCancelled,
|
|
285
|
+
ViewOnly: viewOnly
|
|
286
|
+
}
|
|
287
|
+
if(typeof displayMode != 'undefined' && _.has(displayMode, 'DisplayTextMode')) {
|
|
288
|
+
_.set(data, 'DisplayTextMode', _.get(displayMode, 'DisplayTextMode'));
|
|
289
|
+
if(_.get(displayMode, 'DisplayTextMode')=='CD' && _.has(displayMode, 'DisplayTextDelimeter')) {
|
|
290
|
+
_.set(data, 'DisplayTextDelimeter', _.get(displayMode, 'DisplayTextDelimeter'));
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
this.cw.runRequest('Ams/ServiceRequest/ProblemNodes', data).then(r => {
|
|
294
|
+
resolve(r.Value)
|
|
295
|
+
}).catch(e => {
|
|
296
|
+
reject(e)
|
|
297
|
+
})
|
|
298
|
+
})
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Get a list of problem codes
|
|
303
|
+
*
|
|
304
|
+
* @category Request Options
|
|
305
|
+
* @param {boolean} forPublicOnly - Return only publicly-available service requests. Defaults to false.
|
|
306
|
+
* @param {boolean} onlyActiveTemplates - Return only active templates. Defaults to true.
|
|
307
|
+
* @return {Object} Returns Promise that represents an Array of problem name objects.
|
|
308
|
+
*/
|
|
309
|
+
getProblems(forPublicOnly: boolean = false, onlyActiveTemplates: boolean = true, domainIds?: Array<number>) {
|
|
310
|
+
return new Promise((resolve, reject) => {
|
|
311
|
+
var data = {
|
|
312
|
+
ForPublicOnly: forPublicOnly,
|
|
313
|
+
OnlyActiveTemplates: onlyActiveTemplates
|
|
314
|
+
}
|
|
315
|
+
if(typeof domainIds != 'undefined') {
|
|
316
|
+
_.set(data, 'DomainIds', domainIds);
|
|
317
|
+
}
|
|
318
|
+
this.cw.runRequest('Ams/ServiceRequest/Problems', data).then(r => {
|
|
319
|
+
resolve(r.Value)
|
|
320
|
+
}).catch(e => {
|
|
321
|
+
reject(e)
|
|
322
|
+
})
|
|
323
|
+
})
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Get a list of problem codes by keywords
|
|
328
|
+
*
|
|
329
|
+
* @category Request Options
|
|
330
|
+
* @param {string} keywords - Keywords to search for potential problem codes
|
|
331
|
+
* @return {Object} Returns Promise that represents an Array of problem name objects.
|
|
332
|
+
*/
|
|
333
|
+
getProblemsByKeywords(keywords: string) {
|
|
334
|
+
return new Promise((resolve, reject) => {
|
|
335
|
+
var data = {
|
|
336
|
+
Keywords: keywords
|
|
337
|
+
}
|
|
338
|
+
this.cw.runRequest('Ams/ServiceRequest/ProblemsByKeywords', data).then(r => {
|
|
339
|
+
resolve(r.Value)
|
|
340
|
+
}).catch(e => {
|
|
341
|
+
reject(e)
|
|
342
|
+
})
|
|
343
|
+
})
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* Get a list of a problem code's priorities
|
|
348
|
+
*
|
|
349
|
+
* @category Request Options
|
|
350
|
+
* @param {number} problemSid - Return priorities for given problemSid
|
|
351
|
+
* @return {Object} Returns Promise that represents an Array of priorities
|
|
352
|
+
*/
|
|
353
|
+
getPriorities(problemSid: number) {
|
|
354
|
+
return new Promise((resolve, reject) => {
|
|
355
|
+
var data = {
|
|
356
|
+
ProblemSids: problemSid,
|
|
357
|
+
}
|
|
358
|
+
this.cw.runRequest('Ams/ServiceRequest/Priorities', data).then(r => {
|
|
359
|
+
resolve(r.Value)
|
|
360
|
+
}).catch(e => {
|
|
361
|
+
reject(e)
|
|
362
|
+
})
|
|
363
|
+
})
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Get custom field templates for problem code
|
|
368
|
+
*
|
|
369
|
+
* @category Request Options
|
|
370
|
+
* @param {number} problemSid - The problemSid whose template custom fields should be returned
|
|
371
|
+
* @return {Object} Returns Promise that represents a collection of custom fields
|
|
372
|
+
*/
|
|
373
|
+
getCustomFieldTemplate(problemSid: number) {
|
|
374
|
+
return new Promise((resolve, reject) => {
|
|
375
|
+
var data = {
|
|
376
|
+
ProblemSids: problemSid,
|
|
377
|
+
}
|
|
378
|
+
this.cw.runRequest('Ams/ServiceRequest/TemplateCustomFields', data).then(r => {
|
|
379
|
+
resolve(r.Value)
|
|
380
|
+
}).catch(e => {
|
|
381
|
+
reject(e)
|
|
382
|
+
})
|
|
383
|
+
})
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* Get the questions and answer options for a problem code
|
|
388
|
+
*
|
|
389
|
+
* @category Request Options
|
|
390
|
+
* @param {number} problemSid - The problemSid whose Q&A should be returned
|
|
391
|
+
* @return {Object} Returns Promise that represents a collection of questions and answer settings
|
|
392
|
+
*/
|
|
393
|
+
getQASettings(problemSid: number) {
|
|
394
|
+
return new Promise((resolve, reject) => {
|
|
395
|
+
var data = {
|
|
396
|
+
ProblemSids: problemSid,
|
|
397
|
+
}
|
|
398
|
+
this.cw.runRequest('Ams/ServiceRequest/QA', data).then(r => {
|
|
399
|
+
resolve(r.Value)
|
|
400
|
+
}).catch(e => {
|
|
401
|
+
reject(e)
|
|
402
|
+
})
|
|
403
|
+
})
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* Get problem leaf (template) by Sid
|
|
408
|
+
*
|
|
409
|
+
* @category Request Options
|
|
410
|
+
* @param {number} problemSid - Return problem leaf for given problemSid
|
|
411
|
+
* @return {Object} Returns Promise that represents an Object that describes the problem leaf (template)
|
|
412
|
+
*/
|
|
413
|
+
getProblemLeaf(problemSid: number) {
|
|
414
|
+
return new Promise((resolve, reject) => {
|
|
415
|
+
var data = {
|
|
416
|
+
ProblemSid: problemSid
|
|
417
|
+
}
|
|
418
|
+
this.cw.runRequest('Ams/ServiceRequest/ProblemLeafBySid', data).then(r => {
|
|
419
|
+
resolve(r.Value)
|
|
420
|
+
}).catch(e => {
|
|
421
|
+
reject(e)
|
|
422
|
+
})
|
|
423
|
+
})
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* Get a list of default statuses
|
|
428
|
+
*
|
|
429
|
+
* @category Request Options
|
|
430
|
+
* @param {Array<number>} domainIds - List of domains to return default statuses for
|
|
431
|
+
* @return {Object} Returns Promise that represents an Array of statuses.
|
|
432
|
+
*/
|
|
433
|
+
getStatuses(domainIds: Array<number>) {
|
|
434
|
+
return new Promise((resolve, reject) => {
|
|
435
|
+
var data = {
|
|
436
|
+
DomainIds: domainIds
|
|
437
|
+
}
|
|
438
|
+
this.cw.runRequest('Ams/ServiceRequest/DefaultStatus', data).then(r => {
|
|
439
|
+
resolve(r.Value)
|
|
440
|
+
}).catch(e => {
|
|
441
|
+
reject(e)
|
|
442
|
+
})
|
|
443
|
+
})
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* Get a list of possible DispatchTo values
|
|
448
|
+
*
|
|
449
|
+
* @category Request Options
|
|
450
|
+
* @param {Array<number>} domainId - Domain to return possible dispatchTo values for
|
|
451
|
+
* @return {Object} Returns Promise that represents an Array of dispatchTo options.
|
|
452
|
+
*/
|
|
453
|
+
getDispatchTo(domainId: Array<number>) {
|
|
454
|
+
return new Promise((resolve, reject) => {
|
|
455
|
+
var data = {
|
|
456
|
+
DomainId: domainId
|
|
457
|
+
}
|
|
458
|
+
this.cw.runRequest('Ams/ServiceRequest/DispatchTo', data).then(r => {
|
|
459
|
+
resolve(r.Value)
|
|
460
|
+
}).catch(e => {
|
|
461
|
+
reject(e)
|
|
462
|
+
})
|
|
463
|
+
})
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
/**
|
|
467
|
+
* Get a list of possible SubmitTo values
|
|
468
|
+
*
|
|
469
|
+
* @category Request Options
|
|
470
|
+
* @param {Array<number>} domainId - Domain to return possible submitTo values for
|
|
471
|
+
* @return {Object} Returns Promise that represents an Array of submitTo options.
|
|
472
|
+
*/
|
|
473
|
+
getSubmitTo(domainId: Array<number>) {
|
|
474
|
+
return new Promise((resolve, reject) => {
|
|
475
|
+
var data = {
|
|
476
|
+
DmainId: domainId
|
|
477
|
+
}
|
|
478
|
+
this.cw.runRequest('Ams/ServiceRequest/SubmitTo', data).then(r => {
|
|
479
|
+
resolve(r.Value)
|
|
480
|
+
}).catch(e => {
|
|
481
|
+
reject(e)
|
|
482
|
+
})
|
|
483
|
+
})
|
|
484
|
+
}
|
|
485
|
+
|
|
17
486
|
}
|