cityworks 0.0.52 → 1.0.1

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.
Files changed (45) hide show
  1. package/README.md +13 -1
  2. package/dist/activity_link.js +219 -0
  3. package/dist/attachments.d.ts +59 -0
  4. package/dist/briefcase.d.ts +22 -1
  5. package/dist/briefcase.js +327 -0
  6. package/dist/case_admin.d.ts +0 -22
  7. package/dist/case_admin.js +821 -0
  8. package/dist/case_assets.js +129 -0
  9. package/dist/case_data.js +416 -0
  10. package/dist/case_financial.js +848 -0
  11. package/dist/case_workflow.js +455 -0
  12. package/dist/comments.js +126 -0
  13. package/dist/error.js +30 -0
  14. package/dist/event_layer.d.ts +97 -0
  15. package/dist/event_layer.js +207 -0
  16. package/dist/general.d.ts +23 -0
  17. package/dist/general.js +212 -0
  18. package/dist/gis.js +250 -0
  19. package/dist/index.d.ts +10 -8
  20. package/dist/index.js +1 -1
  21. package/dist/index.js.map +1 -1
  22. package/dist/index.m.js +1 -1
  23. package/dist/index.m.js.map +1 -1
  24. package/dist/index.modern.mjs +1 -1
  25. package/dist/index.modern.mjs.map +1 -1
  26. package/dist/index.umd.js +1 -1
  27. package/dist/index.umd.js.map +1 -1
  28. package/dist/inspection.d.ts +17 -1
  29. package/dist/inspection.js +933 -0
  30. package/dist/inspection_admin.js +43 -0
  31. package/dist/inspection_costs.js +200 -0
  32. package/dist/message_queue.js +248 -0
  33. package/dist/query.d.ts +108 -0
  34. package/dist/query.js +242 -0
  35. package/dist/request.d.ts +5 -1
  36. package/dist/request.js +899 -0
  37. package/dist/request_admin.js +32 -0
  38. package/dist/request_costs.js +113 -0
  39. package/dist/search.d.ts +12 -1
  40. package/dist/search.js +371 -0
  41. package/dist/workorder.d.ts +4 -0
  42. package/dist/workorder.js +951 -0
  43. package/dist/workorder_admin.js +248 -0
  44. package/dist/workorder_costs.js +274 -0
  45. package/package.json +7 -2
package/README.md CHANGED
@@ -10,7 +10,7 @@ Require the class:
10
10
 
11
11
  Instantiate the Class for the instance of Cityworks available given a domain:
12
12
 
13
- cw.Cityworks.configure('cw.domain.tld', {path: 'cityworks'})
13
+ cw.Cityworks.configure('cw.domain.tld', {path: 'cityworks', version: 15})
14
14
 
15
15
  ## Authentication
16
16
 
@@ -89,3 +89,15 @@ For any object in Cityworks which can be commented on, use the [Comments class](
89
89
  cw.workorder.comment.add(WorkOrderSIDGoesHere, "Comment goes here").then(resp => {})
90
90
 
91
91
  cw.request.comment.add(RequestIDGoesHere, "Comment goes here").then(resp => {})
92
+
93
+ ## Attachments
94
+
95
+ For any object in Cityworks which has attachments, (including cases as CaRelDocs), use the [Attachments class](https://walker.github.io/cityworks/modules/attachments.html) via the class the attachment is to be made on:
96
+
97
+ cw.briefcase.attachment.add(CaObjectIdGoesHere, path.join('uploads', 'filename.pdf')).then(resp => {})
98
+
99
+ cw.workorder.attachment.add(WorkOrderSIDGoesHere, path.join('uploads', 'filename.pdf')).then(resp => {})
100
+
101
+ cw.request.attachment.add(RequestIDGoesHere, path.join('uploads', 'filename.pdf')).then(resp => {})
102
+
103
+ cw.inspection.attachment.add(InspectionIDGoesHere, path.join('uploads', 'filename.pdf')).then(resp => {})
@@ -0,0 +1,219 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ActivityLinks = void 0;
4
+ var error_1 = require("./error");
5
+ var reversible_map_1 = require("reversible-map");
6
+ var _ = require('lodash');
7
+ /**
8
+ * ActivityLinks implements the activity link functions via using the ActivityLink interface
9
+ *
10
+ */
11
+ var ActivityLinks = /** @class */ (function () {
12
+ /**
13
+ * @hidden
14
+ */
15
+ function ActivityLinks(cw) {
16
+ this.cw = cw;
17
+ this.activityTypes = new reversible_map_1.default();
18
+ this.activityTypes.set("null", 0);
19
+ this.activityTypes.set("case", 1);
20
+ this.activityTypes.set("inspection", 2);
21
+ this.activityTypes.set("request", 3);
22
+ this.activityTypes.set("workorder", 4);
23
+ this.activityTypes.set("wipcase", 5);
24
+ this.linkTypes = new reversible_map_1.default();
25
+ this.linkTypes.set("null", 0);
26
+ this.linkTypes.set("parent", 1);
27
+ this.linkTypes.set("related", 2);
28
+ }
29
+ /**
30
+ * Create a new activity link between two items.
31
+ *
32
+ * @param {string} source_type - Source type as string. Options:
33
+ *
34
+ * "null", "case", "inspection", "request", "workorder", "wipcase"
35
+ *
36
+ * @param {number} source_sid - Source SID (numeric ID) one wishes to remove a link between SID as source and a particular destination
37
+ * @param {string} destination_type - Destination type as string
38
+ *
39
+ * "null", "case", "inspection", "request", "workorder", "wipcase"
40
+ *
41
+ * @param {number} destination_sid - Destination SID (numeric ID) one wishes to remove a link between SID as destination and a particular source
42
+ * @param {string} link_type - The type of link which exists between provided source and destination. Defaults to `related`. Options:
43
+ *
44
+ * "null", "parent", "related"
45
+ *
46
+ * @return {Object} Returns Promise object that represents a
47
+ */
48
+ ActivityLinks.prototype.add = function (source_type, source_sid, destination_type, destination_sid, link_type) {
49
+ var _this_1 = this;
50
+ if (link_type === void 0) { link_type = 'related'; }
51
+ return new Promise(function (resolve, reject) {
52
+ if (!_this_1.activityTypes.has(source_type)) {
53
+ reject(new error_1.CWError(1, 'Source type not found.', { 'provided': source_type, 'options': _this_1.activityTypes }));
54
+ }
55
+ if (!_this_1.activityTypes.has(destination_type)) {
56
+ reject(new error_1.CWError(2, 'Destination type not found.', { 'provided': destination_type, 'options': _this_1.activityTypes }));
57
+ }
58
+ if (!_this_1.linkTypes.has(link_type)) {
59
+ reject(new error_1.CWError(3, 'Link type not found.', { 'provided': link_type, 'options': _this_1.linkTypes }));
60
+ }
61
+ var data = {
62
+ SourceType: _this_1.activityTypes.get(source_type),
63
+ SourceSid: source_sid,
64
+ DestType: _this_1.activityTypes.get(destination_type),
65
+ DestSid: destination_sid,
66
+ LinkType: _this_1.linkTypes.get(link_type)
67
+ };
68
+ var path = 'General/ActivityLink/Add';
69
+ _this_1.cw.runRequest(path, data).then(function (response) {
70
+ resolve(response.Value);
71
+ }).catch(function (e) {
72
+ reject(e);
73
+ });
74
+ });
75
+ };
76
+ /**
77
+ * Get the links for a particular node type by ID.
78
+ *
79
+ * @param {string} type - Source type as string. Options:
80
+ *
81
+ * "null", "case", "inspection", "request", "workorder", "wipcase"
82
+ *
83
+ * @param {Array<number>} sids - Array of numeric (S)IDs you wish to get of the specified type
84
+ * @return {Object} Returns Promise object that represents a collection
85
+ */
86
+ ActivityLinks.prototype.get = function (type, sids) {
87
+ var _this_1 = this;
88
+ return new Promise(function (resolve, reject) {
89
+ if (!_this_1.activityTypes.has(type)) {
90
+ reject(new error_1.CWError(4, 'Activity type not found.', { 'provided': type, 'options': _this_1.activityTypes }));
91
+ }
92
+ var data = {
93
+ ActivityType: _this_1.activityTypes.get(type),
94
+ ActivitySids: sids
95
+ };
96
+ var _this = _this_1;
97
+ var path = 'General/ActivityLink/ByActivitySids';
98
+ _this_1.cw.runRequest(path, data).then(function (response) {
99
+ var return_data = new Array();
100
+ _.forEach(response.Value, function (link, key) {
101
+ link.DestType = _this.activityTypes.get(link.DestType);
102
+ link.SourceType = _this.activityTypes.get(link.SourceType);
103
+ link.LinkType = _this.linkTypes.get(link.LinkType);
104
+ return_data.push(link);
105
+ });
106
+ resolve(return_data);
107
+ }).catch(function (e) {
108
+ reject(e);
109
+ });
110
+ });
111
+ };
112
+ /**
113
+ * Clone a current activity link.
114
+ *
115
+ * @param {string} source_type - Source type as string. Options:
116
+ *
117
+ * "null", "case", "inspection", "request", "workorder", "wipcase"
118
+ *
119
+ * @param {number} source_sid - Source SID (numeric ID) one wishes to clone a link between SID as source and a particular destination
120
+ * @param {string} destination_type - Destination type as string
121
+ *
122
+ * "null", "case", "inspection", "request", "workorder", "wipcase"
123
+ *
124
+ * @param {number} destination_sid - Destination SID (numeric ID) one wishes to clone a link between SID as destination and a particular source
125
+ * @return {Object} Returns Promise object that represents a
126
+ */
127
+ ActivityLinks.prototype.clone = function (source_type, source_sid, destination_type, destination_sid) {
128
+ var _this_1 = this;
129
+ return new Promise(function (resolve, reject) {
130
+ if (!_this_1.activityTypes.has(source_type)) {
131
+ reject(new error_1.CWError(1, 'Source type not found.', { 'provided': source_type, 'options': _this_1.activityTypes }));
132
+ }
133
+ if (!_this_1.activityTypes.has(destination_type)) {
134
+ reject(new error_1.CWError(2, 'Destination type not found.', { 'provided': destination_type, 'options': _this_1.activityTypes }));
135
+ }
136
+ var data = {
137
+ SourceActivityType: _this_1.activityTypes.get(source_type),
138
+ SourceActivitySid: source_sid,
139
+ DestinationActivityType: _this_1.activityTypes.get(destination_type),
140
+ DestinationActivitySid: destination_sid
141
+ };
142
+ var path = 'General/ActivityLink/CloneByActivitySid';
143
+ _this_1.cw.runRequest(path, data).then(function (response) {
144
+ resolve(response.Value);
145
+ }).catch(function (e) {
146
+ reject(e);
147
+ });
148
+ });
149
+ };
150
+ /**
151
+ * Delete an activity link by ID
152
+ *
153
+ * @param {number} activity_link_id - The ID of the activity link one wishes to delete
154
+ * @return {Object} Returns Promise object that represents a
155
+ */
156
+ ActivityLinks.prototype.delete = function (activity_link_id) {
157
+ var _this_1 = this;
158
+ return new Promise(function (resolve, reject) {
159
+ var data = {
160
+ ActivityLinkId: activity_link_id
161
+ };
162
+ var path = 'General/ActivityLink/Delete';
163
+ _this_1.cw.runRequest(path, data).then(function (response) {
164
+ resolve(response.Value);
165
+ }).catch(function (e) {
166
+ reject(e);
167
+ });
168
+ });
169
+ };
170
+ /**
171
+ * Remove a link by specifying everything.
172
+ *
173
+ * @param {string} source_type - Source type as string. Options:
174
+ *
175
+ * "null", "case", "inspection", "request", "workorder", "wipcase"
176
+ *
177
+ * @param {number} source_sid - Source SID (numeric ID) one wishes to remove a link between SID as source and a particular destination
178
+ * @param {string} destination_type - Destination type as string
179
+ *
180
+ * "null", "case", "inspection", "request", "workorder", "wipcase"
181
+ *
182
+ * @param {number} destination_sid - Destination SID (numeric ID) one wishes to remove a link between SID as destination and a particular source
183
+ * @param {string} link_type - The type of link which exists between provided source and destination. Defaults to `related`. Options:
184
+ *
185
+ * "null", "parent", "related"
186
+ *
187
+ * @return {Object} Returns Promise object that represents a
188
+ */
189
+ ActivityLinks.prototype.remove = function (source_type, source_sid, destination_type, destination_sid, link_type) {
190
+ var _this_1 = this;
191
+ if (link_type === void 0) { link_type = 'related'; }
192
+ return new Promise(function (resolve, reject) {
193
+ if (!_this_1.activityTypes.has(source_type)) {
194
+ reject(new error_1.CWError(1, 'Source type not found.', { 'provided': source_type, 'options': _this_1.activityTypes }));
195
+ }
196
+ if (!_this_1.activityTypes.has(destination_type)) {
197
+ reject(new error_1.CWError(1, 'Destination type not found.', { 'provided': destination_type, 'options': _this_1.activityTypes }));
198
+ }
199
+ if (!_this_1.linkTypes.has(link_type)) {
200
+ reject(new error_1.CWError(1, 'Link type not found.', { 'provided': link_type, 'options': _this_1.linkTypes }));
201
+ }
202
+ var data = {
203
+ SourceType: _this_1.activityTypes.get(source_type),
204
+ SourceSid: source_sid,
205
+ DestType: _this_1.activityTypes.get(destination_type),
206
+ DestSid: destination_sid,
207
+ LinkType: _this_1.linkTypes.get(link_type)
208
+ };
209
+ var path = 'General/ActivityLink/Remove';
210
+ _this_1.cw.runRequest(path, data).then(function (response) {
211
+ resolve(response.Value);
212
+ }).catch(function (e) {
213
+ reject(e);
214
+ });
215
+ });
216
+ };
217
+ return ActivityLinks;
218
+ }());
219
+ exports.ActivityLinks = ActivityLinks;
@@ -0,0 +1,59 @@
1
+ export declare class Attachments {
2
+ /**
3
+ * @hidden
4
+ */
5
+ cw: any;
6
+ /**
7
+ * Storage of object's active activityType
8
+ */
9
+ currentActivityType: string;
10
+ /**
11
+ * @hidden
12
+ */
13
+ constructor(cw: any, current_type: any);
14
+ /**
15
+ * Add inspection attachments (doesn't handle URL or Signature type properly, currently)
16
+ *
17
+ * @category Inspection Attachments
18
+ * @param {number} id - The ID of the node to add the attachment to (CA_OBJECT_ID, REQUESTID, WORKORDERSID, WORKORDERID, INSPECTIONID). If WORKORDERID, you _must_ feed in as a string.
19
+ * @param {string} the_file - The loca path of the file to upload to the Cityworks instance
20
+ * @param {number} [task_id] - ID of WorkOrder task, if current activity is a work order and the attachment should be on the task
21
+ * @param {string} [filename] - The filename for the attachment
22
+ * @param {string} [attachment_type] - The filename for the attachment, values: attachment, signature, url
23
+ * @param {string} [comments] - The filename for the attachment
24
+ * @return {Object} Returns object that represents a boolean for action resolution
25
+ */
26
+ add(node_id: number | string, the_file: string, filename?: string, attachment_type?: string, task_id?: number, comments?: string): Promise<unknown>;
27
+ /**
28
+ * Delete inspection attachments
29
+ *
30
+ * @category Inspection Attachments
31
+ * @param {Array<number>|number} attachmentIds - An array of attachment IDs or a single attachment ID to delete.
32
+ * @return {Object} Returns object that represents a boolean for action resolution
33
+ */
34
+ delete(attachmentIds: Array<number> | number): Promise<unknown>;
35
+ /**
36
+ * Download an attachment
37
+ *
38
+ * @category Attachments
39
+ * @param {number} attachmentId - ID of an attachment to download
40
+ * @return {Object} Returns object that represents a file stream
41
+ */
42
+ download(attachmentId: number): Promise<unknown>;
43
+ /**
44
+ * Get attachment by ID (not implemented)
45
+ *
46
+ * @category Attachments
47
+ * @param {number} attachmentId - An attachment ID to get info for
48
+ * @return {Object} Returns object that represents an object that describes the matched inspection attachment
49
+ */
50
+ getById(attachmentId: number): Promise<unknown>;
51
+ /**
52
+ * Get attachment by node (Inspection, WorkOrder, Request, or Case) IDs
53
+ *
54
+ * @category Attachments
55
+ * @param {Array<number>|number} ids - An array of IDs or a single ID (inspectionIds, WorkOrderSids, WorkOrderIds, RequestIds, or CaseIds) to get attachments for. Only one node (Inspection, WorkOrder, Request, or Case) type at a time. Don't mix-and-match WorkOrderIds with WorkOrderSids.
56
+ * @return {Object} Returns object that represents a collection of attachments from the matched inspections
57
+ */
58
+ getByNodesId(ids: Array<number> | number): Promise<unknown>;
59
+ }
@@ -11,6 +11,10 @@ export declare class Briefcase {
11
11
  * Asset (Address) methods
12
12
  */
13
13
  asset?: any;
14
+ /**
15
+ * Asset (Address) methods
16
+ */
17
+ attachments?: any;
14
18
  /**
15
19
  * Workflow & task methods
16
20
  */
@@ -135,8 +139,25 @@ export declare class Briefcase {
135
139
  * Delete Map Layer Fields
136
140
  *
137
141
  * @category Cases
138
- * @param {string} workOrderSId - The case object ID to delete the map layer fields for.
142
+ * @param {number} caObjectId - The case object ID to delete the map layer fields for.
139
143
  * @return {Object} Returns Promise that represents a collection of Objects describing the case object map layer fields deleted
140
144
  */
141
145
  deleteMLFs(caObjectId: number): Promise<unknown>;
146
+ /**
147
+ * Reports available for Case
148
+ *
149
+ * @category Cases
150
+ * @param {number} caObjectId - The case object ID to get the report (print template) list for
151
+ * @return {Object} Returns Promise that represents a collection of Objects describing the reports (print templates) available for this case
152
+ */
153
+ getPrintTemplates(caObjectId: number): Promise<unknown>;
154
+ /**
155
+ * Print Case
156
+ *
157
+ * @category Cases
158
+ * @param {number} caObjectId - The case object ID to delete the map layer fields for.
159
+ * @param {string} fileName - the filename of the report from the getPrintTemplates method, but w/out the extension
160
+ * @return {Object} Returns Promise that represents a collection of Objects describing the case object map layer fields deleted
161
+ */
162
+ print(caObjectId: number, fileName: string, callback: any): Promise<unknown>;
142
163
  }
@@ -0,0 +1,327 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Briefcase = void 0;
4
+ var error_1 = require("./error");
5
+ var _ = require('lodash');
6
+ var Briefcase = /** @class */ (function () {
7
+ /**
8
+ * @hidden
9
+ */
10
+ function Briefcase(cw) {
11
+ this.cw = cw;
12
+ }
13
+ /**
14
+ * Create new case
15
+ *
16
+ * @category Cases
17
+ * @param {number} caseTypeId - The case Type ID
18
+ * @param {number} subTypeId - The case subType ID
19
+ * @param {Object} [options] - See /{subdirectory}/apidocs/#/data-type-info;dataType=CaObjectItemBase
20
+ * @return {Object} Returns Promise that represents an object describing the newly-created case
21
+ */
22
+ Briefcase.prototype.create = function (caseTypeId, subTypeId, options) {
23
+ var _this = this;
24
+ return new Promise(function (resolve, reject) {
25
+ var data_init = {
26
+ CaseTypeId: caseTypeId,
27
+ SubTypeId: subTypeId
28
+ };
29
+ var data = _.merge(data_init, options);
30
+ _this.cw.runRequest('Pll/Case/Create', data).then(function (r) {
31
+ resolve(r.Value);
32
+ }).catch(function (e) {
33
+ reject(e);
34
+ });
35
+ });
36
+ };
37
+ /**
38
+ * Create a child case
39
+ *
40
+ * @category Cases
41
+ * @param {number} busCaseId - The case Type ID
42
+ * @param {number} parentCaObjectId - The case subType ID
43
+ * @param {Object} [options] - See /{subdirectory}/apidocs/#/data-type-info;dataType=CaObjectItemBase
44
+ * @return {Object} Returns Promise that represents an object describing the newly-created case
45
+ */
46
+ Briefcase.prototype.createChild = function (busCaseId, parentCaObjectId, options) {
47
+ var _this = this;
48
+ return new Promise(function (resolve, reject) {
49
+ var data_init = {
50
+ BusCaseId: busCaseId,
51
+ ParentCaObjectId: parentCaObjectId
52
+ };
53
+ var data = _.merge(data_init, options);
54
+ _this.cw.runRequest('Pll/Case/CreateChild', data).then(function (r) {
55
+ resolve(r.Value);
56
+ }).catch(function (e) {
57
+ reject(e);
58
+ });
59
+ });
60
+ };
61
+ /**
62
+ * Create a case from a Service Request
63
+ *
64
+ * @category Cases
65
+ * @param {number} caseTypeId - The case Type ID
66
+ * @param {number} subTypeId - The case subType ID
67
+ * @param {number} requestId - The service request ID
68
+ * @param {Object} [options] - See /{subdirectory}/apidocs/#/data-type-info;dataType=CaObjectItemBase
69
+ * @return {Object} Returns Promise that represents an object describing the newly-created case
70
+ */
71
+ Briefcase.prototype.createFromRequest = function (caseTypeId, subTypeId, requestId, options) {
72
+ var _this = this;
73
+ return new Promise(function (resolve, reject) {
74
+ var data_init = {
75
+ CaseTypeId: caseTypeId,
76
+ SubTypeId: subTypeId,
77
+ ServiceRequestId: requestId
78
+ };
79
+ var data = _.merge(data_init, options);
80
+ _this.cw.runRequest('Pll/CaseObject/CreateCaseFromServiceRequest', data).then(function (r) {
81
+ resolve(r.Value);
82
+ }).catch(function (e) {
83
+ reject(e);
84
+ });
85
+ });
86
+ };
87
+ /**
88
+ * Update a case
89
+ *
90
+ * @category Cases
91
+ * @param {number} caObjectId - The case Object ID to update
92
+ * @param {Object} [options] - See /{subdirectory}/apidocs/#/data-type-info;dataType=CaObjectItemBase
93
+ * @return {Object} Returns Promise that represents an object describing the updated case
94
+ */
95
+ Briefcase.prototype.update = function (caObjectId, options) {
96
+ var _this = this;
97
+ return new Promise(function (resolve, reject) {
98
+ var data_init = {
99
+ CaObjectId: caObjectId
100
+ };
101
+ var data = _.merge(data_init, options);
102
+ _this.cw.runRequest('Pll/CaseObject/Update', data).then(function (r) {
103
+ resolve(r.Value);
104
+ }).catch(function (e) {
105
+ reject(e);
106
+ });
107
+ });
108
+ };
109
+ /**
110
+ * Get cases by IDs
111
+ *
112
+ * @category Cases
113
+ * @param {Array<number>} caObjectIds - The case Object ID to update
114
+ * @return {Object} Returns Promise that represents a collection of objects describing the cases
115
+ */
116
+ Briefcase.prototype.getByIds = function (caObjectIds) {
117
+ var _this = this;
118
+ return new Promise(function (resolve, reject) {
119
+ var data = {
120
+ CaObjectIds: caObjectIds
121
+ };
122
+ _this.cw.runRequest('Pll/CaseObject/ByIds', data).then(function (r) {
123
+ resolve(r.Value);
124
+ }).catch(function (e) {
125
+ reject(e);
126
+ });
127
+ });
128
+ };
129
+ /**
130
+ * Search for Cases. Include at least one of the search fields. A logical 'and' operation is applied for multiple search fields.
131
+ *
132
+ * @category Cases
133
+ * @param {Object} filters - The parameter(s) to search by
134
+ * @return {Object} Returns Promise that represents an Array of case Object IDs
135
+ */
136
+ Briefcase.prototype.search = function (filters) {
137
+ var _this = this;
138
+ return new Promise(function (resolve, reject) {
139
+ var data = filters;
140
+ _this.cw.runRequest('Pll/CaseObject/Search', data).then(function (r) {
141
+ resolve(r.Value);
142
+ }).catch(function (e) {
143
+ reject(e);
144
+ });
145
+ });
146
+ };
147
+ /**
148
+ * Move a Case point
149
+ *
150
+ * @category Cases
151
+ * @param {string} caObjectId
152
+ * @param {number} x
153
+ * @param {number} y
154
+ * @param {Object} projection - Should include at least WKT _or_ WKID attribute. Can also include VcsWKID attribute.
155
+ * @param {number} [z] - Optional Z coordinate
156
+ * @return {Object} Returns Promise that represents an object describing the updated GISPoint
157
+ */
158
+ Briefcase.prototype.move = function (caObjectId, x, y, projection, z) {
159
+ var _this = this;
160
+ return new Promise(function (resolve, reject) {
161
+ if (!_.has(projection, 'WKID') && !_.has(projection, 'WKT')) {
162
+ // Throw error
163
+ reject(new error_1.CWError(1, 'You must provide either the WKID or WKT for the x/y coordinates.', { 'projection': projection }));
164
+ }
165
+ var data_init = {
166
+ CaObjectId: caObjectId,
167
+ X: x,
168
+ Y: y
169
+ };
170
+ if (typeof (z) != 'undefined') {
171
+ _.set(data_init, 'Z', z);
172
+ }
173
+ var data = _.merge(data_init, projection);
174
+ _this.cw.runRequest('Pll/CaseObject/Move', data).then(function (r) {
175
+ resolve(r.Value);
176
+ }).catch(function (e) {
177
+ reject(e);
178
+ });
179
+ });
180
+ };
181
+ /**
182
+ * Delete case
183
+ *
184
+ * @category Cases
185
+ * @param {number} caObjectId - The case Object ID
186
+ * @return {Object} Returns Promise that represents an object describing the deleted case
187
+ */
188
+ Briefcase.prototype.delete = function (caObjectId) {
189
+ var _this = this;
190
+ return new Promise(function (resolve, reject) {
191
+ var data = {
192
+ CaObjectId: caObjectId
193
+ };
194
+ _this.cw.runRequest('Pll/CaseObject/DeleteCase', data).then(function (r) {
195
+ resolve(r.Value);
196
+ }).catch(function (e) {
197
+ reject(e);
198
+ });
199
+ });
200
+ };
201
+ /**
202
+ * Get Map Layer Fields
203
+ *
204
+ * @category Cases
205
+ * @param {number} caObjectId - The case object ID to get the map layer fields for.
206
+ * @return {Object} Returns Promise that represents a collection of Objects describing the case object map layer fields
207
+ */
208
+ Briefcase.prototype.getMLFs = function (caObjectId) {
209
+ var _this = this;
210
+ return new Promise(function (resolve, reject) {
211
+ var data = {
212
+ CaObjectId: caObjectId
213
+ };
214
+ var path = 'Ams/TemplateMapLayer/CaseInstanceMapLayersByCaObjectId';
215
+ _this.cw.runRequest(path, data).then(function (r) {
216
+ resolve(r.Value);
217
+ }).catch(function (e) {
218
+ reject(e);
219
+ });
220
+ });
221
+ };
222
+ /**
223
+ * Update Map Layer Fields
224
+ *
225
+ * @category Cases
226
+ * @param {number} caObjectId - The case object ID to get the map layer fields for.
227
+ * @param {number} x
228
+ * @param {number} y
229
+ * @param {number} domainId - The domain ID for the case in question
230
+ * @param {number} [z] - Optional Z coordinate
231
+ * @return {Object} Returns Promise that represents a collection of Objects describing the case object map layer fields
232
+ */
233
+ Briefcase.prototype.updateMLFs = function (caObjectId, x, y, domainId, z) {
234
+ var _this = this;
235
+ return new Promise(function (resolve, reject) {
236
+ var data = {
237
+ CaObjectId: caObjectId
238
+ };
239
+ var path = 'Ams/TemplateMapLayer/UpdateCaseInstanceMapLayers';
240
+ if (_.isNumber(x)) {
241
+ _.set(data, 'X', x);
242
+ }
243
+ if (_.isNumber(y)) {
244
+ _.set(data, 'Y', y);
245
+ }
246
+ if (_.isNumber(z)) {
247
+ _.set(data, 'Z', z);
248
+ }
249
+ if (_.isNumber(domainId)) {
250
+ _.set(data, 'DomainId', domainId);
251
+ }
252
+ _this.cw.runRequest(path, data).then(function (r) {
253
+ resolve(r.Value);
254
+ }).catch(function (e) {
255
+ reject(e);
256
+ });
257
+ });
258
+ };
259
+ /**
260
+ * Delete Map Layer Fields
261
+ *
262
+ * @category Cases
263
+ * @param {number} caObjectId - The case object ID to delete the map layer fields for.
264
+ * @return {Object} Returns Promise that represents a collection of Objects describing the case object map layer fields deleted
265
+ */
266
+ Briefcase.prototype.deleteMLFs = function (caObjectId) {
267
+ var _this = this;
268
+ return new Promise(function (resolve, reject) {
269
+ var data = {
270
+ CaObjectId: caObjectId
271
+ };
272
+ var path = 'Ams/TemplateMapLayer/DeleteCaseInstanceMapLayersByCaObjectId';
273
+ _this.cw.runRequest(path, data).then(function (r) {
274
+ resolve(r.Value);
275
+ }).catch(function (e) {
276
+ reject(e);
277
+ });
278
+ });
279
+ };
280
+ /**
281
+ * Reports available for Case
282
+ *
283
+ * @category Cases
284
+ * @param {number} caObjectId - The case object ID to get the report (print template) list for
285
+ * @return {Object} Returns Promise that represents a collection of Objects describing the reports (print templates) available for this case
286
+ */
287
+ Briefcase.prototype.getPrintTemplates = function (caObjectId) {
288
+ var _this = this;
289
+ return new Promise(function (resolve, reject) {
290
+ var data = {
291
+ CaObjectId: caObjectId
292
+ };
293
+ var path = 'Pll/BusinessCaseReports/ByCaObjectId';
294
+ _this.cw.runRequest(path, data).then(function (r) {
295
+ resolve(r.Value);
296
+ }).catch(function (e) {
297
+ reject(e);
298
+ });
299
+ });
300
+ };
301
+ /**
302
+ * Print Case
303
+ *
304
+ * @category Cases
305
+ * @param {number} caObjectId - The case object ID to delete the map layer fields for.
306
+ * @param {string} fileName - the filename of the report from the getPrintTemplates method, but w/out the extension
307
+ * @return {Object} Returns Promise that represents a collection of Objects describing the case object map layer fields deleted
308
+ */
309
+ Briefcase.prototype.print = function (caObjectId, fileName) {
310
+ var _this = this;
311
+ return new Promise(function (resolve, reject) {
312
+ var data = {
313
+ CaObjectId: caObjectId,
314
+ FileName: fileName
315
+ };
316
+ var path = 'Pll/BusinessCaseReports/Download';
317
+ // TODO: test the Filename to make sure it's in the File list from getPrintTemplates (or let the API just error?)
318
+ _this.cw.runRequest(path, data).then(function (r) {
319
+ resolve(r.Value);
320
+ }).catch(function (e) {
321
+ reject(e);
322
+ });
323
+ });
324
+ };
325
+ return Briefcase;
326
+ }());
327
+ exports.Briefcase = Briefcase;