cityworks 0.0.4 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cityworks",
3
- "version": "0.0.4",
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",
package/src/inspection.ts CHANGED
@@ -11,33 +11,34 @@ export class Inspection {
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 with data
18
+ * Create new inspection
19
19
  *
20
+ * @category Inspections
20
21
  * @param {Object} insp_data - See /{subdirectory}/apidocs/#/data-type-info;dataType=InspectionBase on your Cityworks instance
21
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
26
  if(!_.has(insp_data, 'EntityType') || !_.has(insp_data, 'InspTemplateId')) {
26
- reject(new CWError(1, 'EntityType and InspTemplateId properties must be provided.', {'provided': insp_data}));
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
39
- * (TODO: what array of entities)
40
40
  *
41
+ * @category Inspections
41
42
  * @param {Object} insp_data - See /{subdirectory}/apidocs/#/data-type-info;dataType=InspectionBase on your Cityworks instance
42
43
  * @return {Object} Returns Promise that represents a collection of objects describing the newly-created inspections
43
44
  */
@@ -55,9 +56,10 @@ export class Inspection {
55
56
  });
56
57
  }
57
58
 
58
- /*
59
+ /**
59
60
  * Create an inspection from a parent inspection (TODO: what parent!?)
60
61
  *
62
+ * @category Inspections
61
63
  * @param {object} insp_data - See /{subdirectory}/apidocs/#/data-type-info;dataType=InspectionBase on your Cityworks instance
62
64
  * @return {Object} Returns object that represents an object describing the newly-created inspection
63
65
  */
@@ -76,9 +78,10 @@ export class Inspection {
76
78
  });
77
79
  }
78
80
 
79
- /*
81
+ /**
80
82
  * Create an inspection from a service request
81
83
  *
84
+ * @category Inspections
82
85
  * @param {object} insp_data - See /{subdirectory}/apidocs/#/data-type-info;dataType=InspectionBase on your Cityworks instance
83
86
  * @return {Object} Returns object that represents an object describing the newly-created inspection
84
87
  */
@@ -96,9 +99,10 @@ export class Inspection {
96
99
  });
97
100
  }
98
101
 
99
- /*
102
+ /**
100
103
  * Create an inspection from a work order
101
104
  *
105
+ * @category Inspections
102
106
  * @param {object} insp_data - See /{subdirectory}/apidocs/#/data-type-info;dataType=InspectionBase on your Cityworks instance
103
107
  * @return {Object} Returns object that represents an object describing the newly-created inspection
104
108
  */
@@ -120,10 +124,11 @@ export class Inspection {
120
124
  }
121
125
 
122
126
  /**
123
- * Update an inspection with data
127
+ * Update an inspection
124
128
  *
125
- * @param {object} insp_data - See /{subdirectory}/apidocs/#/data-type-info;dataType=InspectionBase on your Cityworks instance
126
- * @return {Object} Returns object that represents an object describing the updated inspection
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
127
132
  */
128
133
  update(insp_data: Object) {
129
134
  return new Promise((resolve, reject) => {
@@ -144,6 +149,7 @@ export class Inspection {
144
149
  /**
145
150
  * Get an inspection by ID
146
151
  *
152
+ * @category Inspections
147
153
  * @param {number} inspectionId - The inspection ID to retrieve
148
154
  * @return {Object} Returns Promise that represents an object describing the inspection
149
155
  */
@@ -163,7 +169,8 @@ export class Inspection {
163
169
  /**
164
170
  * Get inspections by array of IDs
165
171
  *
166
- * @param {number} inspectionId - The inspection ID to retrieve
172
+ * @category Inspections
173
+ * @param {Array<number>} inspectionIds - The inspection IDs to retrieve
167
174
  * @return {Object} Returns Promise that represents a collection of Objects describing the inspections
168
175
  */
169
176
  getByIds(inspectionIds: Array<number>) {
@@ -182,6 +189,7 @@ export class Inspection {
182
189
  /**
183
190
  * Cancel inspections
184
191
  *
192
+ * @category Inspections
185
193
  * @param {Array<number>} inspectionIds - An array of the IDs to cancel the matched inspections
186
194
  * @param {string} [cancelReason] - A reason for cancelling the inspection(s)
187
195
  * @param {datetime} [dateCancelled] - The date/time that it should be indicated the inspection was cancelled
@@ -205,9 +213,30 @@ export class Inspection {
205
213
  });
206
214
  }
207
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
+
208
236
  /**
209
237
  * Close inspections
210
238
  *
239
+ * @category Inspections
211
240
  * @param {Array<number>} inspectionIds - An array of the IDs to close the matched inspections
212
241
  * @return {Object} Returns object that represents a collection of inspections
213
242
  */
@@ -224,9 +253,30 @@ export class Inspection {
224
253
  });
225
254
  }
226
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
+
227
276
  /**
228
277
  * Delete inspections
229
278
  *
279
+ * @category Inspections
230
280
  * @param {Array<number>} inspectionIds - An array of the IDs to delete the matched inspections
231
281
  * @return {Object} Returns object that represents a collection of inspection Ids which have been deleted
232
282
  */
@@ -243,28 +293,10 @@ export class Inspection {
243
293
  });
244
294
  }
245
295
 
246
- /**
247
- * Reopen inspections
248
- *
249
- * @param {Array<number>} inspectionIds - An array of the IDs to reopen the matched inspections
250
- * @return {Object} Returns object that represents a collection of inspection Ids which have been deleted
251
- */
252
- reopen(inspectionIds: Array<number>) {
253
- return new Promise((resolve, reject) => {
254
- var data = {
255
- InspectionIds: inspectionIds
256
- };
257
- this.cw.runRequest('Ams/Inspection/Reopen', data).then(r => {
258
- resolve(r.Value);
259
- }).catch(e => {
260
- reject(e);
261
- });
262
- });
263
- }
264
-
265
296
  /**
266
297
  * Search for inspections
267
298
  *
299
+ * @category Inspections
268
300
  * @param {Object} searchData - An array of the IDs to retrieve the matched inspections, see instance docs: /{subdirectory}/apidocs/#/service-info/Ams/Inspection
269
301
  * @return {Object} Returns object that represents an array of the matching inspection IDs
270
302
  */
@@ -282,6 +314,7 @@ export class Inspection {
282
314
  /**
283
315
  * Get list of statuses
284
316
  *
317
+ * @category Inspection Options
285
318
  * @return {Object} Returns object that represents an array of all possible statuses for an Inspection
286
319
  */
287
320
  statuses() {
@@ -297,6 +330,7 @@ export class Inspection {
297
330
  /**
298
331
  * Get inspection submit to list
299
332
  *
333
+ * @category Inspection Options
300
334
  * @param {boolean} [includeInactiveEmployees] - whether to include inactive employees in the return. Defaults to false.
301
335
  * @param {boolean} [domainIds] - which domains to include in the return, default to All domains
302
336
  * @return {Object} Returns object that represents a collection of all possible employees for an Inspection's SubmitTo
@@ -322,6 +356,8 @@ export class Inspection {
322
356
  /**
323
357
  * Add an entity to an existing inspection
324
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
325
361
  * @param {Object} entity - Either of two attribute combinations are valid: entityType & entityUid OR Entity as a fully-inflated WorkOrderEntity (WorkOrderEntityBase) object.
326
362
  * @param {number} inspectionId - An Inspection ID to attach the entity/asset to.
327
363
  * @param {boolean} updateXY - Provide a boolean to whether the inspection's X/Y coordinates should be updated. Default is true.
@@ -364,6 +400,7 @@ export class Inspection {
364
400
  /**
365
401
  * Get the answers for inspections
366
402
  *
403
+ * @category Inspections
367
404
  * @param {Array<number>} inspections - An Array of one or more Inspection IDs
368
405
  * @return {Object} Returns Promise that represents a collection of Inspection Answers
369
406
  */
@@ -386,6 +423,7 @@ export class Inspection {
386
423
  /**
387
424
  * Get the audit log for a specific Inspection
388
425
  *
426
+ * @category Inspections
389
427
  * @param {number} inspectionId - An Inspection ID to get the audit log for
390
428
  * @return {Object} Returns Promise that represents a collection of Cityworks Metadata Objects
391
429
  */
@@ -403,6 +441,7 @@ export class Inspection {
403
441
  /**
404
442
  * Create a search definition. Save the definition by setting SaveDefinition = true and supplying a SearchName.
405
443
  *
444
+ * @category Inspections
406
445
  * @param {Object} searchData - Search data variables. See /{subdirectory}/apidocs/#/service-info/Ams/Inspection
407
446
  * @param {number} [searchName] - What to name your search (if it should be saved)
408
447
  * @param {number} [sharedWithin] - What group or domain to share the search to.
@@ -431,6 +470,7 @@ export class Inspection {
431
470
  /**
432
471
  * Get cycle from
433
472
  *
473
+ * @category Inspection Options
434
474
  * @return {Object} Returns Promise that represents ... I have no idea what this endpoint does
435
475
  */
436
476
  getCycleFrom() {
@@ -446,6 +486,7 @@ export class Inspection {
446
486
  /**
447
487
  * Get cycle intervals
448
488
  *
489
+ * @category Inspection Options
449
490
  * @return {Object} Returns Promise that represents a Dictionary of the cycle intervals available
450
491
  */
451
492
  getCycleIntervals() {
@@ -461,6 +502,7 @@ export class Inspection {
461
502
  /**
462
503
  * Get cycle types
463
504
  *
505
+ * @category Inspection Options
464
506
  * @return {Object} Returns Promise that represents a Dictionary of the cycle types available
465
507
  */
466
508
  getCycleTypes() {
@@ -476,6 +518,7 @@ export class Inspection {
476
518
  /**
477
519
  * Get districts
478
520
  *
521
+ * @category Inspection Options
479
522
  * @return {Object} Returns Promise that represents an Array of the districts
480
523
  */
481
524
  getDistricts() {
@@ -489,24 +532,10 @@ export class Inspection {
489
532
  }
490
533
 
491
534
 
492
- /**
493
- * Get cycle types
494
- *
495
- * @return {Object} Returns Promise that represents a Dictionary of the cycle intervals available
496
- */
497
- cycleIntervals() {
498
- return new Promise((resolve, reject) => {
499
- this.cw.runRequest('Ams/Inspection/CycleTypes', {}).then(r => {
500
- resolve(r.Value)
501
- }).catch(e => {
502
- reject(e)
503
- })
504
- })
505
- }
506
-
507
535
  /**
508
536
  * Move inspection by InspectionId. Must provide well known id (WKID) or well known text (WKT)
509
537
  *
538
+ * @category Inspections
510
539
  * @param {number} inspectionId - The ID of the inspection that should be moved
511
540
  * @param {number} x - The X coordinate for the move
512
541
  * @param {number} y - The Y coordinate for the move
@@ -550,6 +579,7 @@ export class Inspection {
550
579
  /**
551
580
  * Get inspection templates
552
581
  *
582
+ * @category Inspection Templates
553
583
  * @param {Array<string>} [entityTypes] - The Entity Type(s) to return potential inspections for
554
584
  * @param {boolean} [canCreate] - If true, only return templates the user can create, ignored if false or null, default is true
555
585
  * @param {Object} [options] - An object which can include: [IncludeInactive]: boolean, MaximumDateModified: Date, MinimumDateModified: Date, TemplateIds: Array<number>
@@ -578,6 +608,7 @@ export class Inspection {
578
608
  /**
579
609
  * Get a list of templates by IDs
580
610
  *
611
+ * @category Inspection Templates
581
612
  * @param {Array<number>} inspectionIds - An array of the IDs to retrieve the matched inspections
582
613
  * @param {Object} [options] - An object which can include: [IncludeInactive]: boolean, MaximumDateModified: Date, MinimumDateModified: Date, TemplateIds: Array<number>
583
614
  * @return {Object} Returns object that represents an object describing the inspection
@@ -603,6 +634,7 @@ export class Inspection {
603
634
  /**
604
635
  * Get entity types for inspection template(s)
605
636
  *
637
+ * @category Inspection Templates
606
638
  * @param {Array<number>} inspTemplateIds - An array of the IDs to reopen the matched inspections
607
639
  * @return {Object} Returns object that represents an array of Entity Types
608
640
  */
@@ -622,6 +654,7 @@ export class Inspection {
622
654
  /**
623
655
  * Get the questions and answers for inspection template(s)
624
656
  *
657
+ * @category Inspection Templates
625
658
  * @param {Array<number>} inspTemplateIds - An array of the IDs to reopen the matched inspections
626
659
  * @return {Object} Returns object that represents an array which contains a list of InspQuestionPanel for the template
627
660
  */
@@ -641,6 +674,7 @@ export class Inspection {
641
674
  /**
642
675
  * Get inspection template question conditions
643
676
  *
677
+ * @category Inspection Templates
644
678
  * @param {Array<number>} inspTemplateIds - An array of template IDs to get the matched inspection template Question conditions for
645
679
  * @return {Object} Returns object that represents an array which contains a dictionary of InspQuestion IDs to configs
646
680
  */
@@ -677,6 +711,7 @@ export class Inspection {
677
711
  /**
678
712
  * Delete inspection attachments
679
713
  *
714
+ * @category Inspection Attachments
680
715
  * @param {Array<number>} attachmentIds - An array of inspection attachment IDs to delete
681
716
  * @return {Object} Returns object that represents a boolean for action resolution
682
717
  */
@@ -696,6 +731,7 @@ export class Inspection {
696
731
  /**
697
732
  * Download an inspection attachment
698
733
  *
734
+ * @category Inspection Attachments
699
735
  * @param {number} attachmentId - ID of an inspection attachment to download
700
736
  * @return {Object} Returns object that represents a file stream
701
737
  */
@@ -715,6 +751,7 @@ export class Inspection {
715
751
  /**
716
752
  * Get inspection attachment by ID
717
753
  *
754
+ * @category Inspection Attachments
718
755
  * @param {number} attachmentId - An attachment ID to get info for
719
756
  * @return {Object} Returns object that represents an object that describes the matched inspection attachment
720
757
  */
@@ -734,6 +771,7 @@ export class Inspection {
734
771
  /**
735
772
  * Get inspection attachment by ID
736
773
  *
774
+ * @category Inspection Attachments
737
775
  * @param {Array<number>} inspectionIds - An array of inspection IDs to get attachments for
738
776
  * @return {Object} Returns object that represents a collection of attachments from the matched inspections
739
777
  */
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 {object} cw - Feed in the cityworks object instance so that this instance has access to the runRequest from the recursively-linked Cityworks instance
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
  }