cityworks 0.0.36 → 0.0.38
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 +4 -2
- package/dist/cityworks.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.m.js +1 -1
- package/dist/index.m.js.map +1 -1
- package/dist/index.modern.mjs +1 -1
- package/dist/index.modern.mjs.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +2 -1
- package/index.js +0 -1
- package/src/activity_link.ts +0 -241
- package/src/case.ts +0 -282
- package/src/case_admin.ts +0 -883
- package/src/case_assets.ts +0 -129
- package/src/case_data.ts +0 -446
- package/src/case_financial.ts +0 -848
- package/src/case_workflow.ts +0 -462
- package/src/cityworks.ts +0 -719
- package/src/comments.ts +0 -167
- package/src/costs.ts +0 -289
- package/src/error.ts +0 -56
- package/src/event_layer.ts +0 -231
- package/src/general.ts +0 -143
- package/src/gis.ts +0 -242
- package/src/index.ts +0 -1
- package/src/inspection.ts +0 -851
- package/src/inspection_admin.ts +0 -45
- package/src/message_queue.ts +0 -243
- package/src/request.ts +0 -823
- package/src/request_admin.ts +0 -35
- package/src/search.ts +0 -339
- package/src/workorder.ts +0 -838
- package/src/workorder_admin.ts +0 -248
- package/test/01.cityworksTest.js +0 -80
- package/test/02.activitylinkTest.js +0 -58
- package/test/03.generalTest.js +0 -87
- package/test/04.requestTest.js +0 -293
- package/test/05.caseTest.js +0 -110
- package/test/06.caseFinancialTest.js +0 -172
- package/test/07.searchTest.js +0 -191
- package/test/08.workOrderTest.js +0 -48
- package/test/09.caseAssetsTest.js +0 -72
- package/test/09.inspectionTest.js +0 -28
- package/tsconfig.json +0 -68
package/src/request.ts
DELETED
|
@@ -1,823 +0,0 @@
|
|
|
1
|
-
import { CWError } from './error'
|
|
2
|
-
const _ = require('lodash')
|
|
3
|
-
import { RequestAdmin } from './request_admin'
|
|
4
|
-
import { Comments } from './comments'
|
|
5
|
-
|
|
6
|
-
export class Request {
|
|
7
|
-
/**
|
|
8
|
-
* @hidden
|
|
9
|
-
*/
|
|
10
|
-
cw: any
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Request Administration methods
|
|
14
|
-
*/
|
|
15
|
-
admin?: Object
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* WorkOrder Comments methods
|
|
19
|
-
*/
|
|
20
|
-
comment: Object
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* @hidden
|
|
24
|
-
*/
|
|
25
|
-
constructor(cw) {
|
|
26
|
-
this.cw = cw
|
|
27
|
-
this.admin = new RequestAdmin(cw)
|
|
28
|
-
this.comment = new Comments(cw, 'Request')
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Create new requests
|
|
33
|
-
*
|
|
34
|
-
* @category Requests
|
|
35
|
-
* @param {Object} sr_data - See /{subdirectory}/apidocs/#/data-type-infodataType=RequestBase on the Cityworks instance
|
|
36
|
-
* @return {Object} Returns Promise that represents an object describing the newly-created request
|
|
37
|
-
*/
|
|
38
|
-
create(sr_data: Object) {
|
|
39
|
-
return new Promise((resolve, reject) => {
|
|
40
|
-
if(!_.has(sr_data, 'ProblemSid')) {
|
|
41
|
-
reject(new CWError(2, 'ProblemSid must be provided.', {'provided': sr_data}))
|
|
42
|
-
} else {
|
|
43
|
-
this.cw.runRequest('Ams/ServiceRequest/Create', sr_data).then(r => {
|
|
44
|
-
resolve(r.Value)
|
|
45
|
-
}).catch(e => {
|
|
46
|
-
reject(e)
|
|
47
|
-
})
|
|
48
|
-
}
|
|
49
|
-
})
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Update a request
|
|
54
|
-
*
|
|
55
|
-
* @category Requests
|
|
56
|
-
* @param {object} sr_data - See /{subdirectory}/apidocs/#/data-type-infodataType=RequestBase on the Cityworks instance
|
|
57
|
-
* @return {Object} Returns Promise that represents an object describing the updated request
|
|
58
|
-
*/
|
|
59
|
-
update(sr_data: Object) {
|
|
60
|
-
return new Promise((resolve, reject) => {
|
|
61
|
-
if(!_.has(sr_data, 'RequestId')) {
|
|
62
|
-
reject(new CWError(3, 'RequestId must be provided.', {'provided': sr_data}))
|
|
63
|
-
} else {
|
|
64
|
-
this.cw.runRequest('Ams/ServiceRequest/Update', sr_data).then(r => {
|
|
65
|
-
resolve(r.Value)
|
|
66
|
-
}).catch(e => {
|
|
67
|
-
reject(e)
|
|
68
|
-
})
|
|
69
|
-
}
|
|
70
|
-
})
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Move a request's point
|
|
75
|
-
*
|
|
76
|
-
* @category Requests
|
|
77
|
-
* @param {number} requestId
|
|
78
|
-
* @param {number} x
|
|
79
|
-
* @param {number} y
|
|
80
|
-
* @param {Object} projection - Should include at least WKT _or_ WKID attribute. Can also include VcsWKID attribute.
|
|
81
|
-
* @param {number} [z] - Optional Z coordinate
|
|
82
|
-
* @return {Object} Returns Promise that represents an object describing the updated GISPoint
|
|
83
|
-
*/
|
|
84
|
-
move(requestId: number, x: number, y: number, projection: {WKID?: string, WKT?: string, VcsWKID?: string}, z?: number) {
|
|
85
|
-
return new Promise((resolve, reject) => {
|
|
86
|
-
if(!_.has(projection, 'WKID') && !_.has(projection, 'WKT')) {
|
|
87
|
-
// Throw error
|
|
88
|
-
reject(new CWError(6, 'You must provide either the WKID or WKT for the x/y coordinates.', {'projection': projection}))
|
|
89
|
-
}
|
|
90
|
-
var base_data = {
|
|
91
|
-
RequestId: requestId,
|
|
92
|
-
X: x,
|
|
93
|
-
Y: y
|
|
94
|
-
};
|
|
95
|
-
if(typeof(z)!='undefined') {
|
|
96
|
-
_.set(base_data, 'Z', z)
|
|
97
|
-
}
|
|
98
|
-
var data = _.merge(base_data, projection);
|
|
99
|
-
this.cw.runRequest('Ams/ServiceRequest/Move', data).then(r => {
|
|
100
|
-
resolve(r.Value)
|
|
101
|
-
}).catch(e => {
|
|
102
|
-
reject(e)
|
|
103
|
-
})
|
|
104
|
-
})
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Update request's map layer fields
|
|
109
|
-
*
|
|
110
|
-
* @category Requests
|
|
111
|
-
* @param {number} requestId
|
|
112
|
-
* @return {Object} Returns Promise that represents an object describing the updated map layer fields
|
|
113
|
-
*/
|
|
114
|
-
updateMLF = (requestId: number) => {
|
|
115
|
-
return new Promise((resolve, reject) => {
|
|
116
|
-
var data = {
|
|
117
|
-
ServiceRequestId: requestId
|
|
118
|
-
}
|
|
119
|
-
this.cw.runRequest('Ams/TemplateMapLayer/ServiceRequestInstanceMapLayersByRequestId', data).then(r => {
|
|
120
|
-
resolve(r.Value)
|
|
121
|
-
}).catch(e => {
|
|
122
|
-
reject(e)
|
|
123
|
-
})
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Change a request's problem code
|
|
129
|
-
*
|
|
130
|
-
* @category Requests
|
|
131
|
-
* @param {number} requestId - The request ID to change
|
|
132
|
-
* @param {number} problemSid - The request's new ProblemSID
|
|
133
|
-
* @return {Object} Returns Promise that represents an object describing the updated request
|
|
134
|
-
*/
|
|
135
|
-
changeProblem(requestId: number, problemSid: number) {
|
|
136
|
-
return new Promise((resolve, reject) => {
|
|
137
|
-
var data = {
|
|
138
|
-
RequestId: requestId,
|
|
139
|
-
ProblemSid: problemSid
|
|
140
|
-
}
|
|
141
|
-
this.cw.runRequest('Ams/ServiceRequest/ChangeProblem', data).then(r => {
|
|
142
|
-
resolve(r.Value)
|
|
143
|
-
}).catch(e => {
|
|
144
|
-
reject(e)
|
|
145
|
-
})
|
|
146
|
-
})
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Get a request by ID
|
|
151
|
-
*
|
|
152
|
-
* @category Requests
|
|
153
|
-
* @param {number} requestId - The ID of the request to retrieve
|
|
154
|
-
* @return {Object} Returns Promise that represents an object describing the request
|
|
155
|
-
*/
|
|
156
|
-
getById(requestId: number) {
|
|
157
|
-
return new Promise((resolve, reject) => {
|
|
158
|
-
var data = {
|
|
159
|
-
RequestId: requestId
|
|
160
|
-
}
|
|
161
|
-
this.cw.runRequest('Ams/ServiceRequest/ById', data).then(r => {
|
|
162
|
-
resolve(r.Value)
|
|
163
|
-
}).catch(e => {
|
|
164
|
-
reject(e)
|
|
165
|
-
})
|
|
166
|
-
})
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Get requests by array of IDs
|
|
171
|
-
*
|
|
172
|
-
* @category Requests
|
|
173
|
-
* @param {Array<number>} requestIds - The request IDs to retrieve
|
|
174
|
-
* @return {Object} Returns Promise that represents a collection of Objects describing the requests
|
|
175
|
-
*/
|
|
176
|
-
getByIds(requestIds: Array<number>) {
|
|
177
|
-
return new Promise((resolve, reject) => {
|
|
178
|
-
var data = {
|
|
179
|
-
RequestIds: requestIds
|
|
180
|
-
}
|
|
181
|
-
this.cw.runRequest('Ams/ServiceRequest/ByIds', data).then(r => {
|
|
182
|
-
resolve(r.Value)
|
|
183
|
-
}).catch(e => {
|
|
184
|
-
reject(e)
|
|
185
|
-
})
|
|
186
|
-
})
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* Get the audit log for a specific request
|
|
191
|
-
*
|
|
192
|
-
* @category Requests
|
|
193
|
-
* @param {number} requestId - A Request ID to get the audit log for
|
|
194
|
-
* @return {Object} Returns Promise that represents a collection of Cityworks Metadata Objects
|
|
195
|
-
*/
|
|
196
|
-
getAuditLog(requestId: number) {
|
|
197
|
-
return new Promise((resolve, reject) => {
|
|
198
|
-
var data = {RequestId: requestId}
|
|
199
|
-
this.cw.runRequest('Ams/ServiceRequest/AuditLog', data).then(r => {
|
|
200
|
-
resolve(r.Value)
|
|
201
|
-
}).catch(e => {
|
|
202
|
-
reject(e)
|
|
203
|
-
})
|
|
204
|
-
})
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* Get custom fields for provided requests
|
|
209
|
-
*
|
|
210
|
-
* @category Requests
|
|
211
|
-
* @param {Array<number>} requestIds - The RequestIds whose custom fields should be returned
|
|
212
|
-
* @return {Object} Returns Promise that represents a collection of custom fields
|
|
213
|
-
*/
|
|
214
|
-
getCustomFields(requestIds: Array<number>) {
|
|
215
|
-
return new Promise((resolve, reject) => {
|
|
216
|
-
var data = {
|
|
217
|
-
RequestIds: requestIds,
|
|
218
|
-
}
|
|
219
|
-
this.cw.runRequest('Ams/ServiceRequest/CustomFields', data).then(r => {
|
|
220
|
-
resolve(r.Value)
|
|
221
|
-
}).catch(e => {
|
|
222
|
-
reject(e)
|
|
223
|
-
})
|
|
224
|
-
})
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
/**
|
|
228
|
-
* Change custom field category for provided requests
|
|
229
|
-
*
|
|
230
|
-
* @category Requests
|
|
231
|
-
* @param {Array<number>} requestIds - The RequestIds whose custom fields should be returned
|
|
232
|
-
* @param {number} categoryId - The new custom field grouping/category which should be assigned to the provided requests
|
|
233
|
-
* @return {Object} Returns Promise that represents a collection of requests
|
|
234
|
-
*/
|
|
235
|
-
changeCustomFieldCategory(requestIds: Array<number>, categoryId: number) {
|
|
236
|
-
return new Promise((resolve, reject) => {
|
|
237
|
-
var data = {
|
|
238
|
-
RequestIds: requestIds,
|
|
239
|
-
CategoryId: categoryId
|
|
240
|
-
}
|
|
241
|
-
this.cw.runRequest('Ams/ServiceRequest/ChangeCustomFieldCategory', data).then(r => {
|
|
242
|
-
resolve(r.Value)
|
|
243
|
-
}).catch(e => {
|
|
244
|
-
reject(e)
|
|
245
|
-
})
|
|
246
|
-
})
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
/**
|
|
250
|
-
* Cancel requests
|
|
251
|
-
*
|
|
252
|
-
* @category Requests
|
|
253
|
-
* @param {Array<number>} requestIds - An array of the IDs to cancel the matched requests
|
|
254
|
-
* @param {string} [cancelReason] - A reason for cancelling the request(s)
|
|
255
|
-
* @param {datetime} [dateCancelled] - The date/time that it should be indicated the request was cancelled
|
|
256
|
-
* @return {Object} Returns object that represents a collection of requests
|
|
257
|
-
*/
|
|
258
|
-
cancel(requestIds: Array<number>, cancelReason?: string, dateCancelled?: Date) {
|
|
259
|
-
return new Promise((resolve, reject) => {
|
|
260
|
-
var m = new Date()
|
|
261
|
-
var data: {RequestIds: Array<number>, CancelReason?: string, DateCancelled?: Date} = { RequestIds: requestIds }
|
|
262
|
-
if(typeof(cancelReason)!=='undefined')
|
|
263
|
-
_.set(data, 'CancelReason', cancelReason);
|
|
264
|
-
if(typeof(dateCancelled)!=='undefined')
|
|
265
|
-
_.set(data, 'DateCancelled', dateCancelled);
|
|
266
|
-
this.cw.runRequest('Ams/ServiceRequest/Cancel', data).then(r => {
|
|
267
|
-
resolve(r.Value)
|
|
268
|
-
}).catch(e => {
|
|
269
|
-
reject(e)
|
|
270
|
-
})
|
|
271
|
-
})
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
/**
|
|
275
|
-
* Uncancel requests
|
|
276
|
-
*
|
|
277
|
-
* @category Requests
|
|
278
|
-
* @param {Array<number>} requestIds - An array of the IDs to uncancel the matched requests
|
|
279
|
-
* @return {Object} Returns object that represents a collection of requests
|
|
280
|
-
*/
|
|
281
|
-
uncancel(requestIds: Array<number>) {
|
|
282
|
-
return new Promise((resolve, reject) => {
|
|
283
|
-
var data = {
|
|
284
|
-
RequestIds: requestIds
|
|
285
|
-
}
|
|
286
|
-
this.cw.runRequest('Ams/ServiceRequest/Uncancel', data).then(r => {
|
|
287
|
-
resolve(r.Value)
|
|
288
|
-
}).catch(e => {
|
|
289
|
-
reject(e)
|
|
290
|
-
})
|
|
291
|
-
})
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
/**
|
|
295
|
-
* Close requests
|
|
296
|
-
*
|
|
297
|
-
* @category Requests
|
|
298
|
-
* @param {Array<number>} requestIds - An array of the IDs to close the matched requests
|
|
299
|
-
* @return {Object} Returns object that represents a collection of requests
|
|
300
|
-
*/
|
|
301
|
-
close(requestIds: Array<number>) {
|
|
302
|
-
return new Promise((resolve, reject) => {
|
|
303
|
-
var data = {
|
|
304
|
-
RequestIds: requestIds
|
|
305
|
-
}
|
|
306
|
-
this.cw.runRequest('Ams/ServiceRequest/Close', data).then(r => {
|
|
307
|
-
if(r.Status>0) {
|
|
308
|
-
reject(new CWError(5, r.Message, {'response': r}))
|
|
309
|
-
} else {
|
|
310
|
-
resolve(r.Value)
|
|
311
|
-
}
|
|
312
|
-
}).catch(e => {
|
|
313
|
-
reject(e)
|
|
314
|
-
})
|
|
315
|
-
})
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
/**
|
|
319
|
-
* Reopen closed requests
|
|
320
|
-
*
|
|
321
|
-
* @category Requests
|
|
322
|
-
* @param {Array<number>} requestIds - An array of the IDs to reopen the matched requests
|
|
323
|
-
* @return {Object} Returns object that represents a collection of requests
|
|
324
|
-
*/
|
|
325
|
-
reopen(requestIds: Array<number>) {
|
|
326
|
-
return new Promise((resolve, reject) => {
|
|
327
|
-
var data = {
|
|
328
|
-
RequestIds: requestIds
|
|
329
|
-
}
|
|
330
|
-
this.cw.runRequest('Ams/ServiceRequest/ReOpen', data).then(r => {
|
|
331
|
-
resolve(r.Value)
|
|
332
|
-
}).catch(e => {
|
|
333
|
-
reject(e)
|
|
334
|
-
})
|
|
335
|
-
})
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
/**
|
|
339
|
-
* Delete requests
|
|
340
|
-
*
|
|
341
|
-
* @category Requests
|
|
342
|
-
* @param {Array<number>} requestIds - An array of the IDs to delete the matched requests
|
|
343
|
-
* @return {Object} Returns object that represents a collection of request Ids which have been deleted
|
|
344
|
-
*/
|
|
345
|
-
delete(requestIds: Array<number>) {
|
|
346
|
-
return new Promise((resolve, reject) => {
|
|
347
|
-
var data = {
|
|
348
|
-
RequestIds: requestIds
|
|
349
|
-
}
|
|
350
|
-
this.cw.runRequest('Ams/ServiceRequest/Delete', data).then(r => {
|
|
351
|
-
if(r.Status>0) {
|
|
352
|
-
reject(new CWError(4, r.Message, {'response': r}))
|
|
353
|
-
} else {
|
|
354
|
-
resolve(r.Value)
|
|
355
|
-
}
|
|
356
|
-
}).catch(e => {
|
|
357
|
-
reject(e)
|
|
358
|
-
})
|
|
359
|
-
})
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
/**
|
|
363
|
-
* Search for requests
|
|
364
|
-
*
|
|
365
|
-
* @category Request Search
|
|
366
|
-
* @param {Object} searchData - The search information to retrieve matched requests, see instance docs: /{subdirectory}/apidocs/#/service-info/Ams/ServiceRequest
|
|
367
|
-
* @return {Object} Returns Promise that represents an Array of the matching request IDs
|
|
368
|
-
*/
|
|
369
|
-
search(searchData: Object) {
|
|
370
|
-
return new Promise((resolve, reject) => {
|
|
371
|
-
var data = searchData
|
|
372
|
-
this.cw.runRequest('Ams/ServiceRequest/Search', data).then(r => {
|
|
373
|
-
resolve(r.Value)
|
|
374
|
-
}).catch(e => {
|
|
375
|
-
reject(e)
|
|
376
|
-
})
|
|
377
|
-
})
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
/**
|
|
381
|
-
* Get the records on the basis of RequestId, only populates RequestId, Description, ProblemCode properties
|
|
382
|
-
*
|
|
383
|
-
* @category Request Object Search
|
|
384
|
-
* @param {string} requestId - ???, see instance docs: /{subdirectory}/apidocs/#/service-info/Ams/ServiceRequest
|
|
385
|
-
* @return {Object} Returns Promise that represents a collection of the matching (limited) request objects
|
|
386
|
-
*/
|
|
387
|
-
searchObject(requestId: string) {
|
|
388
|
-
return new Promise((resolve, reject) => {
|
|
389
|
-
var data = {
|
|
390
|
-
RequestId: requestId
|
|
391
|
-
}
|
|
392
|
-
this.cw.runRequest('Ams/ServiceRequest/SearchObject', data).then(r => {
|
|
393
|
-
resolve(r.Value)
|
|
394
|
-
}).catch(e => {
|
|
395
|
-
reject(e)
|
|
396
|
-
})
|
|
397
|
-
})
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
/**
|
|
401
|
-
* Create a search definition. Save the definition by setting SaveDefinition = true and supplying a SearchName.
|
|
402
|
-
*
|
|
403
|
-
* @category Requests
|
|
404
|
-
* @param {Object} searchData - Search data variables. See /{subdirectory}/apidocs/#/service-info/Ams/ServiceRequest
|
|
405
|
-
* @param {number} [searchName] - What to name your search (if it should be saved)
|
|
406
|
-
* @param {number} [sharedWithin] - What group or domain to share the search to.
|
|
407
|
-
* @param {boolean} saveDefinition - Whether or not to save the search definition. Defaults to true when a search name is specified.
|
|
408
|
-
* @param {boolean} enableEurl - Whether or not to enable EURL for the saved search. Defaults to true.
|
|
409
|
-
* @return {Object} Returns Promise that represents a collection of Cityworks Metadata Objects
|
|
410
|
-
*/
|
|
411
|
-
createSearchDefinition(searchData: Object, searchName?: string, sharedWithin?: number, saveDefinition: boolean = true, enableEurl: boolean = true) {
|
|
412
|
-
return new Promise((resolve, reject) => {
|
|
413
|
-
var data = searchData
|
|
414
|
-
if(_.isString(searchName)) {
|
|
415
|
-
_.set(data, 'SearchName', searchName)
|
|
416
|
-
_.set(data, 'SaveDefinition', saveDefinition)
|
|
417
|
-
_.set(data, 'EnableEurl', enableEurl)
|
|
418
|
-
// not sure how to handle sharedWithin...
|
|
419
|
-
// _.set(data, 'SharedWithin', sharedWithin)
|
|
420
|
-
}
|
|
421
|
-
this.cw.runRequest('Ams/ServiceRequest/CreateSearchDefinition', data).then(r => {
|
|
422
|
-
resolve(r.Value)
|
|
423
|
-
}).catch(e => {
|
|
424
|
-
reject(e)
|
|
425
|
-
})
|
|
426
|
-
})
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
/**
|
|
430
|
-
* Get a list of problem nodes for a domain
|
|
431
|
-
*
|
|
432
|
-
* @category Request Categorization
|
|
433
|
-
* @param {number} domainId - The domain ID for which to retrieve problem nodes.
|
|
434
|
-
* @param {boolean} viewOnly - Return only view only problem nodes. Defaults to false.
|
|
435
|
-
* @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.
|
|
436
|
-
* @param {boolean} includeCancelled - Return only cancelled problem nodes as well. Defaults to false.
|
|
437
|
-
* @return {Object} Returns Promise that represents a collection of problem node objects.
|
|
438
|
-
*/
|
|
439
|
-
getProblemNodes(domainId: number, viewOnly: boolean = false, displayMode?: Object, includeCancelled: boolean = false) {
|
|
440
|
-
return new Promise((resolve, reject) => {
|
|
441
|
-
var data = {
|
|
442
|
-
DomainId: domainId,
|
|
443
|
-
IncludeCancelled: includeCancelled,
|
|
444
|
-
ViewOnly: viewOnly
|
|
445
|
-
}
|
|
446
|
-
if(typeof displayMode != 'undefined' && displayMode !== null && _.has(displayMode, 'DisplayTextMode')) {
|
|
447
|
-
_.set(data, 'DisplayTextMode', _.get(displayMode, 'DisplayTextMode'))
|
|
448
|
-
if(_.get(displayMode, 'DisplayTextMode')=='CD' && _.has(displayMode, 'DisplayTextDelimeter')) {
|
|
449
|
-
_.set(data, 'DisplayTextDelimeter', _.get(displayMode, 'DisplayTextDelimeter'))
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
this.cw.runRequest('Ams/ServiceRequest/ProblemNodes', data).then(r => {
|
|
453
|
-
// console.log(_.filter(r, function(o) { return !o.Cancel; }), 'filter');
|
|
454
|
-
// console.log(_.some(r.Value, ['Cancel', true]), 'some');
|
|
455
|
-
resolve(r.Value)
|
|
456
|
-
}).catch(e => {
|
|
457
|
-
reject(e)
|
|
458
|
-
})
|
|
459
|
-
})
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
/**
|
|
463
|
-
* Get a list of problem codes
|
|
464
|
-
*
|
|
465
|
-
* @category Request Options
|
|
466
|
-
* @param {boolean} forPublicOnly - Return only publicly-available service requests. Defaults to false.
|
|
467
|
-
* @param {boolean} onlyActiveTemplates - Return only active templates. Defaults to true.
|
|
468
|
-
* @return {Object} Returns Promise that represents an Array of problem name objects.
|
|
469
|
-
*/
|
|
470
|
-
getProblems(forPublicOnly: boolean = false, onlyActiveTemplates: boolean = true, domainIds?: Array<number>) {
|
|
471
|
-
return new Promise((resolve, reject) => {
|
|
472
|
-
var data = {
|
|
473
|
-
ForPublicOnly: forPublicOnly,
|
|
474
|
-
OnlyActiveTemplates: onlyActiveTemplates
|
|
475
|
-
}
|
|
476
|
-
if(typeof domainIds != 'undefined') {
|
|
477
|
-
_.set(data, 'DomainIds', domainIds)
|
|
478
|
-
}
|
|
479
|
-
this.cw.runRequest('Ams/ServiceRequest/Problems', data).then(r => {
|
|
480
|
-
resolve(r.Value)
|
|
481
|
-
}).catch(e => {
|
|
482
|
-
reject(e)
|
|
483
|
-
})
|
|
484
|
-
})
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
/**
|
|
488
|
-
* Get a list of problem codes by keywords
|
|
489
|
-
*
|
|
490
|
-
* @category Request Options
|
|
491
|
-
* @param {string} keywords - Keywords to search for potential problem codes
|
|
492
|
-
* @return {Object} Returns Promise that represents an Array of problem name objects.
|
|
493
|
-
*/
|
|
494
|
-
getProblemsByKeywords(keywords: string) {
|
|
495
|
-
return new Promise((resolve, reject) => {
|
|
496
|
-
var data = {
|
|
497
|
-
Keywords: keywords
|
|
498
|
-
}
|
|
499
|
-
this.cw.runRequest('Ams/ServiceRequest/ProblemsByKeywords', data).then(r => {
|
|
500
|
-
resolve(r.Value)
|
|
501
|
-
}).catch(e => {
|
|
502
|
-
reject(e)
|
|
503
|
-
})
|
|
504
|
-
})
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
/**
|
|
508
|
-
* Get a list of a problem code's priorities
|
|
509
|
-
*
|
|
510
|
-
* @category Request Options
|
|
511
|
-
* @param {number} problemSid - Return priorities for given problemSid
|
|
512
|
-
* @return {Object} Returns Promise that represents an Array of priorities
|
|
513
|
-
*/
|
|
514
|
-
getPriorities(problemSid: number) {
|
|
515
|
-
return new Promise((resolve, reject) => {
|
|
516
|
-
var data = {
|
|
517
|
-
ProblemSids: problemSid,
|
|
518
|
-
}
|
|
519
|
-
this.cw.runRequest('Ams/ServiceRequest/Priorities', data).then(r => {
|
|
520
|
-
resolve(r.Value)
|
|
521
|
-
}).catch(e => {
|
|
522
|
-
reject(e)
|
|
523
|
-
})
|
|
524
|
-
})
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
/**
|
|
528
|
-
* Get custom field templates for problem code
|
|
529
|
-
*
|
|
530
|
-
* @category Request Options
|
|
531
|
-
* @param {number} problemSid - The problemSid whose template custom fields should be returned
|
|
532
|
-
* @return {Object} Returns Promise that represents a collection of custom fields
|
|
533
|
-
*/
|
|
534
|
-
getCustomFieldTemplate(problemSid: number) {
|
|
535
|
-
return new Promise((resolve, reject) => {
|
|
536
|
-
var data = {
|
|
537
|
-
ProblemSids: problemSid,
|
|
538
|
-
}
|
|
539
|
-
this.cw.runRequest('Ams/ServiceRequest/TemplateCustomFields', data).then(r => {
|
|
540
|
-
resolve(r.Value)
|
|
541
|
-
}).catch(e => {
|
|
542
|
-
reject(e)
|
|
543
|
-
})
|
|
544
|
-
})
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
/**
|
|
548
|
-
* Get the questions and answer options for a problem code
|
|
549
|
-
*
|
|
550
|
-
* @category Request Options
|
|
551
|
-
* @param {number} problemSid - The problemSid whose Q&A should be returned
|
|
552
|
-
* @return {Object} Returns Promise that represents a collection of questions and answer settings
|
|
553
|
-
*/
|
|
554
|
-
getQASettings(problemSid: number) {
|
|
555
|
-
return new Promise((resolve, reject) => {
|
|
556
|
-
var data = {
|
|
557
|
-
ProblemSids: problemSid,
|
|
558
|
-
}
|
|
559
|
-
this.cw.runRequest('Ams/ServiceRequest/QA', data).then(r => {
|
|
560
|
-
resolve(r.Value)
|
|
561
|
-
}).catch(e => {
|
|
562
|
-
reject(e)
|
|
563
|
-
})
|
|
564
|
-
})
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
/**
|
|
568
|
-
* Get problem leaf (template) by Sid
|
|
569
|
-
*
|
|
570
|
-
* @category Request Options
|
|
571
|
-
* @param {number} problemSid - Return problem leaf for given problemSid
|
|
572
|
-
* @return {Object} Returns Promise that represents an Object that describes the problem leaf (template)
|
|
573
|
-
*/
|
|
574
|
-
getProblemLeaf(problemSid: number) {
|
|
575
|
-
return new Promise((resolve, reject) => {
|
|
576
|
-
var data = {
|
|
577
|
-
ProblemSid: problemSid
|
|
578
|
-
}
|
|
579
|
-
this.cw.runRequest('Ams/ServiceRequest/ProblemLeafBySid', data).then(r => {
|
|
580
|
-
resolve(r.Value)
|
|
581
|
-
}).catch(e => {
|
|
582
|
-
reject(e)
|
|
583
|
-
})
|
|
584
|
-
})
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
/**
|
|
588
|
-
* Get a list of default statuses
|
|
589
|
-
*
|
|
590
|
-
* @category Request Options
|
|
591
|
-
* @param {Array<number>} domainIds - List of domains to return default statuses for
|
|
592
|
-
* @return {Object} Returns Promise that represents an Array of statuses.
|
|
593
|
-
*/
|
|
594
|
-
getStatuses(domainIds: Array<number>) {
|
|
595
|
-
return new Promise((resolve, reject) => {
|
|
596
|
-
var data = {
|
|
597
|
-
DomainIds: domainIds
|
|
598
|
-
}
|
|
599
|
-
this.cw.runRequest('Ams/ServiceRequest/DefaultStatus', data).then(r => {
|
|
600
|
-
resolve(r.Value)
|
|
601
|
-
}).catch(e => {
|
|
602
|
-
reject(e)
|
|
603
|
-
})
|
|
604
|
-
})
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
/**
|
|
608
|
-
* Get a list of possible Employee values
|
|
609
|
-
*
|
|
610
|
-
* @category Request Options
|
|
611
|
-
* @param {string} listType - Which list (endpoint) to get. Includes only DispatchTo & SubmitTo.
|
|
612
|
-
* @param {number} domainId - Domain to return possible dispatchTo values for
|
|
613
|
-
* @return {Object} Returns Promise that represents an Array of Employee options.
|
|
614
|
-
*/
|
|
615
|
-
getEmployeeLists(listType: string, domainId: number) {
|
|
616
|
-
return new Promise((resolve, reject) => {
|
|
617
|
-
// TODO: make a default domain option on the CW object for cases like this.
|
|
618
|
-
var data = {
|
|
619
|
-
DomainId: domainId
|
|
620
|
-
}
|
|
621
|
-
if(!_.includes(['DispatchTo', 'SubmitTo'], listType)) {
|
|
622
|
-
reject(new CWError(2, 'listType must be either SubmitTo or DispatchTo.', {'provided': listType}))
|
|
623
|
-
} else {
|
|
624
|
-
this.cw.runRequest(`Ams/ServiceRequest/${listType}`, data).then(r => {
|
|
625
|
-
resolve(r.Value)
|
|
626
|
-
}).catch(e => {
|
|
627
|
-
reject(e)
|
|
628
|
-
})
|
|
629
|
-
}
|
|
630
|
-
})
|
|
631
|
-
}
|
|
632
|
-
|
|
633
|
-
/**
|
|
634
|
-
* Get a list of possible DispatchTo values
|
|
635
|
-
*
|
|
636
|
-
* @category Request Options
|
|
637
|
-
* @param {number} domainId - Domain to return possible dispatchTo values for
|
|
638
|
-
* @return {Object} Returns Promise that represents an Array of dispatchTo options.
|
|
639
|
-
*/
|
|
640
|
-
getDispatchTos(domainId: number) {
|
|
641
|
-
// Fix name for choice of non-pluralized endpoint. Unlike WOs & Inspections...
|
|
642
|
-
return this.getEmployeeLists('DispatchTo', domainId);
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
/**
|
|
646
|
-
* Get a list of possible SubmitTo values
|
|
647
|
-
*
|
|
648
|
-
* @category Request Options
|
|
649
|
-
* @param {number} domainId - Domain to return possible submitTo values for
|
|
650
|
-
* @return {Object} Returns Promise that represents an Array of submitTo options.
|
|
651
|
-
*/
|
|
652
|
-
getSubmitTos(domainId: number) {
|
|
653
|
-
// Fix name for choice of non-pluralized endpoint. Unlike WOs & Inspections...
|
|
654
|
-
return this.getEmployeeLists('SubmitTo', domainId);
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
/**
|
|
658
|
-
* Get street codes
|
|
659
|
-
*
|
|
660
|
-
* @category Request Options
|
|
661
|
-
* @return {Object} Returns Promise that represents an Array of Street Codes.
|
|
662
|
-
*/
|
|
663
|
-
streetCodes() {
|
|
664
|
-
return new Promise((resolve, reject) => {
|
|
665
|
-
this.cw.runRequest('Ams/ServiceRequest/AllStreetCode', {}).then(r => {
|
|
666
|
-
resolve(r.Value)
|
|
667
|
-
}).catch(e => {
|
|
668
|
-
reject(e)
|
|
669
|
-
})
|
|
670
|
-
})
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
/**
|
|
674
|
-
* Get a list of templates
|
|
675
|
-
*
|
|
676
|
-
* @category Request Templates
|
|
677
|
-
* @param {Array<number>} problemSids - An array list of problemSids to retrieve templates for
|
|
678
|
-
* @param {Date} [minimumDateModified] - ?
|
|
679
|
-
* @param {Date} [maximumDateModified] - ?
|
|
680
|
-
* @return {Object} Returns Promise that represents
|
|
681
|
-
*/
|
|
682
|
-
getTemplatesById(problemSids: Array<number>, minimumDateModified?: Date, maximumDateModified?: Date) {
|
|
683
|
-
return new Promise((resolve, reject) => {
|
|
684
|
-
var data = {
|
|
685
|
-
ProblemSids: null
|
|
686
|
-
}
|
|
687
|
-
if(typeof minimumDateModified != 'undefined') {
|
|
688
|
-
_.set(data, 'MinimumDateModified', minimumDateModified)
|
|
689
|
-
}
|
|
690
|
-
if(typeof maximumDateModified != 'undefined') {
|
|
691
|
-
_.set(data, 'MaximumDateModified', maximumDateModified)
|
|
692
|
-
}
|
|
693
|
-
|
|
694
|
-
this.cw.runRequest('Ams/ServiceRequestTemplate/ByIds', data).then(r => {
|
|
695
|
-
resolve(r.Value)
|
|
696
|
-
}).catch(e => {
|
|
697
|
-
reject(e)
|
|
698
|
-
})
|
|
699
|
-
})
|
|
700
|
-
}
|
|
701
|
-
|
|
702
|
-
/**
|
|
703
|
-
* Create a search definition. Save the definition by setting SaveDefinition = true and supplying a SearchName.
|
|
704
|
-
*
|
|
705
|
-
* @category Request Templates
|
|
706
|
-
* @param {Object} searchData - Search data variables. See /{subdirectory}/apidocs/#/service-info/Ams/ServiceRequestTemplate
|
|
707
|
-
* @param {number} [searchName] - What to name your search (if it should be saved)
|
|
708
|
-
* @param {number} [sharedWithin] - What group or domain to share the search to.
|
|
709
|
-
* @param {boolean} saveDefinition - Whether or not to save the search definition. Defaults to true when a search name is specified.
|
|
710
|
-
* @return {Object} Returns Promise that represents a collection of Cityworks Metadata Objects. See: /{subdirectory}/apidocs/#/data-type-info;dataType=CWMetadata
|
|
711
|
-
*/
|
|
712
|
-
createTemplateSearchDefinition(searchData: Object, searchName?: string, sharedWithin?: number, saveDefinition: boolean = true) {
|
|
713
|
-
return new Promise((resolve, reject) => {
|
|
714
|
-
var data = searchData
|
|
715
|
-
if(_.isString(searchName)) {
|
|
716
|
-
_.set(data, 'SearchName', searchName)
|
|
717
|
-
_.set(data, 'SaveDefinition', saveDefinition)
|
|
718
|
-
// not sure how to handle sharedWithin...
|
|
719
|
-
// _.set(data, 'SharedWithin', sharedWithin)
|
|
720
|
-
}
|
|
721
|
-
this.cw.runRequest('Ams/ServiceRequestTemplate/CreateSearchDefinition', data).then(r => {
|
|
722
|
-
resolve(r.Value)
|
|
723
|
-
}).catch(e => {
|
|
724
|
-
reject(e)
|
|
725
|
-
})
|
|
726
|
-
})
|
|
727
|
-
}
|
|
728
|
-
|
|
729
|
-
/**
|
|
730
|
-
* Get the questions and answers for a(many) request template(s)
|
|
731
|
-
*
|
|
732
|
-
* @category Request Templates
|
|
733
|
-
* @param {Array<number>} problemSids - An array list of problemSids to retrieve templates for
|
|
734
|
-
* @return {Object} Returns Promise that represents a collection of ProblemQAs. See /{subdirectory}/apidocs/#/data-type-info;dataType=ProblemQA
|
|
735
|
-
*/
|
|
736
|
-
getTemplateQAs(problemSids: Array<number>, minimumDateModified?: Date, maximumDateModified?: Date) {
|
|
737
|
-
return new Promise((resolve, reject) => {
|
|
738
|
-
var data = {
|
|
739
|
-
ProblemSids: null
|
|
740
|
-
}
|
|
741
|
-
this.cw.runRequest('Ams/ServiceRequestTemplate/QA', data).then(r => {
|
|
742
|
-
resolve(r.Value)
|
|
743
|
-
}).catch(e => {
|
|
744
|
-
reject(e)
|
|
745
|
-
})
|
|
746
|
-
})
|
|
747
|
-
}
|
|
748
|
-
|
|
749
|
-
/**
|
|
750
|
-
* Get a list of template id results for a provided search parameters
|
|
751
|
-
*
|
|
752
|
-
* @category Request Templates
|
|
753
|
-
* @param {Object} searchData - Search data variables. See /{subdirectory}/apidocs/#/service-info/Ams/ServiceRequestTemplate
|
|
754
|
-
* @return {Object} Returns Promise that represents a list of template IDs.
|
|
755
|
-
*/
|
|
756
|
-
searchTemplates(searchData: Object) {
|
|
757
|
-
return new Promise((resolve, reject) => {
|
|
758
|
-
var data = searchData
|
|
759
|
-
this.cw.runRequest('Ams/ServiceRequestTemplate/Search', data).then(r => {
|
|
760
|
-
resolve(r.Value)
|
|
761
|
-
}).catch(e => {
|
|
762
|
-
reject(e)
|
|
763
|
-
})
|
|
764
|
-
})
|
|
765
|
-
}
|
|
766
|
-
|
|
767
|
-
/**
|
|
768
|
-
* Get request templates (problem leaf[s])
|
|
769
|
-
*
|
|
770
|
-
* @category Request Templates
|
|
771
|
-
* @param {Array<number>} [templateIds] - Array of specific template IDs to retrieve
|
|
772
|
-
* @param {number} canCreate - If true, only return templates the user can create, ignored if false or null, default is false
|
|
773
|
-
* @param {boolean} includeInactiveIf - If true, returns inactive templates, default is false
|
|
774
|
-
* @param {Date} [minimumDateModified] - ?
|
|
775
|
-
* @param {Date} [maximumDateModified] - ?
|
|
776
|
-
* @return {Object} Returns Promise that represents a collection of Problem Leafs. See /{subdirectory}/apidocs/#/data-type-info;dataType=ProblemLeaf
|
|
777
|
-
*/
|
|
778
|
-
getTemplates(templateIds: Array<number>, canCreate: boolean = false, includeInactiveIf: boolean = false, minimumDateModified?: Date, maximumDateModified?: Date) {
|
|
779
|
-
return new Promise((resolve, reject) => {
|
|
780
|
-
var data = {
|
|
781
|
-
CanCreate: canCreate,
|
|
782
|
-
IncludeInactiveIf: includeInactiveIf
|
|
783
|
-
}
|
|
784
|
-
if(typeof templateIds != 'undefined') {
|
|
785
|
-
_.set(data, 'TemplateIds', templateIds)
|
|
786
|
-
}
|
|
787
|
-
if(typeof minimumDateModified != 'undefined') {
|
|
788
|
-
_.set(data, 'MinimumDateModified', minimumDateModified)
|
|
789
|
-
}
|
|
790
|
-
if(typeof maximumDateModified != 'undefined') {
|
|
791
|
-
_.set(data, 'MaximumDateModified', maximumDateModified)
|
|
792
|
-
}
|
|
793
|
-
this.cw.runRequest('Ams/ServiceRequestTemplate/Templates', data).then(r => {
|
|
794
|
-
resolve(r.Value)
|
|
795
|
-
}).catch(e => {
|
|
796
|
-
reject(e)
|
|
797
|
-
})
|
|
798
|
-
})
|
|
799
|
-
}
|
|
800
|
-
|
|
801
|
-
/**
|
|
802
|
-
* Get WorkOrder templates that are associated to this request template type
|
|
803
|
-
*
|
|
804
|
-
* @category Request Templates
|
|
805
|
-
* @param {Array<number>} problemSids - An array list of problemSids to retrieve Problem WO templates for
|
|
806
|
-
* @param {boolean} includeInactiveIf - Include inactive WorkOrder templates, default is false
|
|
807
|
-
* @return {Object} Returns Promise that represents a collection of Problem WO Templates. See /{subdirectory}/apidocs/#/data-type-info;dataType=ProblemWOTemplate
|
|
808
|
-
*/
|
|
809
|
-
getWOTemplates(problemSids: Array<number>, includeInactive: boolean = false) {
|
|
810
|
-
return new Promise((resolve, reject) => {
|
|
811
|
-
var data = {
|
|
812
|
-
ProblemSids: problemSids,
|
|
813
|
-
IncludeInactive: includeInactive
|
|
814
|
-
}
|
|
815
|
-
this.cw.runRequest('Ams/ServiceRequestTemplate/WorkOrderTemplates', data).then(r => {
|
|
816
|
-
resolve(r.Value)
|
|
817
|
-
}).catch(e => {
|
|
818
|
-
reject(e)
|
|
819
|
-
})
|
|
820
|
-
})
|
|
821
|
-
}
|
|
822
|
-
|
|
823
|
-
}
|