cityworks 0.0.30 → 0.0.35
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/LICENSE +1 -1
- package/README.md +24 -24
- package/dist/activity_link.d.ts +6 -3
- package/dist/case.d.ts +4 -0
- package/dist/case_assets.d.ts +88 -0
- package/dist/case_data.d.ts +1 -1
- package/dist/case_workflow.d.ts +28 -0
- package/dist/cityworks.d.ts +238 -0
- package/dist/comments.d.ts +2 -2
- package/dist/error.d.ts +7 -4
- package/dist/general.d.ts +2 -2
- package/dist/gis.d.ts +17 -4
- 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.js +1 -1
- package/dist/index.modern.js.map +1 -1
- package/dist/index.modern.mjs +2 -0
- package/dist/index.modern.mjs.map +1 -0
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/inspection.d.ts +2 -2
- package/dist/inspection_admin.d.ts +15 -0
- package/dist/request.d.ts +10 -2
- package/dist/request_admin.d.ts +8 -0
- package/dist/workorder.d.ts +7 -7
- package/dist/workorder_admin.d.ts +101 -0
- package/package.json +13 -12
- package/src/activity_link.ts +17 -3
- package/src/case.ts +44 -0
- package/src/case_assets.ts +129 -0
- package/src/case_data.ts +54 -3
- package/src/case_workflow.ts +72 -0
- package/src/cityworks.ts +43 -19
- package/src/comments.ts +13 -5
- package/src/costs.ts +289 -0
- package/src/error.ts +11 -3
- package/src/event_layer.ts +219 -28
- package/src/general.ts +5 -3
- package/src/gis.ts +92 -57
- package/src/inspection.ts +2 -2
- package/src/inspection_admin.ts +28 -0
- package/src/message_queue.ts +10 -0
- package/src/request.ts +22 -2
- package/src/request_admin.ts +18 -0
- package/src/workorder.ts +9 -9
- package/src/workorder_admin.ts +231 -0
- package/test/01.cityworksTest.js +12 -12
- package/test/08.workOrderTest.js +1 -1
- package/test/09.caseAssetsTest.js +72 -0
package/src/case_workflow.ts
CHANGED
|
@@ -387,4 +387,76 @@ export class CaseWorkflow {
|
|
|
387
387
|
})
|
|
388
388
|
})
|
|
389
389
|
}
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* Adds a task to the case specified by the CaObectId.
|
|
393
|
+
*
|
|
394
|
+
* @category Task Attachments
|
|
395
|
+
* @param {number} caTaskId - The Task ID to attach the document to
|
|
396
|
+
* @param {number} caObjectId - The Case Object ID
|
|
397
|
+
* @param {string} docName - The file name as it should display in the system
|
|
398
|
+
* @param {string} locationType - The location of the file...leave blank
|
|
399
|
+
* @param {any} file - The binary string for the file
|
|
400
|
+
* @return {Object} Returns Promise that represents an object describing added Attachment
|
|
401
|
+
*/
|
|
402
|
+
addTaskAttachment(caTaskId: number, caObjectId: number, docName: number, file: any, locationType?: string) {
|
|
403
|
+
return new Promise((resolve, reject) => {
|
|
404
|
+
var data = {
|
|
405
|
+
CaObjectId: caObjectId,
|
|
406
|
+
CaTaskId: caTaskId,
|
|
407
|
+
DocName: docName
|
|
408
|
+
}
|
|
409
|
+
if(typeof(locationType)!='undefined') {
|
|
410
|
+
_.set(data, 'LocationType', locationType)
|
|
411
|
+
}
|
|
412
|
+
this.cw.runRequest('Pll/CaseRelDocs/AddTaskRelDoc', data, file).then(r => {
|
|
413
|
+
resolve(r.Value)
|
|
414
|
+
}).catch(e => {
|
|
415
|
+
reject(e)
|
|
416
|
+
})
|
|
417
|
+
})
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* Gets each Document Attached to the specified Task
|
|
422
|
+
*
|
|
423
|
+
* @category Task Attachments
|
|
424
|
+
* @param {number} caTaskId - The Task ID to attach the document to
|
|
425
|
+
* @return {Object} Returns Promise that represents a collection of objects describing each Attachment on the provided task
|
|
426
|
+
*/
|
|
427
|
+
getTaskAttachments(caTaskId: number) {
|
|
428
|
+
return new Promise((resolve, reject) => {
|
|
429
|
+
var data = {
|
|
430
|
+
CaTaskId: caTaskId
|
|
431
|
+
}
|
|
432
|
+
this.cw.runRequest('Pll/CaseRelDocs/ByCaTaskId', data).then(r => {
|
|
433
|
+
resolve(r.Value)
|
|
434
|
+
}).catch(e => {
|
|
435
|
+
reject(e)
|
|
436
|
+
})
|
|
437
|
+
})
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* Deletes a task attachment by caRelDocId (Related Case Document ID). Same as RelDocs delete for case.
|
|
442
|
+
*
|
|
443
|
+
* @category Task Attachments
|
|
444
|
+
* @param {number} caRelDocId - The caRelDocId for the related document which should be deleted
|
|
445
|
+
* @return {Object} Returns Promise that represents the an object describing the deleted document.
|
|
446
|
+
*/
|
|
447
|
+
deleteTaskAttachment(caRelDocId: number) {
|
|
448
|
+
return new Promise((resolve, reject) => {
|
|
449
|
+
var data = {
|
|
450
|
+
CaRelDocId: caRelDocId
|
|
451
|
+
}
|
|
452
|
+
this.cw.runRequest('PLL/CaseRelDocs/Delete', data).then(r => {
|
|
453
|
+
resolve(r.Value)
|
|
454
|
+
}).catch(e => {
|
|
455
|
+
reject(e)
|
|
456
|
+
})
|
|
457
|
+
})
|
|
458
|
+
}
|
|
390
459
|
}
|
|
460
|
+
|
|
461
|
+
|
|
462
|
+
|
package/src/cityworks.ts
CHANGED
|
@@ -17,6 +17,7 @@ const _ = require('lodash')
|
|
|
17
17
|
interface postData {
|
|
18
18
|
data?: string
|
|
19
19
|
token?: string
|
|
20
|
+
file?: any
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
/**
|
|
@@ -51,7 +52,7 @@ interface Citywork {
|
|
|
51
52
|
/**
|
|
52
53
|
* Core class Cityworks with most of the authentication and install capabilities functions
|
|
53
54
|
*/
|
|
54
|
-
|
|
55
|
+
export class Cityworks implements Citywork {
|
|
55
56
|
/**
|
|
56
57
|
* The domain of the cityworks install. Defaults to Cityworks Online
|
|
57
58
|
*/
|
|
@@ -200,20 +201,30 @@ module.exports = class Cityworks implements Citywork {
|
|
|
200
201
|
*
|
|
201
202
|
* @param {string} path - The path to the particular endpoint
|
|
202
203
|
* @param {Object} data - The data object to be sent to the Cityworks API
|
|
204
|
+
* @param {any} file - The file to send in binary to the Cityworks API
|
|
203
205
|
* @return {Object} Returns Promise object that represents the json object returned from the Cityworks API
|
|
204
206
|
*/
|
|
205
|
-
runRequest(path, data) {
|
|
207
|
+
runRequest(path, data?, file?: any) {
|
|
206
208
|
return new Promise((resolve, reject) => {
|
|
207
209
|
let pd = {} as postData
|
|
208
|
-
|
|
210
|
+
|
|
211
|
+
if(typeof(data) !== 'undefined') {
|
|
212
|
+
pd.data = JSON.stringify(data)
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if(typeof(file) !== 'undefined' && (path=='Pll/CaseRelDocs/AddTaskRelDoc' || path=='Pll/CaseRelDocs/Add')) {
|
|
216
|
+
pd.file = file
|
|
217
|
+
}
|
|
209
218
|
|
|
210
219
|
if(typeof(this.Token) !== 'undefined' && this.Token != '' && path!='General/Authentication/CityworksOnlineAuthenticate' && path!='General/Authentication/Authenticate') {
|
|
211
220
|
pd.token = this.Token
|
|
212
221
|
}
|
|
222
|
+
|
|
213
223
|
let obj: {
|
|
214
224
|
Status: number,
|
|
215
225
|
Message: string
|
|
216
226
|
}
|
|
227
|
+
|
|
217
228
|
let options = {
|
|
218
229
|
hostname: this.base_url,
|
|
219
230
|
port: 443,
|
|
@@ -225,7 +236,6 @@ module.exports = class Cityworks implements Citywork {
|
|
|
225
236
|
},
|
|
226
237
|
timeout: 10000000
|
|
227
238
|
}
|
|
228
|
-
|
|
229
239
|
let request = https.request(options, (response) => {
|
|
230
240
|
let str=''
|
|
231
241
|
response.on('error',function(e){
|
|
@@ -249,20 +259,34 @@ module.exports = class Cityworks implements Citywork {
|
|
|
249
259
|
// failed
|
|
250
260
|
reject(new CWError(10, 'No response received from Cityworks API.'))
|
|
251
261
|
} else if(typeof(obj)!='undefined' && typeof(obj.Value)!='undefined') { // && typeof(response.Value.Token)!='undefined') {
|
|
252
|
-
|
|
262
|
+
switch(obj.Status) {
|
|
263
|
+
case 1:
|
|
264
|
+
reject(new CWError(1, 'Error', obj))
|
|
265
|
+
break;
|
|
266
|
+
case 2:
|
|
267
|
+
reject(new CWError(2, 'Unauthorized', obj))
|
|
268
|
+
break;
|
|
269
|
+
case 3:
|
|
270
|
+
reject(new CWError(3, 'InvalidCredentials', obj))
|
|
271
|
+
break;
|
|
272
|
+
case 0:
|
|
273
|
+
default:
|
|
274
|
+
resolve(obj);
|
|
275
|
+
break;
|
|
276
|
+
}
|
|
253
277
|
} else {
|
|
254
|
-
reject(new CWError(
|
|
278
|
+
reject(new CWError(4, "Unknown error.", {options: options, postedData: pd, api_returned_string: obj}))
|
|
255
279
|
}
|
|
256
280
|
} else {
|
|
257
|
-
reject(new CWError(
|
|
281
|
+
reject(new CWError(5, "Error parsing JSON. Cityworks returned HTML.", {response: str}))
|
|
258
282
|
}
|
|
259
283
|
} catch (e) {
|
|
260
284
|
if (e instanceof SyntaxError) {
|
|
261
285
|
console.log('try/catch error on JSON')
|
|
262
|
-
reject(new CWError(
|
|
286
|
+
reject(new CWError(6, "Error parsing JSON.", {error: e}))
|
|
263
287
|
} else {
|
|
264
|
-
console.log('try/catch error on JSON')
|
|
265
|
-
reject(new CWError(
|
|
288
|
+
console.log('try/catch error on JSON - but not an instance of SyntaxError')
|
|
289
|
+
reject(new CWError(7, "Error parsing JSON."))
|
|
266
290
|
}
|
|
267
291
|
}
|
|
268
292
|
})
|
|
@@ -286,20 +310,20 @@ module.exports = class Cityworks implements Citywork {
|
|
|
286
310
|
path = 'General/Authentication/CityworksOnlineAuthenticate'
|
|
287
311
|
}
|
|
288
312
|
this.runRequest(path, data).then((response: any) => {
|
|
289
|
-
if(response.Status>0) {
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
} else if(typeof(response.Value)!='undefined' && typeof(response.Value.Token)!='undefined') {
|
|
313
|
+
// if(response.Status>0) {
|
|
314
|
+
// // failed
|
|
315
|
+
// reject(new CWError(100, response.Message))
|
|
316
|
+
// } else if(typeof(response.Value)!='undefined' && typeof(response.Value.Token)!='undefined') {
|
|
293
317
|
this.login = login
|
|
294
318
|
this.password = password
|
|
295
319
|
this.Token = response.Value.Token
|
|
296
320
|
resolve(true)
|
|
297
|
-
} else {
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
}
|
|
321
|
+
// } else {
|
|
322
|
+
// // failed
|
|
323
|
+
// reject(new CWError(11, 'Unknown Error'))
|
|
324
|
+
// }
|
|
301
325
|
}).catch(error => {
|
|
302
|
-
reject(error)
|
|
326
|
+
reject(error);
|
|
303
327
|
})
|
|
304
328
|
})
|
|
305
329
|
}
|
package/src/comments.ts
CHANGED
|
@@ -25,7 +25,7 @@ export class Comments {
|
|
|
25
25
|
/**
|
|
26
26
|
* @hidden
|
|
27
27
|
*/
|
|
28
|
-
constructor(cw, activityType) {
|
|
28
|
+
constructor(cw: any, activityType: string) {
|
|
29
29
|
this.cw = cw
|
|
30
30
|
this.activityTypes = new ReversibleMap<string, number>()
|
|
31
31
|
this.activityTypes.set("Unknown", 0)
|
|
@@ -38,14 +38,14 @@ export class Comments {
|
|
|
38
38
|
this.activityTypes.set("Contract", 7)
|
|
39
39
|
|
|
40
40
|
if(!this.activityTypes.has(activityType)) {
|
|
41
|
-
throw new CWError(1, '
|
|
41
|
+
throw new CWError(1, 'Comment activity type not found.', {'provided': activityType, 'options':this.activityTypes})
|
|
42
42
|
}
|
|
43
43
|
this.currentActivityType = activityType
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
|
-
* Add a comment
|
|
48
|
-
*
|
|
47
|
+
* Add a comment - for adding a comment to an object when the object is already known. Always call comment.add from request, case, workorder, or inspection.
|
|
48
|
+
*
|
|
49
49
|
* @param {number} sid - The SID of the activity to which the comment should be attached
|
|
50
50
|
* @param {string} comment - The text for the comment
|
|
51
51
|
* @return {Object} Returns a Promise which represents a CommentRecord object
|
|
@@ -59,6 +59,8 @@ export class Comments {
|
|
|
59
59
|
}
|
|
60
60
|
this.cw.runRequest('Ams/Comment/Add', data).then((response: any) => {
|
|
61
61
|
resolve(response.Value)
|
|
62
|
+
}).catch(e => {
|
|
63
|
+
reject(e)
|
|
62
64
|
})
|
|
63
65
|
})
|
|
64
66
|
}
|
|
@@ -79,6 +81,8 @@ export class Comments {
|
|
|
79
81
|
}
|
|
80
82
|
this.cw.runRequest('Ams/Comment/Update', data).then((response: any) => {
|
|
81
83
|
resolve(response.Value)
|
|
84
|
+
}).catch(e => {
|
|
85
|
+
reject(e)
|
|
82
86
|
})
|
|
83
87
|
})
|
|
84
88
|
}
|
|
@@ -126,6 +130,8 @@ export class Comments {
|
|
|
126
130
|
_.set(data, 'ActivityType', this.activityTypes.get(this.currentActivityType))
|
|
127
131
|
this.cw.runRequest('Ams/Comment/PredefinedComments', data).then((response: any) => {
|
|
128
132
|
resolve(response.Value)
|
|
133
|
+
}).catch(e => {
|
|
134
|
+
reject(e)
|
|
129
135
|
})
|
|
130
136
|
})
|
|
131
137
|
}
|
|
@@ -152,7 +158,9 @@ export class Comments {
|
|
|
152
158
|
// console.log(data, 'data')
|
|
153
159
|
// this.cw.runRequest('Ams/Comment/ByActivityTypes', data).then((response: any) => {
|
|
154
160
|
// resolve(response.Value)
|
|
155
|
-
// })
|
|
161
|
+
// }).catch(e => {
|
|
162
|
+
// reject(e)
|
|
163
|
+
// })
|
|
156
164
|
// })
|
|
157
165
|
// }
|
|
158
166
|
|
package/src/costs.ts
ADDED
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import { CWError } from './error'
|
|
2
|
+
import ReversibleMap from 'reversible-map'
|
|
3
|
+
const _ = require('lodash')
|
|
4
|
+
|
|
5
|
+
export class Costs {
|
|
6
|
+
/**
|
|
7
|
+
* @hidden
|
|
8
|
+
*/
|
|
9
|
+
cw: any
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Storage of all potential activity types which comments can be attached to: Unknown, Request, WorkOrder, CaTask, CaObject, CaCorrection, Project, Contract
|
|
13
|
+
*/
|
|
14
|
+
activityTypes: ReversibleMap<string, number>
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Storage of object's active activityType
|
|
18
|
+
*/
|
|
19
|
+
currentActivityType: string
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @hidden
|
|
23
|
+
*/
|
|
24
|
+
constructor(cw:any, activityType:string) {
|
|
25
|
+
this.cw = cw
|
|
26
|
+
this.activityTypes = new ReversibleMap<string, number>()
|
|
27
|
+
this.activityTypes.set("Request", 1)
|
|
28
|
+
this.activityTypes.set("WorkOrder", 2)
|
|
29
|
+
this.activityTypes.set("Inspection", 3)
|
|
30
|
+
|
|
31
|
+
if(!this.activityTypes.has(activityType)) {
|
|
32
|
+
throw new CWError(1, 'Cost activity type not found.', {'provided': activityType, 'options':this.activityTypes})
|
|
33
|
+
}
|
|
34
|
+
this.currentActivityType = activityType
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Get Cost Codes
|
|
39
|
+
*
|
|
40
|
+
* @category Labor Costs
|
|
41
|
+
* @param {Array<number>} employeeSids - A list of Employee IDs for which to get the job codes.
|
|
42
|
+
* @param {boolean} commonOnly - Set to true to get the Cost Codes that are common to ALL employees in the list, otherwise get all job codes that apply to at least one employee in the list.
|
|
43
|
+
* @return {Object} Returns Promise that represents an object describing
|
|
44
|
+
*/
|
|
45
|
+
getCodes(employeeSids: Object, commonOnly: boolean = false) {
|
|
46
|
+
return new Promise((resolve, reject) => {
|
|
47
|
+
var data = {
|
|
48
|
+
EmployeeSids: employeeSids,
|
|
49
|
+
CommonCodesOnly: commonOnly
|
|
50
|
+
}
|
|
51
|
+
this.cw.runRequest('Ams/LaborCost/CostCodes', data).then(r => {
|
|
52
|
+
resolve(r.Value)
|
|
53
|
+
}).catch(e => {
|
|
54
|
+
reject(e)
|
|
55
|
+
})
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Get Job Codes
|
|
61
|
+
*
|
|
62
|
+
* @category Labor Costs
|
|
63
|
+
* @return {Object} Returns Promise that represents an object describing
|
|
64
|
+
*/
|
|
65
|
+
getJobCodes() {
|
|
66
|
+
return new Promise((resolve, reject) => {
|
|
67
|
+
this.cw.runRequest('Ams/LaborCost/JobCodes').then(r => {
|
|
68
|
+
resolve(r.Value)
|
|
69
|
+
}).catch(e => {
|
|
70
|
+
reject(e)
|
|
71
|
+
})
|
|
72
|
+
})
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Add Inspection Labor Costs
|
|
77
|
+
*
|
|
78
|
+
* @category Inspection Costs
|
|
79
|
+
* @param {number} inspectionId - Inspection ID to add labor costs to
|
|
80
|
+
* @param {number} hours - The hours to add to the inspection
|
|
81
|
+
* @param {Object} options - Additional settings for hours setting
|
|
82
|
+
* @param {boolean} estimated - Boolean, get estimated or real costs, defaults to false (get real by default)
|
|
83
|
+
* @return {Object} Returns Promise that represents an object describing
|
|
84
|
+
*/
|
|
85
|
+
addInspectionLabor(inspectionId: number, hours: number, options: object, estimated: boolean = false) {
|
|
86
|
+
return new Promise((resolve, reject) => {
|
|
87
|
+
var data = {
|
|
88
|
+
Estimated: estimated,
|
|
89
|
+
InspectionIds: inspectionId,
|
|
90
|
+
Hours: hours
|
|
91
|
+
}
|
|
92
|
+
this.cw.runRequest('Ams/LaborCost/AddInspectionCosts', data).then((response: any) => {
|
|
93
|
+
resolve(response.Value)
|
|
94
|
+
}).catch(e => {
|
|
95
|
+
reject(e)
|
|
96
|
+
})
|
|
97
|
+
})
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Get Labor Costs for a specific list of Inspections
|
|
102
|
+
*
|
|
103
|
+
* @category Inspection Costs
|
|
104
|
+
* @param {Array<int>} inspectionIds - An array of inspection IDs to get associated costs for.
|
|
105
|
+
* @param {boolean} estimated - Boolean, get estimated or real costs, defaults to false (get real by default)
|
|
106
|
+
* @return {Object} Returns Promise that represents an object describing
|
|
107
|
+
*/
|
|
108
|
+
getInspectionLabor(inspectionIds: Array<number>, estimated: boolean = false) {
|
|
109
|
+
return new Promise((resolve, reject) => {
|
|
110
|
+
var data = {
|
|
111
|
+
Estimated: estimated,
|
|
112
|
+
InspectionIds: inspectionIds
|
|
113
|
+
}
|
|
114
|
+
this.cw.runRequest('Ams/LaborCost/InspectionCostsByInspection', data).then((response: any) => {
|
|
115
|
+
resolve(response.Value)
|
|
116
|
+
}).catch(e => {
|
|
117
|
+
reject(e)
|
|
118
|
+
})
|
|
119
|
+
})
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Delete Inspection Labor Costs
|
|
124
|
+
*
|
|
125
|
+
* @category Inspection Costs
|
|
126
|
+
* @param {Array<int>} laborCostIds - An array of inspection labor cost IDs to delete
|
|
127
|
+
* @param {boolean} estimated - Boolean, delete estimated or real costs, defaults to false (delete real by default)
|
|
128
|
+
* @return {Object} Returns Promise that represents an object describing
|
|
129
|
+
*/
|
|
130
|
+
deleteInspectionLabor(laborCostIds: Array<number>, estimated: boolean = false) {
|
|
131
|
+
return new Promise((resolve, reject) => {
|
|
132
|
+
var data = {
|
|
133
|
+
Estimated: estimated,
|
|
134
|
+
reqLaborCostIds: laborCostIds
|
|
135
|
+
}
|
|
136
|
+
this.cw.runRequest('Ams/LaborCost/DeleteInspectionCosts', data).then((response: any) => {
|
|
137
|
+
resolve(response.Value)
|
|
138
|
+
}).catch(e => {
|
|
139
|
+
reject(e)
|
|
140
|
+
})
|
|
141
|
+
})
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Add Request Labor Costs
|
|
146
|
+
*
|
|
147
|
+
* @category Request Costs
|
|
148
|
+
* @param {Object} requestCosts - Array of inspection labor costings
|
|
149
|
+
* @return {Object} Returns Promise that represents an object describing
|
|
150
|
+
*/
|
|
151
|
+
addRequestLabor(requestCosts: Array<Object>) {
|
|
152
|
+
return new Promise((resolve, reject) => {
|
|
153
|
+
var data = requestCosts
|
|
154
|
+
// ensure each object has Hours & InspectionId
|
|
155
|
+
this.cw.runRequest('Ams/LaborCost/AddRequestCosts', data).then((response: any) => {
|
|
156
|
+
resolve(response.Value)
|
|
157
|
+
}).catch(e => {
|
|
158
|
+
reject(e)
|
|
159
|
+
})
|
|
160
|
+
})
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Get Labor Costs for Request(s)
|
|
165
|
+
*
|
|
166
|
+
* @category Request Costs
|
|
167
|
+
* @param {Object}
|
|
168
|
+
* @return {Object} Returns Promise that represents an object describing
|
|
169
|
+
*/
|
|
170
|
+
// RequestCostsByRequestList<RequestLaborCost>
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Delete Request Labor Costs
|
|
174
|
+
*
|
|
175
|
+
* @category InspeRequestction Costs
|
|
176
|
+
* @param {Object}
|
|
177
|
+
* @return {Object} Returns Promise that represents an object describing
|
|
178
|
+
*/
|
|
179
|
+
// DeleteRequestCostsDictionary<Int32, Boolean>
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Add WorkOrder Labor Costs
|
|
183
|
+
*
|
|
184
|
+
* @category WorkOrder Costs
|
|
185
|
+
* @param {Object}
|
|
186
|
+
* @return {Object} Returns Promise that represents an object describing
|
|
187
|
+
*/
|
|
188
|
+
// AddWorkOrderCostsList<WorkOrderLaborCost>
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Get Labor Costs for WorkOrder(s)
|
|
192
|
+
*
|
|
193
|
+
* @category WorkOrder Costs
|
|
194
|
+
* @param {Object}
|
|
195
|
+
* @return {Object} Returns Promise that represents an object describing
|
|
196
|
+
*/
|
|
197
|
+
// WorkOrderCostsByWorkOrderList<WorkOrderLaborCost>
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Delete WorkOrder Labor Costs
|
|
201
|
+
*
|
|
202
|
+
* @category WorkOrder Costs
|
|
203
|
+
* @param {Object}
|
|
204
|
+
* @return {Object} Returns Promise that represents an object describing
|
|
205
|
+
*/
|
|
206
|
+
// DeleteWorkOrderCostsDictionary<Int32, Boolean>
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Add Inspection Equipment Costs
|
|
210
|
+
*
|
|
211
|
+
* @category Inspection Costs
|
|
212
|
+
* @param {Object}
|
|
213
|
+
* @return {Object} Returns Promise that represents an object describing
|
|
214
|
+
*/
|
|
215
|
+
// AddInspectionCostsList<InspectionEquipmentCost>
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Get Equipment Costs for Inspection(s)
|
|
219
|
+
*
|
|
220
|
+
* @category Inspection Costs
|
|
221
|
+
* @param {Object}
|
|
222
|
+
* @return {Object} Returns Promise that represents an object describing
|
|
223
|
+
*/
|
|
224
|
+
// InspectionCostsByInspectionList<InspectionEquipmentCost>
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Delete Inspection Equipment Costs
|
|
228
|
+
*
|
|
229
|
+
* @category Inspection Costs
|
|
230
|
+
* @param {Object}
|
|
231
|
+
* @return {Object} Returns Promise that represents an object describing
|
|
232
|
+
*/
|
|
233
|
+
// DeleteInspectionCostsDictionary<Int32, Boolean>
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Add WorkOrder Equipment Costs
|
|
237
|
+
*
|
|
238
|
+
* @category WorkOrder Costs
|
|
239
|
+
* @param {Object}
|
|
240
|
+
* @return {Object} Returns Promise that represents an object describing
|
|
241
|
+
*/
|
|
242
|
+
// AddWorkOrderCostsList<EquipmentCost>
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Get Equipment Costs for WorkOrder(s)
|
|
246
|
+
*
|
|
247
|
+
* @category WorkOrder Costs
|
|
248
|
+
* @param {Object}
|
|
249
|
+
* @return {Object} Returns Promise that represents an object describing
|
|
250
|
+
*/
|
|
251
|
+
// WorkOrderCostsByWorkOrderList<EquipmentCost>
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Delete WorkOrder Equipment Costs
|
|
255
|
+
*
|
|
256
|
+
* @category WorkOrder Costs
|
|
257
|
+
* @param {Object}
|
|
258
|
+
* @return {Object} Returns Promise that represents an object describing
|
|
259
|
+
*/
|
|
260
|
+
// DeleteWorkOrderCostsDictionary<Int32, Boolean>
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Add WorkOrder Material Costs
|
|
264
|
+
*
|
|
265
|
+
* @category WorkOrder Costs
|
|
266
|
+
* @param {Object}
|
|
267
|
+
* @return {Object} Returns Promise that represents an object describing
|
|
268
|
+
*/
|
|
269
|
+
// AddWorkOrderCostsList<MaterialCost>
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Get Material Costs for WorkOrder(s)
|
|
273
|
+
*
|
|
274
|
+
* @category WorkOrder Costs
|
|
275
|
+
* @param {Object}
|
|
276
|
+
* @return {Object} Returns Promise that represents an object describing
|
|
277
|
+
*/
|
|
278
|
+
// WorkOrderCostsByWorkOrderList<MaterialCost>
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Delete WorkOrder Material Costs
|
|
282
|
+
*
|
|
283
|
+
* @category WorkOrder Costs
|
|
284
|
+
* @param {Object}
|
|
285
|
+
* @return {Object} Returns Promise that represents an object describing
|
|
286
|
+
*/
|
|
287
|
+
// DeleteWorkOrderCostsDictionary<Int32, Boolean>
|
|
288
|
+
|
|
289
|
+
}
|
package/src/error.ts
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
const _ = require('lodash')
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* CWErrorInt interface definition for implementation by CWError
|
|
5
|
+
*
|
|
6
|
+
* `{name: string, code: number, message: string, info?: string}`
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
export interface CWErrorInt {
|
|
2
10
|
name: string
|
|
3
11
|
code: number
|
|
4
12
|
message: string
|
|
@@ -8,8 +16,6 @@ interface CWErrorInt {
|
|
|
8
16
|
/**
|
|
9
17
|
* CWError implements a custom error class for this codebase with additional information
|
|
10
18
|
*
|
|
11
|
-
* `{name: string, code:number, info: object}`
|
|
12
|
-
*
|
|
13
19
|
*/
|
|
14
20
|
export class CWError implements CWErrorInt {
|
|
15
21
|
/**
|
|
@@ -42,6 +48,8 @@ export class CWError implements CWErrorInt {
|
|
|
42
48
|
this.code = code
|
|
43
49
|
this.message = message
|
|
44
50
|
if(typeof(info) !== 'undefined') {
|
|
51
|
+
if(_.has(info, 'Message'))
|
|
52
|
+
this.message = _.get(info, 'Message')
|
|
45
53
|
this.info = JSON.stringify(info)
|
|
46
54
|
}
|
|
47
55
|
}
|