cityworks 0.0.26 → 0.0.30
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 +22 -0
- package/dist/case.d.ts +4 -0
- package/dist/case_workflow.d.ts +4 -0
- package/dist/comments.d.ts +53 -0
- 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.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/request.d.ts +4 -9
- package/dist/search.d.ts +7 -7
- package/dist/workorder.d.ts +5 -10
- package/package.json +1 -1
- package/src/case.ts +8 -3
- package/src/case_admin.ts +4 -4
- package/src/case_data.ts +3 -3
- package/src/case_financial.ts +8 -8
- package/src/case_workflow.ts +11 -2
- package/src/cityworks.ts +3 -3
- package/src/comments.ts +159 -0
- package/src/message_queue.ts +12 -14
- package/src/request.ts +7 -22
- package/src/search.ts +16 -14
- package/src/workorder.ts +106 -129
- package/test/03.generalTest.js +87 -0
- package/test/04.requestTest.js +68 -1
- package/test/05.caseTest.js +86 -5
- package/test/06.caseFinancialTest.js +95 -6
- package/test/07.searchTest.js +191 -0
- package/test/08.workOrderTest.js +48 -0
- package/test/09.inspectionTest.js +28 -0
- package/test/03.general.js +0 -87
package/dist/request.d.ts
CHANGED
|
@@ -7,6 +7,10 @@ export declare class Request {
|
|
|
7
7
|
* Request Administration methods
|
|
8
8
|
*/
|
|
9
9
|
admin?: Object;
|
|
10
|
+
/**
|
|
11
|
+
* WorkOrder Comments methods
|
|
12
|
+
*/
|
|
13
|
+
comment: Object;
|
|
10
14
|
/**
|
|
11
15
|
* @hidden
|
|
12
16
|
*/
|
|
@@ -93,15 +97,6 @@ export declare class Request {
|
|
|
93
97
|
* @return {Object} Returns Promise that represents a collection of requests
|
|
94
98
|
*/
|
|
95
99
|
changeCustomFieldCategory(requestIds: Array<number>, categoryId: number): Promise<unknown>;
|
|
96
|
-
/**
|
|
97
|
-
* Add a comment to a request
|
|
98
|
-
*
|
|
99
|
-
* @category Requests
|
|
100
|
-
* @param {number} requestId - The ID of the request to retrieve
|
|
101
|
-
* @param {string} comment - The comment text to add
|
|
102
|
-
* @return {Object} Returns Promise that represents an object describing the comment added
|
|
103
|
-
*/
|
|
104
|
-
comment(requestId: number, comment: string): Promise<unknown>;
|
|
105
100
|
/**
|
|
106
101
|
* Cancel requests
|
|
107
102
|
*
|
package/dist/search.d.ts
CHANGED
|
@@ -90,22 +90,22 @@ export declare class Search {
|
|
|
90
90
|
*/
|
|
91
91
|
getDefinition(searchId: number, employeeSid?: number): Promise<unknown>;
|
|
92
92
|
/**
|
|
93
|
-
* Get search
|
|
93
|
+
* Get search definitions
|
|
94
94
|
*
|
|
95
95
|
* @category Search Definitions
|
|
96
96
|
* @param {Array<number>} searchIds - SearchIds to get.
|
|
97
|
-
* @
|
|
97
|
+
* @param {number} employeeSid - Enforces employee security settings on search definition if provided.
|
|
98
|
+
* @return {Object} Returns Promise object that represents a collection of SearchDefinition objects
|
|
98
99
|
*/
|
|
99
|
-
|
|
100
|
+
getDefinitions(searchIds: Array<number>, employeeSid?: number): Promise<unknown>;
|
|
100
101
|
/**
|
|
101
|
-
* Get search
|
|
102
|
+
* Get search definition names
|
|
102
103
|
*
|
|
103
104
|
* @category Search Definitions
|
|
104
105
|
* @param {Array<number>} searchIds - SearchIds to get.
|
|
105
|
-
* @
|
|
106
|
-
* @return {Object} Returns Promise object that represents a collection of SearchDefinition objects
|
|
106
|
+
* @return {Object} Returns Promise object that represents a collection of SearchDefinitionNames
|
|
107
107
|
*/
|
|
108
|
-
|
|
108
|
+
getDefinitionNames(searchIds: Array<number>): Promise<unknown>;
|
|
109
109
|
/**
|
|
110
110
|
* Delete search definitions
|
|
111
111
|
*
|
package/dist/workorder.d.ts
CHANGED
|
@@ -6,7 +6,11 @@ export declare class WorkOrder {
|
|
|
6
6
|
/**
|
|
7
7
|
* WorkOrder Administration methods
|
|
8
8
|
*/
|
|
9
|
-
admin
|
|
9
|
+
admin: Object;
|
|
10
|
+
/**
|
|
11
|
+
* WorkOrder Comments methods
|
|
12
|
+
*/
|
|
13
|
+
comment: Object;
|
|
10
14
|
/**
|
|
11
15
|
* @hidden
|
|
12
16
|
*/
|
|
@@ -101,15 +105,6 @@ export declare class WorkOrder {
|
|
|
101
105
|
* @return {Object} Returns Promise that represents a collection of Objects describing the workorders
|
|
102
106
|
*/
|
|
103
107
|
getCustomFieldValues(workOrderSIds: Array<string | number>): Promise<unknown>;
|
|
104
|
-
/**
|
|
105
|
-
* Add a comment to a workorder
|
|
106
|
-
*
|
|
107
|
-
* @category WorkOrders
|
|
108
|
-
* @param {number} workOrderSId - The S/ID of the workorder to retrieve. SID is default.
|
|
109
|
-
* @param {string} comment - The comment text to add.
|
|
110
|
-
* @return {Object} Returns Promise that represents an object describing the comment added
|
|
111
|
-
*/
|
|
112
|
-
comment(workOrderSId: string | number, comment: string): Promise<unknown>;
|
|
113
108
|
/**
|
|
114
109
|
* Get entities on an existing WorkOrder
|
|
115
110
|
*
|
package/package.json
CHANGED
package/src/case.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { CaseData } from './case_data'
|
|
|
5
5
|
import { CaseFinancial } from './case_financial'
|
|
6
6
|
import { CaseWorkflow} from './case_workflow'
|
|
7
7
|
import { CaseAdmin } from './case_admin'
|
|
8
|
+
import { Comments } from './comments'
|
|
8
9
|
|
|
9
10
|
export class Case {
|
|
10
11
|
/**
|
|
@@ -25,12 +26,15 @@ export class Case {
|
|
|
25
26
|
* Payment, Receipt, & Fee methods
|
|
26
27
|
*/
|
|
27
28
|
financial?: Object
|
|
29
|
+
/**
|
|
30
|
+
* Commenting methods
|
|
31
|
+
*/
|
|
32
|
+
comment?: Object
|
|
28
33
|
/**
|
|
29
34
|
* PLL Administration methods
|
|
30
35
|
*/
|
|
31
36
|
admin?: Object
|
|
32
37
|
|
|
33
|
-
|
|
34
38
|
/**
|
|
35
39
|
* @hidden
|
|
36
40
|
*/
|
|
@@ -39,6 +43,7 @@ export class Case {
|
|
|
39
43
|
this.data = new CaseData(cw)
|
|
40
44
|
this.workflow = new CaseWorkflow(cw)
|
|
41
45
|
this.financial = new CaseFinancial(cw)
|
|
46
|
+
this.comment = new Comments(cw, 'CaObject')
|
|
42
47
|
this.admin = new CaseAdmin(cw)
|
|
43
48
|
}
|
|
44
49
|
|
|
@@ -207,7 +212,7 @@ export class Case {
|
|
|
207
212
|
}).catch(e => {
|
|
208
213
|
reject(e)
|
|
209
214
|
})
|
|
210
|
-
})
|
|
215
|
+
})
|
|
211
216
|
}
|
|
212
217
|
|
|
213
218
|
/**
|
|
@@ -220,7 +225,7 @@ export class Case {
|
|
|
220
225
|
delete(caObjectId: number) {
|
|
221
226
|
return new Promise((resolve, reject) => {
|
|
222
227
|
var data = {
|
|
223
|
-
CaObjectId: caObjectId
|
|
228
|
+
CaObjectId: caObjectId
|
|
224
229
|
}
|
|
225
230
|
this.cw.runRequest('Pll/CaseObject/DeleteCase', data).then(r => {
|
|
226
231
|
resolve(r.Value)
|
package/src/case_admin.ts
CHANGED
|
@@ -142,7 +142,7 @@ export class CaseAdmin {
|
|
|
142
142
|
*/
|
|
143
143
|
searchCaseTypeIDs(filters: Object) {
|
|
144
144
|
return new Promise((resolve, reject) => {
|
|
145
|
-
if(_.intersectionBy(filters, ['CaseType', 'CaseTypeDesc', 'CaseTypeId']).length==0) {
|
|
145
|
+
if(_.intersectionBy(_.keysIn(filters), ['CaseType', 'CaseTypeDesc', 'CaseTypeId']).length==0) {
|
|
146
146
|
reject(new CWError(2, 'At least one of the attributes (CaFeeId, CaObjectId, FeeCode, FeeDesc) must be defined.'))
|
|
147
147
|
}
|
|
148
148
|
var data = filters
|
|
@@ -163,7 +163,7 @@ export class CaseAdmin {
|
|
|
163
163
|
*/
|
|
164
164
|
searchCaseTypeObjects(filters: Object) {
|
|
165
165
|
return new Promise((resolve, reject) => {
|
|
166
|
-
if(_.intersectionBy(filters, ['CaseType', 'CaseTypeDesc', 'CaseTypeId']).length==0) {
|
|
166
|
+
if(_.intersectionBy(_.keysIn(filters), ['CaseType', 'CaseTypeDesc', 'CaseTypeId']).length==0) {
|
|
167
167
|
reject(new CWError(3, 'At least one of the attributes (CaseType, CaseTypeDesc, CaseTypeId) must be defined.'))
|
|
168
168
|
}
|
|
169
169
|
var data = filters
|
|
@@ -263,7 +263,7 @@ export class CaseAdmin {
|
|
|
263
263
|
*/
|
|
264
264
|
searchFees(filters: {AccountCode?: string, FeeCode?: string, FeeDesc?: string, FeeSetupId?: number, FeeTypeId?: number}) {
|
|
265
265
|
return new Promise((resolve, reject) => {
|
|
266
|
-
if(_.intersectionBy(filters, ['AccountCode', 'FeeCode', 'FeeDesc', 'FeeSetupId', 'FeeTypeId']).length==0) {
|
|
266
|
+
if(_.intersectionBy(_.keysIn(filters), ['AccountCode', 'FeeCode', 'FeeDesc', 'FeeSetupId', 'FeeTypeId']).length==0) {
|
|
267
267
|
reject(new CWError(4, 'At least one of the attributes (AccountCode, FeeCode, FeeDesc, FeeSetupId, FeeTypeId) must be defined.'))
|
|
268
268
|
}
|
|
269
269
|
var data = filters
|
|
@@ -338,7 +338,7 @@ export class CaseAdmin {
|
|
|
338
338
|
*/
|
|
339
339
|
searchDeposits(filters: {AccountCode?: string, DepositCode?: string, DepositDesc?: string, DepositId?: number, DepositTypeId?: number}) {
|
|
340
340
|
return new Promise((resolve, reject) => {
|
|
341
|
-
if(_.intersectionBy(filters, ['AccountCode', 'DepositCode', 'DepositDesc', 'DepositId', 'DepositTypeId']).length==0) {
|
|
341
|
+
if(_.intersectionBy(_.keysIn(filters), ['AccountCode', 'DepositCode', 'DepositDesc', 'DepositId', 'DepositTypeId']).length==0) {
|
|
342
342
|
reject(new CWError(4, 'At least one of the attributes (AccountCode, DepositCode, DepositDesc, DepositId, DepositTypeId) must be defined.'))
|
|
343
343
|
}
|
|
344
344
|
var data = filters
|
package/src/case_data.ts
CHANGED
|
@@ -143,7 +143,7 @@ export class CaseData {
|
|
|
143
143
|
*/
|
|
144
144
|
searchForGroups(filters?: Object) {
|
|
145
145
|
return new Promise((resolve, reject) => {
|
|
146
|
-
if(_.intersectionBy(filters, ['CaDataGroupId', 'CaseDataGroupId', 'GroupCode', 'GroupDesc', 'GroupSum', 'SumFlag']).length==0) {
|
|
146
|
+
if(_.intersectionBy(_.keysIn(filters), ['CaDataGroupId', 'CaseDataGroupId', 'GroupCode', 'GroupDesc', 'GroupSum', 'SumFlag']).length==0) {
|
|
147
147
|
reject(new CWError(2, 'At least one of the attributes (CaDataGroupId, CaseDataGroupId, GroupCode, GroupDesc, GroupSum, SumFlag) must be defined.'))
|
|
148
148
|
}
|
|
149
149
|
var data = filters
|
|
@@ -359,7 +359,7 @@ export class CaseData {
|
|
|
359
359
|
*/
|
|
360
360
|
searchForListValueIds(filters?: Object) {
|
|
361
361
|
return new Promise((resolve, reject) => {
|
|
362
|
-
if(_.intersectionBy(filters, ['CaDataDetailId', 'CaDataListId', 'ListValue']).length==0) {
|
|
362
|
+
if(_.intersectionBy(_.keysIn(filters), ['CaDataDetailId', 'CaDataListId', 'ListValue']).length==0) {
|
|
363
363
|
reject(new CWError(3, 'At least one of the attributes (CaDataDetailId, CaDataListId, ListValue) must be defined.'))
|
|
364
364
|
}
|
|
365
365
|
var data = filters
|
|
@@ -380,7 +380,7 @@ export class CaseData {
|
|
|
380
380
|
*/
|
|
381
381
|
searchForListValueObjects(filters?: Object) {
|
|
382
382
|
return new Promise((resolve, reject) => {
|
|
383
|
-
if(_.intersectionBy(filters, ['CaDataDetailId', 'CaDataListId', 'ListValue']).length==0) {
|
|
383
|
+
if(_.intersectionBy(_.keysIn(filters), ['CaDataDetailId', 'CaDataListId', 'ListValue']).length==0) {
|
|
384
384
|
reject(new CWError(3, 'At least one of the attributes (CaDataDetailId, CaDataListId, ListValue) must be defined.'))
|
|
385
385
|
}
|
|
386
386
|
var data = filters
|
package/src/case_financial.ts
CHANGED
|
@@ -521,7 +521,7 @@ export class CaseFinancial {
|
|
|
521
521
|
*/
|
|
522
522
|
searchFees(filters: Object) {
|
|
523
523
|
return new Promise((resolve, reject) => {
|
|
524
|
-
if(_.intersectionBy(filters, ['CaFeeId', 'CaObjectId', 'FeeCode', 'FeeDesc']).length==0) {
|
|
524
|
+
if(_.intersectionBy(_.keysIn(filters), ['CaFeeId', 'CaObjectId', 'FeeCode', 'FeeDesc']).length==0) {
|
|
525
525
|
reject(new CWError(4, 'At least one of the attributes (CaFeeId, CaObjectId, FeeCode, FeeDesc) must be defined.'))
|
|
526
526
|
}
|
|
527
527
|
var data = filters
|
|
@@ -542,7 +542,7 @@ export class CaseFinancial {
|
|
|
542
542
|
*/
|
|
543
543
|
searchPayments(filters: Object) {
|
|
544
544
|
return new Promise((resolve, reject) => {
|
|
545
|
-
if(_.intersectionBy(filters, ['CaPaymentId', 'CommentText', 'FeeAmount', 'FeeCode', 'FeeDesc', 'PaymentAccount', 'PaymentAmount', 'TenderType']).length==0) {
|
|
545
|
+
if(_.intersectionBy(_.keysIn(filters), ['CaPaymentId', 'CommentText', 'FeeAmount', 'FeeCode', 'FeeDesc', 'PaymentAccount', 'PaymentAmount', 'TenderType']).length==0) {
|
|
546
546
|
reject(new CWError(5, 'At least one of the attributes (CaPaymentId, CommentText, FeeAmount, FeeCode, FeeDesc, PaymentAccount, PaymentAmount, TenderType) must be defined.'))
|
|
547
547
|
}
|
|
548
548
|
var data = filters
|
|
@@ -563,7 +563,7 @@ export class CaseFinancial {
|
|
|
563
563
|
*/
|
|
564
564
|
searchRefunds(filters: Object) {
|
|
565
565
|
return new Promise((resolve, reject) => {
|
|
566
|
-
if(_.intersectionBy(filters, ['CaPaymentId', 'CaPaymentRefundId', 'Comments', 'RefundAmount']).length==0) {
|
|
566
|
+
if(_.intersectionBy(_.keysIn(filters), ['CaPaymentId', 'CaPaymentRefundId', 'Comments', 'RefundAmount']).length==0) {
|
|
567
567
|
reject(new CWError(6, 'At least one of the attributes (CaPaymentId, CaPaymentRefundId, Comments, RefundAmount) must be defined.'))
|
|
568
568
|
}
|
|
569
569
|
var data = filters
|
|
@@ -584,7 +584,7 @@ export class CaseFinancial {
|
|
|
584
584
|
*/
|
|
585
585
|
searchDeposits(filters: Object) {
|
|
586
586
|
return new Promise((resolve, reject) => {
|
|
587
|
-
if(_.intersectionBy(filters, ['CaDepositId', 'CaObjectId', 'DepositCode', 'DepositDesc']).length==0) {
|
|
587
|
+
if(_.intersectionBy(_.keysIn(filters), ['CaDepositId', 'CaObjectId', 'DepositCode', 'DepositDesc']).length==0) {
|
|
588
588
|
reject(new CWError(1, 'At least one of the arguments (CaDepositId, CaObjectId, DepositCode, DepositDesc) must be defined.'))
|
|
589
589
|
}
|
|
590
590
|
var data = filters
|
|
@@ -622,7 +622,7 @@ export class CaseFinancial {
|
|
|
622
622
|
*/
|
|
623
623
|
searchFeeTemplates(filters: Object) {
|
|
624
624
|
return new Promise((resolve, reject) => {
|
|
625
|
-
if(_.intersectionBy(filters, ['FeeSetupId', 'FeeTypeId', 'FeeCode', 'FeeDesc', 'AccountCode']).length==0) {
|
|
625
|
+
if(_.intersectionBy(_.keysIn(filters), ['FeeSetupId', 'FeeTypeId', 'FeeCode', 'FeeDesc', 'AccountCode']).length==0) {
|
|
626
626
|
reject(new CWError(7, 'At least one of the arguments (FeeSetupId, FeeTypeId, FeeCode, FeeDesc, AccountCode) must be defined.'))
|
|
627
627
|
}
|
|
628
628
|
var data = filters
|
|
@@ -643,7 +643,7 @@ export class CaseFinancial {
|
|
|
643
643
|
*/
|
|
644
644
|
searchCaseInstruments(filters: Object) {
|
|
645
645
|
return new Promise((resolve, reject) => {
|
|
646
|
-
if(_.intersectionBy(filters, ['AddressLine1', 'Amount', 'CaInstrumentId', 'CityName', 'CommentText', 'Company', 'ContactEmail', 'ContactName', 'ContactPhone', 'CountryCode', 'InstTypeId', 'SerialNumber', 'StateCode', 'ZipCode']).length==0) {
|
|
646
|
+
if(_.intersectionBy(_.keysIn(filters), ['AddressLine1', 'Amount', 'CaInstrumentId', 'CityName', 'CommentText', 'Company', 'ContactEmail', 'ContactName', 'ContactPhone', 'CountryCode', 'InstTypeId', 'SerialNumber', 'StateCode', 'ZipCode']).length==0) {
|
|
647
647
|
reject(new CWError(9, 'At least one of the arguments (AddressLine1, Amount, CaInstrumentId, CityName, CommentText, Company, ContactEmail, ContactName, ContactPhone, CountryCode, InstTypeId, SerialNumber, StateCode, ZipCode) must be defined.'))
|
|
648
648
|
}
|
|
649
649
|
var data = filters
|
|
@@ -740,7 +740,7 @@ export class CaseFinancial {
|
|
|
740
740
|
searchCaseInstrumentReleases(filters: Object) {
|
|
741
741
|
return new Promise((resolve, reject) => {
|
|
742
742
|
var data = filters
|
|
743
|
-
if(_.intersectionBy(filters, ['AmountReleased', 'CaInstReleasesId', 'CaInstrumentId', 'CommentText', 'PercentReleased', 'ReleasedBy']).length==0) {
|
|
743
|
+
if(_.intersectionBy(_.keysIn(filters), ['AmountReleased', 'CaInstReleasesId', 'CaInstrumentId', 'CommentText', 'PercentReleased', 'ReleasedBy']).length==0) {
|
|
744
744
|
reject(new CWError(3, 'At least one of the attributes (AmountReleased, CaInstReleasesId, CaInstrumentId, CommentText, PercentReleased, ReleasedBy) must be defined.'))
|
|
745
745
|
}
|
|
746
746
|
this.cw.runRequest('Pll/CaseInstReleases/Search', data).then(r => {
|
|
@@ -776,7 +776,7 @@ export class CaseFinancial {
|
|
|
776
776
|
*/
|
|
777
777
|
searchAvailableFees(filters: {AccountCode?: string, FeeCode?: string, FeeDesc?: string, FeeSetupId?: number, FeeTypeId?: number}) {
|
|
778
778
|
return new Promise((resolve, reject) => {
|
|
779
|
-
if(_.intersectionBy(filters, ['AccountCode', 'FeeCode', 'FeeDesc', 'FeeSetupId', 'FeeTypeId']).length==0) {
|
|
779
|
+
if(_.intersectionBy(_.keysIn(filters), ['AccountCode', 'FeeCode', 'FeeDesc', 'FeeSetupId', 'FeeTypeId']).length==0) {
|
|
780
780
|
reject(new CWError(8, 'At least one of the attributes (AccountCode, FeeCode, FeeDesc, FeeSetupId, FeeTypeId) must be defined.'))
|
|
781
781
|
}
|
|
782
782
|
var data = filters
|
package/src/case_workflow.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CWError } from './error'
|
|
2
2
|
const _ = require('lodash')
|
|
3
|
+
import { Comments } from './comments'
|
|
3
4
|
|
|
4
5
|
export class CaseWorkflow {
|
|
5
6
|
/**
|
|
@@ -7,11 +8,19 @@ export class CaseWorkflow {
|
|
|
7
8
|
*/
|
|
8
9
|
cw: any
|
|
9
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Task sub-methods
|
|
13
|
+
*/
|
|
14
|
+
task: Object
|
|
15
|
+
|
|
10
16
|
/**
|
|
11
17
|
* @hidden
|
|
12
18
|
*/
|
|
13
19
|
constructor(cw) {
|
|
14
20
|
this.cw = cw
|
|
21
|
+
this.task = {
|
|
22
|
+
comment: new Comments(cw, 'CaTask')
|
|
23
|
+
}
|
|
15
24
|
}
|
|
16
25
|
|
|
17
26
|
/**
|
|
@@ -266,7 +275,7 @@ export class CaseWorkflow {
|
|
|
266
275
|
var data = {
|
|
267
276
|
CaTaskId: caTaskId
|
|
268
277
|
}
|
|
269
|
-
if(_.intersectionBy(options, ['TaskCompleteDate', 'TaskCompletedBy']).length==0) {
|
|
278
|
+
if(_.intersectionBy(_.keysIn(options), ['TaskCompleteDate', 'TaskCompletedBy']).length==0) {
|
|
270
279
|
reject(new CWError(2, 'At least one of the attributes (TaskCompletedBy, TaskCompleteDate) must be defined.'))
|
|
271
280
|
}
|
|
272
281
|
if(typeof(options)!='undefined') {
|
|
@@ -349,7 +358,7 @@ export class CaseWorkflow {
|
|
|
349
358
|
*/
|
|
350
359
|
searchForTasks(filters?: Object) {
|
|
351
360
|
return new Promise((resolve, reject) => {
|
|
352
|
-
if(_.intersectionBy(filters, ['ResponsibleUserId', 'TaskAvailable', 'TaskComplete', 'TaskType']).length==0) {
|
|
361
|
+
if(_.intersectionBy(_.keysIn(filters), ['ResponsibleUserId', 'TaskAvailable', 'TaskComplete', 'TaskType']).length==0) {
|
|
353
362
|
reject(new CWError(1, 'At least one of the attributes (ResponsibleUserId, TaskAvailable, TaskComplete, TaskType) must be defined.'))
|
|
354
363
|
}
|
|
355
364
|
var data = filters
|
package/src/cityworks.ts
CHANGED
|
@@ -34,10 +34,10 @@ interface Citywork {
|
|
|
34
34
|
default_domain?: any
|
|
35
35
|
|
|
36
36
|
general?: Object
|
|
37
|
+
search?: Object
|
|
37
38
|
activity_link?: Object
|
|
38
39
|
message_queue?: Object
|
|
39
40
|
gis?: Object
|
|
40
|
-
// case?: Object
|
|
41
41
|
inspection?: Object
|
|
42
42
|
workorder?: Object
|
|
43
43
|
request?: Object
|
|
@@ -87,10 +87,10 @@ module.exports = class Cityworks implements Citywork {
|
|
|
87
87
|
}
|
|
88
88
|
error?: Object
|
|
89
89
|
general?: Object
|
|
90
|
+
search?: Object
|
|
90
91
|
activity_link?: Object
|
|
91
92
|
message_queue?: Object
|
|
92
93
|
gis?: Object
|
|
93
|
-
search?: Object
|
|
94
94
|
request?: Object
|
|
95
95
|
inspection?: Object
|
|
96
96
|
workorder?: Object
|
|
@@ -154,6 +154,7 @@ module.exports = class Cityworks implements Citywork {
|
|
|
154
154
|
this.inspection = new Inspection(this)
|
|
155
155
|
this.workorder = new WorkOrder(this)
|
|
156
156
|
this.case = new Case(this)
|
|
157
|
+
this.search = new Search(this)
|
|
157
158
|
} else {
|
|
158
159
|
let _this = this
|
|
159
160
|
_.forEach(this.potential_loads, function(v) {
|
|
@@ -248,7 +249,6 @@ module.exports = class Cityworks implements Citywork {
|
|
|
248
249
|
// failed
|
|
249
250
|
reject(new CWError(10, 'No response received from Cityworks API.'))
|
|
250
251
|
} else if(typeof(obj)!='undefined' && typeof(obj.Value)!='undefined') { // && typeof(response.Value.Token)!='undefined') {
|
|
251
|
-
// console.log(str, options, pd, obj)
|
|
252
252
|
resolve(obj)
|
|
253
253
|
} else {
|
|
254
254
|
reject(new CWError(3, "Unknown error.", {options: options, postedData: pd, api_returned_string: obj}))
|
package/src/comments.ts
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { CWError } from './error'
|
|
2
|
+
import ReversibleMap from 'reversible-map'
|
|
3
|
+
const _ = require('lodash')
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A plugin that contains "comments" methods
|
|
8
|
+
*/
|
|
9
|
+
export class Comments {
|
|
10
|
+
/**
|
|
11
|
+
* @hidden
|
|
12
|
+
*/
|
|
13
|
+
cw: any
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Storage of all potential activity types which comments can be attached to: Unknown, Request, WorkOrder, CaTask, CaObject, CaCorrection, Project, Contract
|
|
17
|
+
*/
|
|
18
|
+
activityTypes: ReversibleMap<string, number>
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Storage of object's active activityType
|
|
22
|
+
*/
|
|
23
|
+
currentActivityType: string
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @hidden
|
|
27
|
+
*/
|
|
28
|
+
constructor(cw, activityType) {
|
|
29
|
+
this.cw = cw
|
|
30
|
+
this.activityTypes = new ReversibleMap<string, number>()
|
|
31
|
+
this.activityTypes.set("Unknown", 0)
|
|
32
|
+
this.activityTypes.set("Request", 1)
|
|
33
|
+
this.activityTypes.set("WorkOrder", 2)
|
|
34
|
+
this.activityTypes.set("CaTask", 3)
|
|
35
|
+
this.activityTypes.set("CaObject", 4)
|
|
36
|
+
this.activityTypes.set("CaCorrection", 5)
|
|
37
|
+
this.activityTypes.set("Project", 6)
|
|
38
|
+
this.activityTypes.set("Contract", 7)
|
|
39
|
+
|
|
40
|
+
if(!this.activityTypes.has(activityType)) {
|
|
41
|
+
throw new CWError(1, 'Activity type not found.', {'provided': activityType, 'options':this.activityTypes})
|
|
42
|
+
}
|
|
43
|
+
this.currentActivityType = activityType
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Add a comment
|
|
48
|
+
*
|
|
49
|
+
* @param {number} sid - The SID of the activity to which the comment should be attached
|
|
50
|
+
* @param {string} comment - The text for the comment
|
|
51
|
+
* @return {Object} Returns a Promise which represents a CommentRecord object
|
|
52
|
+
*/
|
|
53
|
+
add(sid: number, comment: string) {
|
|
54
|
+
return new Promise((resolve, reject) => {
|
|
55
|
+
var data = {
|
|
56
|
+
ActivityType: this.activityTypes.get(this.currentActivityType),
|
|
57
|
+
ActivitySid: sid,
|
|
58
|
+
Comments: comment
|
|
59
|
+
}
|
|
60
|
+
this.cw.runRequest('Ams/Comment/Add', data).then((response: any) => {
|
|
61
|
+
resolve(response.Value)
|
|
62
|
+
})
|
|
63
|
+
})
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Update a comment
|
|
68
|
+
*
|
|
69
|
+
* @param {number} id - The ID of the comment which should be updated
|
|
70
|
+
* @param {string} comment - The new text for the updated comment
|
|
71
|
+
* @return {Object} Returns a Promise which represents a CommentRecord object
|
|
72
|
+
*/
|
|
73
|
+
update(id: number, comment: string) {
|
|
74
|
+
return new Promise((resolve, reject) => {
|
|
75
|
+
var data = {
|
|
76
|
+
ActivityType: this.activityTypes.get(this.currentActivityType),
|
|
77
|
+
CommentId: id,
|
|
78
|
+
Comments: comment
|
|
79
|
+
}
|
|
80
|
+
this.cw.runRequest('Ams/Comment/Update', data).then((response: any) => {
|
|
81
|
+
resolve(response.Value)
|
|
82
|
+
})
|
|
83
|
+
})
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Get comments for activity items
|
|
88
|
+
*
|
|
89
|
+
* @param {Array<number>} sids - The options SIDs to get comments for.
|
|
90
|
+
* @return {Object} Returns Promise object that represents a collection of available comments
|
|
91
|
+
*/
|
|
92
|
+
get(sids: Array<number>) {
|
|
93
|
+
return new Promise((resolve, reject) => {
|
|
94
|
+
if(typeof(sids)!='undefined' && sids !=null) {
|
|
95
|
+
var data = {
|
|
96
|
+
ActivitySids: sids,
|
|
97
|
+
ActivityType: this.activityTypes.get(this.currentActivityType),
|
|
98
|
+
}
|
|
99
|
+
this.cw.runRequest('Ams/Comment/ByActivitySids', data).then((response: any) => {
|
|
100
|
+
if(sids.length==1) {
|
|
101
|
+
resolve(response.Value[sids[0]])
|
|
102
|
+
} else {
|
|
103
|
+
resolve(response.Value)
|
|
104
|
+
}
|
|
105
|
+
})
|
|
106
|
+
}
|
|
107
|
+
})
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Get pre-defined comments for activityTypes
|
|
112
|
+
*
|
|
113
|
+
* @param {number} problemSid - The ProblemSid if currentActivityType is (Service) Request
|
|
114
|
+
* @param {string} [category] - Only applies to WorkOrder and ServiceRequest category comments.
|
|
115
|
+
* @return {Object} Returns Promise object that represents a collection of available comment templates.
|
|
116
|
+
*/
|
|
117
|
+
getPredefined(problemSid?: number, category?: string) {
|
|
118
|
+
return new Promise((resolve, reject) => {
|
|
119
|
+
var data = {}
|
|
120
|
+
if(this.currentActivityType=='Request') {
|
|
121
|
+
_.set(data, 'ProblemSid', problemSid)
|
|
122
|
+
}
|
|
123
|
+
if(typeof(category)!='undefined' && (this.currentActivityType=='Request' || this.currentActivityType=='WorkOrder')) {
|
|
124
|
+
_.set(data, 'Category', category)
|
|
125
|
+
}
|
|
126
|
+
_.set(data, 'ActivityType', this.activityTypes.get(this.currentActivityType))
|
|
127
|
+
this.cw.runRequest('Ams/Comment/PredefinedComments', data).then((response: any) => {
|
|
128
|
+
resolve(response.Value)
|
|
129
|
+
})
|
|
130
|
+
})
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// /**
|
|
134
|
+
// * Get pre-set comments for activityTypes
|
|
135
|
+
// *
|
|
136
|
+
// * @param {Array<string>} [activityTypes] - Provide a list of activity types. Defaults to current activity type.
|
|
137
|
+
// * @param {Array<string>} [categories] - Only applies to WorkOrder and ServiceRequest category comments.
|
|
138
|
+
// * @return {Object} Returns Promise object that represents a collection of available comment templates.
|
|
139
|
+
// */
|
|
140
|
+
// getForActivityList(activityTypes?: Array<string>, categories?: Array<string>) {
|
|
141
|
+
// return new Promise((resolve, reject) => {
|
|
142
|
+
// var data = {}
|
|
143
|
+
// if(typeof(activityTypes)!='undefined') {
|
|
144
|
+
// // TODO: iterate through it and output numeric types
|
|
145
|
+
// _.set(data, 'ActivityTypes', activityTypes)
|
|
146
|
+
// } else {
|
|
147
|
+
// _.set(data, 'ActivityTypes', [this.activityTypes.get(this.currentActivityType)])
|
|
148
|
+
// }
|
|
149
|
+
// if(typeof(categories)!='undefined') {
|
|
150
|
+
// _.set(data, 'Categories', categories)
|
|
151
|
+
// }
|
|
152
|
+
// console.log(data, 'data')
|
|
153
|
+
// this.cw.runRequest('Ams/Comment/ByActivityTypes', data).then((response: any) => {
|
|
154
|
+
// resolve(response.Value)
|
|
155
|
+
// })
|
|
156
|
+
// })
|
|
157
|
+
// }
|
|
158
|
+
|
|
159
|
+
}
|
package/src/message_queue.ts
CHANGED
|
@@ -13,7 +13,12 @@ export class MessageQueue {
|
|
|
13
13
|
* Complete: 2,
|
|
14
14
|
* Failed: 3
|
|
15
15
|
*/
|
|
16
|
-
status: Object
|
|
16
|
+
status: Object = {
|
|
17
|
+
Pending: 0,
|
|
18
|
+
Processing: 1,
|
|
19
|
+
Complete: 2,
|
|
20
|
+
Failed: 3
|
|
21
|
+
}
|
|
17
22
|
/**
|
|
18
23
|
* Hook Types -
|
|
19
24
|
* Unknown: 0,
|
|
@@ -21,25 +26,18 @@ export class MessageQueue {
|
|
|
21
26
|
* Email: 2,
|
|
22
27
|
* WebHook: 3
|
|
23
28
|
*/
|
|
24
|
-
hook_types: Object
|
|
29
|
+
hook_types: Object = {
|
|
30
|
+
Unknown: 0,
|
|
31
|
+
ActivityUpdate: 1,
|
|
32
|
+
Email: 2,
|
|
33
|
+
WebHook: 3
|
|
34
|
+
}
|
|
25
35
|
|
|
26
36
|
/**
|
|
27
37
|
* @hidden
|
|
28
38
|
*/
|
|
29
39
|
constructor(cw) {
|
|
30
40
|
this.cw = cw
|
|
31
|
-
this.status = {
|
|
32
|
-
Pending: 0,
|
|
33
|
-
Processing: 1,
|
|
34
|
-
Complete: 2,
|
|
35
|
-
Failed: 3
|
|
36
|
-
}
|
|
37
|
-
this.hook_types = {
|
|
38
|
-
Unknown: 0,
|
|
39
|
-
ActivityUpdate: 1,
|
|
40
|
-
Email: 2,
|
|
41
|
-
WebHook: 3
|
|
42
|
-
}
|
|
43
41
|
}
|
|
44
42
|
|
|
45
43
|
/**
|
package/src/request.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CWError } from './error'
|
|
2
2
|
const _ = require('lodash')
|
|
3
3
|
import { RequestAdmin } from './request_admin'
|
|
4
|
+
import { Comments } from './comments'
|
|
4
5
|
|
|
5
6
|
export class Request {
|
|
6
7
|
/**
|
|
@@ -13,12 +14,18 @@ export class Request {
|
|
|
13
14
|
*/
|
|
14
15
|
admin?: Object
|
|
15
16
|
|
|
17
|
+
/**
|
|
18
|
+
* WorkOrder Comments methods
|
|
19
|
+
*/
|
|
20
|
+
comment: Object
|
|
21
|
+
|
|
16
22
|
/**
|
|
17
23
|
* @hidden
|
|
18
24
|
*/
|
|
19
25
|
constructor(cw) {
|
|
20
26
|
this.cw = cw
|
|
21
27
|
this.admin = new RequestAdmin(cw)
|
|
28
|
+
this.comment = new Comments(cw, 'Request')
|
|
22
29
|
}
|
|
23
30
|
|
|
24
31
|
/**
|
|
@@ -219,28 +226,6 @@ export class Request {
|
|
|
219
226
|
})
|
|
220
227
|
}
|
|
221
228
|
|
|
222
|
-
/**
|
|
223
|
-
* Add a comment to a request
|
|
224
|
-
*
|
|
225
|
-
* @category Requests
|
|
226
|
-
* @param {number} requestId - The ID of the request to retrieve
|
|
227
|
-
* @param {string} comment - The comment text to add
|
|
228
|
-
* @return {Object} Returns Promise that represents an object describing the comment added
|
|
229
|
-
*/
|
|
230
|
-
comment(requestId: number, comment: string) {
|
|
231
|
-
return new Promise((resolve, reject) => {
|
|
232
|
-
var data = {
|
|
233
|
-
RequestId: requestId,
|
|
234
|
-
Comments: comment
|
|
235
|
-
}
|
|
236
|
-
this.cw.runRequest('Ams/ServiceRequest/AddComments', data).then(r => {
|
|
237
|
-
resolve(r.Value)
|
|
238
|
-
}).catch(e => {
|
|
239
|
-
reject(e)
|
|
240
|
-
})
|
|
241
|
-
})
|
|
242
|
-
}
|
|
243
|
-
|
|
244
229
|
/**
|
|
245
230
|
* Cancel requests
|
|
246
231
|
*
|