cityworks 0.0.37 → 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.
@@ -1,45 +0,0 @@
1
- import { CWError } from './error'
2
- const _ = require('lodash')
3
-
4
- export class InspectionAdmin {
5
- /**
6
- * @hidden
7
- */
8
- cw: any
9
-
10
- /**
11
- * @hidden
12
- */
13
- constructor(cw) {
14
- this.cw = cw
15
- }
16
-
17
- /**
18
- * Get inspection templates
19
- *
20
- * @category Inspection Templates
21
- * @param {Array<string>} [entityTypes] - The Entity Type(s) to return potential inspections for
22
- * @param {boolean} [canCreate] - If true, only return templates the user can create, ignored if false or null, default is true
23
- * @param {Object} [options] - An object which can include: [IncludeInactive]: boolean, MaximumDateModified: Date, MinimumDateModified: Date, TemplateIds: Array<number>
24
- * @return {Object} Returns Promise that represents a collection of all Inspections matching the provided parameters
25
- */
26
- getTemplates(entityTypes?: Array<string>, canCreate?: boolean, options?: {IncludeInactive?: boolean, MaximumDateModified?: Date, MinimumDateModified?: Date, TemplateIds?: Array<number>}) {
27
- return new Promise((resolve, reject) => {
28
- var data: {EntityTypes?: Array<string>, CanCreate?: boolean, IncludeInactive?: boolean, MaximumDateModified?: Date, MinimumDateModified?: Date, TemplateIds?: Array<number>} = {}
29
- if(typeof(entityTypes)!=='undefined') {
30
- data.EntityTypes = entityTypes
31
- }
32
- data.CanCreate = typeof(canCreate)!=='undefined' ? canCreate : true
33
- if(typeof(options)==='object') {
34
- _.forIn(options, (v, k) => {
35
- data[k] = v
36
- })
37
- }
38
- this.cw.runRequest('Ams/InspectionTemplate/Templates', data).then(r => {
39
- resolve(r.Value)
40
- }).catch(e => {
41
- reject(e)
42
- })
43
- })
44
- }
45
- }
@@ -1,243 +0,0 @@
1
- import { CWError } from './error'
2
- const _ = require('lodash')
3
-
4
- export class MessageQueue {
5
- /**
6
- * @hidden
7
- */
8
- cw: any
9
- /**
10
- * Statuses -
11
- * Pending: 0,
12
- * Processing: 1,
13
- * Complete: 2,
14
- * Failed: 3
15
- */
16
- status: Object = {
17
- Pending: 0,
18
- Processing: 1,
19
- Complete: 2,
20
- Failed: 3
21
- }
22
- /**
23
- * Hook Types -
24
- * Unknown: 0,
25
- * ActivityUpdate: 1,
26
- * Email: 2,
27
- * WebHook: 3
28
- */
29
- hook_types: Object = {
30
- Unknown: 0,
31
- ActivityUpdate: 1,
32
- Email: 2,
33
- WebHook: 3
34
- }
35
-
36
- /**
37
- * @hidden
38
- */
39
- constructor(cw) {
40
- this.cw = cw
41
- }
42
-
43
- /**
44
- * Process Webhook MessageQueue records by MessageQueueId
45
- *
46
- * @param {Array<number>} [ids] - List of MessageQueueId values
47
- * @param {boolean} [delete_successful] - automatically delete messages that complete with successful execution, default is false
48
- * @return {Array<>} Returns Promise object that represents a collection of QueueMessages which have been processed
49
- */
50
- processMessages(ids: Array<number>, delete_successful: boolean = false) {
51
- return new Promise((resolve, reject) => {
52
- let data = { Ids: ids, Delete: delete_successful}
53
- let path = 'General/WebHookEvent/ProcessMessages'
54
- this.cw.runRequest(path, data).then((response: any) => {
55
- // TODO
56
- }).catch(e => {
57
- reject(e)
58
- })
59
- })
60
- }
61
-
62
- /**
63
- * Get Messages specified in list of MessageQueueIds
64
- *
65
- * @param {Array<number>} ids - List of MessageQueueId values
66
- * @param {string} status -
67
- * @param {number} [maxcount] - Maximum number returned. Defaults to 15
68
- * @return {Array<>} Returns Promise object that represents a collection of QueueMessages which have been processed
69
- */
70
- get(ids: Array<number>, status: string, maxcount: number = 15) {
71
- return new Promise((resolve, reject) => {
72
- if(typeof(this.status[status])=='undefined') {
73
- reject(new CWError(1, 'Status provided does not exist or is mispelled.', {'provided': status, 'available':this.status}))
74
- }
75
- let data = {
76
- "Ids": ids,
77
- "MaxCount": typeof(maxcount)!='undefined' ? maxcount : 15,
78
- "Status": this.status[status]
79
- }
80
- let path = 'General/MessageQueue/ByIds'
81
- this.cw.runRequest(path, data).then((response: any) => {
82
- // TODO
83
- }).catch(e => {
84
- reject(e)
85
- })
86
- })
87
- }
88
-
89
- /**
90
- * Delete Messages specified in list of MessageQueueIds
91
- *
92
- * @param {Array<number>} ids - List of MessageQueueId values
93
- * @param {string} status - automatically delete messages that complete with successful execution, default is false
94
- * @param {number} [hours_to_keep] - utomatically delete messages that complete with successful execution, default is false
95
- * @return {Array<>} Returns Promise object that represents a collection of QueueMessages which have been processed
96
- */
97
- delete(ids: Array<number>, status: string, hours_to_keep?: number) {
98
- return new Promise((resolve, reject) => {
99
- if(typeof(this.status[status])=='undefined') {
100
- reject(new CWError(2, 'Status provided does not exist or is mispelled.', {'provided': status, 'available':this.status}))
101
- }
102
- let data = {
103
- "Ids": ids,
104
- "Status": this.status[status],
105
- "HoursToKeep": hours_to_keep
106
- }
107
- let path = 'General/MessageQueue/Delete'
108
- this.cw.runRequest(path, data).then((response: any) => {
109
- // TODO
110
- }).catch(e => {
111
- reject(e)
112
- })
113
- })
114
- }
115
-
116
- // PreferencesList<GlobalPreference>
117
- // Base response type: CoreResponseBase
118
- // Get a list of message queue preferences
119
- // This method has no parameters
120
- preferences() {
121
- return new Promise((resolve, reject) => {
122
- let data = {}
123
- let path = 'General/MessageQueue/Preferences'
124
- this.cw.runRequest(path, data).then((response: any) => {
125
- // TODO
126
- }).catch(e => {
127
- reject(e)
128
- })
129
- })
130
- }
131
-
132
- search(parameters, max_results?: number) {
133
- let data: any
134
- return new Promise((resolve, reject) => {
135
- if(typeof(parameters.status)!=='undefined' && typeof(this.status[parameters.status])=='undefined') {
136
- reject(new CWError(3, 'Status provided does not exist or is mispelled.', {'provided': parameters.status, 'available':this.status}))
137
- } else if(typeof(parameters.status)!=='undefined' && typeof(this.status[parameters.status])!=='undefined') {
138
- data.Status = this.status[parameters.status]
139
- }
140
- if(typeof(max_results)!=='undefined') {
141
- data.MaxResults = max_results
142
- }
143
- let allowed_params = ['Id', 'HookId', 'HookType', 'Result', 'DateCreatedBegin', 'DateCreatedEnd', 'DateUpdatedBegin', 'DateUpdatedEnd']
144
- let disallowed_params = ['Status', 'MaxResults']
145
- _.forEach(parameters, (v, k) => {
146
- if(_.indexOf(allowed_params,k)!=-1 && _.indexOf(disallowed_params, k)==-1) {
147
- data[k] = v
148
- } else if(_.indexOf(disallowed_params, k)==-1) {
149
- reject(new CWError(4, 'Provided parameter does not exist or is mispelled.', {'provided': k, 'value': v, 'available':_.concat(allowed_params, disallowed_params)}))
150
- }
151
- })
152
- let path = 'General/MessageQueue/Search'
153
- this.cw.runRequest(path, data).then((response: any) => {
154
- // TODO
155
- if(typeof(response.Value)=='undefined') {
156
- response.Value = []
157
- }
158
- resolve(response.Value)
159
- }).catch(e => {
160
- reject(e)
161
- })
162
- })
163
- }
164
-
165
- /**
166
- * Update queue message
167
- *
168
- * @param {Object} parameters - Provide allowed parameters:
169
- *
170
- * {
171
- * HookId: number,
172
- * Id: number,
173
- * Packet: string,
174
- * Result: string,
175
- * Status: string, // Available options: Pending, Processing, Complete, Failed
176
- * HookType: string // Available options: Unknown, ActivityUpdate, Email, WebHook
177
- * }
178
- *
179
- * @return {Object} Returns Promise object that represents an Object with the desired GIS service definitions
180
- */
181
- update(parameters: any) {
182
- let data: any
183
- return new Promise((resolve, reject) => {
184
- if(typeof(parameters.status)!=='undefined' && typeof(this.status[parameters.status])=='undefined') {
185
- reject(new CWError(3, 'Status provided does not exist or is mispelled.', {'provided': parameters.status, 'available':this.status}))
186
- } else if(typeof(parameters.status)!=='undefined' && typeof(this.status[parameters.status])!=='undefined') {
187
- data.Status = this.status[parameters.status]
188
- }
189
- if(typeof(parameters.hook_types)!=='undefined' && typeof(this.hook_types[parameters.hook_types])=='undefined') {
190
- reject(new CWError(3, 'Status provided does not exist or is mispelled.', {'provided': parameters.hook_types, 'available':this.hook_types}))
191
- } else if(typeof(parameters.hook_types)!=='undefined' && typeof(this.hook_types[parameters.hook_types])!=='undefined') {
192
- data.HookType = this.hook_types[parameters.hook_types]
193
- }
194
- let allowed_params = ['Id', 'HookId', 'Packet', 'Result']
195
- let disallowed_params = ['Status', 'HookType']
196
- _.forEach(parameters, (v, k) => {
197
- if(_.indexOf(allowed_params,k)!=-1 && _.indexOf(disallowed_params, k)==-1) {
198
- data[k] = v
199
- } else if(_.indexOf(disallowed_params, k)==-1) {
200
- reject(new CWError(5, 'Provided parameter does not exist or is mispelled.', {'provided': k, 'value': v, 'available':_.concat(allowed_params, disallowed_params)}))
201
- }
202
- })
203
-
204
- let path = 'General/MessageQueue/Update'
205
- this.cw.runRequest(path, data).then((response: any) => {
206
- // TODO
207
- if(typeof(response.Value)=='undefined') {
208
- response.Value = []
209
- }
210
- resolve(response.Value)
211
- })
212
- })
213
- }
214
-
215
- updateMessageStatus(ids: number[], status: string, hours_to_keep?: number) {
216
- return new Promise((resolve, reject) => {
217
- if(typeof(this.status[status])=='undefined') {
218
- reject(new CWError(2, 'Status provided does not exist or is mispelled.', {'provided': status, 'available':this.status}))
219
- }
220
- let data = {
221
- "Ids": ids,
222
- "Status": this.status[status],
223
- "HoursToKeep": hours_to_keep
224
- }
225
- let path = 'General/MessageQueue/UpdateMessageStatus'
226
- this.cw.runRequest(path, data).then((response: any) => {
227
- // TODO
228
- })
229
- })
230
- }
231
-
232
- getWebooks(hook_ids) {
233
- return new Promise((resolve, reject) => {
234
- let data = {
235
- "HookIds": hook_ids
236
- }
237
- let path = 'General/MessageQueue/WebHooks'
238
- this.cw.runRequest(path, data).then((response: any) => {
239
- // TODO
240
- })
241
- })
242
- }
243
- }