@ndustrial/contxt-sdk 4.3.5 → 5.1.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.
- package/.gitattributes +1 -0
- package/.nvmrc +1 -1
- package/CHANGELOG.md +8 -0
- package/docs/Facilities.md +0 -144
- package/docs/FacilityGroupings.md +0 -160
- package/docs/Nionic.md +63 -0
- package/docs/README.md +3 -29
- package/docs/Typedefs.md +0 -101
- package/esm/config/audiences.js +13 -13
- package/esm/config/audiences.js.map +1 -1
- package/esm/index.js +4 -6
- package/esm/index.js.map +1 -1
- package/esm/nionic/index.js +126 -0
- package/esm/nionic/index.js.map +1 -0
- package/lib/config/audiences.js +13 -13
- package/lib/config/audiences.js.map +1 -1
- package/lib/index.js +10 -15
- package/lib/index.js.map +1 -1
- package/lib/nionic/index.js +130 -0
- package/lib/nionic/index.js.map +1 -0
- package/meta.yaml +11 -0
- package/package.json +9 -10
- package/src/bus/index.spec.js +3 -2
- package/src/bus/webSocketConnection.spec.js +31 -31
- package/src/config/audiences.js +13 -13
- package/src/config/index.spec.js +6 -6
- package/src/coordinator/applications.spec.js +8 -8
- package/src/coordinator/consent.spec.js +1 -1
- package/src/coordinator/edgeNodes.spec.js +3 -3
- package/src/coordinator/organizations.spec.js +4 -4
- package/src/coordinator/permissions.spec.js +4 -4
- package/src/coordinator/roles.spec.js +3 -3
- package/src/coordinator/users.spec.js +14 -15
- package/src/events/index.spec.js +16 -16
- package/src/files/index.spec.js +7 -7
- package/src/index.js +4 -6
- package/src/index.spec.js +8 -22
- package/src/iot/feeds.spec.js +4 -4
- package/src/iot/fieldCategories.spec.js +4 -4
- package/src/iot/fieldGroupings.spec.js +5 -5
- package/src/iot/outputs.spec.js +6 -6
- package/src/nionic/index.js +151 -0
- package/src/request.spec.js +3 -3
- package/src/sessionTypes/auth0WebAuth.spec.js +2 -2
- package/src/sessionTypes/index.spec.js +3 -3
- package/src/sessionTypes/machineAuth.spec.js +3 -3
- package/src/sessionTypes/passwordGrantAuth.spec.js +1 -1
- package/src/utils/iot/formatOutputFieldDataFromServer.spec.js +6 -6
- package/src/utils/iot/parseOutputFieldNextPageUrlMetadata.spec.js +2 -2
- package/src/utils/pagination/formatPaginatedDataFromServer.spec.js +2 -2
- package/src/utils/url/stringifyParams.spec.js +2 -3
- package/support/fixtures/factories/IOSDevice.js +3 -3
- package/support/fixtures/factories/applicationGrouping.js +4 -4
- package/support/fixtures/factories/applicationModule.js +2 -2
- package/support/fixtures/factories/asset.js +1 -1
- package/support/fixtures/factories/assetAttribute.js +2 -2
- package/support/fixtures/factories/assetAttributeValue.js +2 -2
- package/support/fixtures/factories/assetMetric.js +1 -1
- package/support/fixtures/factories/assetMetricValue.js +3 -3
- package/support/fixtures/factories/assetMetricValueCompact.js +2 -2
- package/support/fixtures/factories/assetType.js +1 -1
- package/support/fixtures/factories/authResults.js +3 -3
- package/support/fixtures/factories/channel.js +1 -1
- package/support/fixtures/factories/contxtApplication.js +5 -5
- package/support/fixtures/factories/contxtOrganization.js +2 -2
- package/support/fixtures/factories/contxtOrganizationFeaturedApplication.js +3 -3
- package/support/fixtures/factories/contxtProject.js +2 -2
- package/support/fixtures/factories/contxtProjectEnvironment.js +2 -2
- package/support/fixtures/factories/contxtRole.js +3 -3
- package/support/fixtures/factories/contxtRoleApplication.js +1 -1
- package/support/fixtures/factories/contxtRoleProjectEnvironment.js +1 -1
- package/support/fixtures/factories/contxtUser.js +2 -2
- package/support/fixtures/factories/contxtUserApplication.js +1 -1
- package/support/fixtures/factories/contxtUserFavoriteApplication.js +2 -2
- package/support/fixtures/factories/contxtUserPermissions.js +5 -5
- package/support/fixtures/factories/contxtUserProjectEnvironment.js +1 -1
- package/support/fixtures/factories/contxtUserRole.js +2 -2
- package/support/fixtures/factories/costCenter.js +2 -2
- package/support/fixtures/factories/costCenterFacility.js +3 -3
- package/support/fixtures/factories/edgeNode.js +1 -1
- package/support/fixtures/factories/event.js +5 -5
- package/support/fixtures/factories/eventType.js +4 -4
- package/support/fixtures/factories/eventUser.js +5 -5
- package/support/fixtures/factories/facility.js +4 -4
- package/support/fixtures/factories/facilityGrouping.js +3 -3
- package/support/fixtures/factories/facilityGroupingFacility.js +3 -3
- package/support/fixtures/factories/facilityInfo.js +2 -2
- package/support/fixtures/factories/facilityTag.js +1 -1
- package/support/fixtures/factories/feedStatus.js +1 -1
- package/support/fixtures/factories/feedType.js +1 -1
- package/support/fixtures/factories/feeds.js +5 -5
- package/support/fixtures/factories/fieldCategory.js +3 -3
- package/support/fixtures/factories/fieldGrouping.js +4 -4
- package/support/fixtures/factories/fieldGroupingField.js +3 -3
- package/support/fixtures/factories/fieldGroupingStatus.js +1 -1
- package/support/fixtures/factories/file.js +1 -1
- package/support/fixtures/factories/fileUploadInfo.js +1 -1
- package/support/fixtures/factories/organization.js +1 -1
- package/support/fixtures/factories/outputField.js +10 -10
- package/support/fixtures/factories/outputFieldData.js +1 -1
- package/support/fixtures/factories/owner.js +2 -2
- package/support/fixtures/factories/paginationMetadata.js +2 -2
- package/support/fixtures/factories/triggeredEvent.js +4 -4
- package/support/fixtures/factories/userEventSubscription.js +1 -1
- package/support/fixtures/factories/userMobileNumber.js +1 -1
- package/support/fixtures/factories/userPermissionsMap.js +2 -2
- package/.huskyrc.js +0 -11
- package/.nycrc +0 -12
- package/esm/assets/assetAttributes.js +0 -574
- package/esm/assets/assetAttributes.js.map +0 -1
- package/esm/assets/assetMetrics.js +0 -690
- package/esm/assets/assetMetrics.js.map +0 -1
- package/esm/assets/assetTypes.js +0 -273
- package/esm/assets/assetTypes.js.map +0 -1
- package/esm/assets/index.js +0 -283
- package/esm/assets/index.js.map +0 -1
- package/esm/facilities/costCenters.js +0 -306
- package/esm/facilities/costCenters.js.map +0 -1
- package/esm/facilities/groupings.js +0 -323
- package/esm/facilities/groupings.js.map +0 -1
- package/esm/facilities/index.js +0 -343
- package/esm/facilities/index.js.map +0 -1
- package/esm/health/index.js +0 -229
- package/esm/health/index.js.map +0 -1
- package/esm/utils/facilities/formatFacilityWithInfoFromServer.js +0 -65
- package/esm/utils/facilities/formatFacilityWithInfoFromServer.js.map +0 -1
- package/esm/utils/facilities/index.js +0 -4
- package/esm/utils/facilities/index.js.map +0 -1
- package/lib/assets/assetAttributes.js +0 -588
- package/lib/assets/assetAttributes.js.map +0 -1
- package/lib/assets/assetMetrics.js +0 -705
- package/lib/assets/assetMetrics.js.map +0 -1
- package/lib/assets/assetTypes.js +0 -287
- package/lib/assets/assetTypes.js.map +0 -1
- package/lib/assets/index.js +0 -302
- package/lib/assets/index.js.map +0 -1
- package/lib/facilities/costCenters.js +0 -316
- package/lib/facilities/costCenters.js.map +0 -1
- package/lib/facilities/groupings.js +0 -333
- package/lib/facilities/groupings.js.map +0 -1
- package/lib/facilities/index.js +0 -360
- package/lib/facilities/index.js.map +0 -1
- package/lib/health/index.js +0 -232
- package/lib/health/index.js.map +0 -1
- package/lib/utils/facilities/formatFacilityWithInfoFromServer.js +0 -71
- package/lib/utils/facilities/formatFacilityWithInfoFromServer.js.map +0 -1
- package/lib/utils/facilities/index.js +0 -15
- package/lib/utils/facilities/index.js.map +0 -1
- package/src/assets/assetAttributes.js +0 -619
- package/src/assets/assetAttributes.spec.js +0 -1143
- package/src/assets/assetMetrics.js +0 -736
- package/src/assets/assetMetrics.spec.js +0 -1180
- package/src/assets/assetTypes.js +0 -260
- package/src/assets/assetTypes.spec.js +0 -556
- package/src/assets/index.js +0 -271
- package/src/assets/index.spec.js +0 -515
- package/src/facilities/costCenters.js +0 -295
- package/src/facilities/costCenters.spec.js +0 -529
- package/src/facilities/groupings.js +0 -320
- package/src/facilities/groupings.spec.js +0 -567
- package/src/facilities/index.js +0 -343
- package/src/facilities/index.spec.js +0 -551
- package/src/health/index.js +0 -200
- package/src/health/index.spec.js +0 -501
- package/src/utils/facilities/formatFacilityWithInfoFromServer.js +0 -62
- package/src/utils/facilities/formatFacilityWithInfoFromServer.spec.js +0 -73
- package/src/utils/facilities/index.js +0 -3
|
@@ -1,320 +0,0 @@
|
|
|
1
|
-
import isPlainObject from 'lodash.isplainobject';
|
|
2
|
-
import { toCamelCase, toSnakeCase } from '../utils/objects';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @typedef {Object} FacilityGrouping
|
|
6
|
-
* @param {string} createdAt ISO 8601 Extended Format date/time string
|
|
7
|
-
* @param {string} [description]
|
|
8
|
-
* @param {Facility[]} [facilities]
|
|
9
|
-
* @param {string} id UUID
|
|
10
|
-
* @param {boolean} isPrivate
|
|
11
|
-
* @param {string} name
|
|
12
|
-
* @param {string} organizationId UUID
|
|
13
|
-
* @param {string} ownerId Auth0 identifer of the user
|
|
14
|
-
* @param {string} [parentGroupingId] UUID
|
|
15
|
-
* @param {string} updatedAt ISO 8601 Extended Format date/time string
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @typedef {Object} FacilityGroupingFacility
|
|
20
|
-
* @param {string} createdAt ISO 8601 Extended Format date/time string
|
|
21
|
-
* @param {string} facilityGroupingId UUID
|
|
22
|
-
* @param {number} facilityId
|
|
23
|
-
* @param {string} id UUID
|
|
24
|
-
* @param {string} updatedAt ISO 8601 Extended Format date/time string
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Module that provides access to facility groupings, and helps manage
|
|
29
|
-
* the relationship between those groupings and facilities
|
|
30
|
-
*
|
|
31
|
-
* @typicalname contxtSdk.facilities.groupings
|
|
32
|
-
*/
|
|
33
|
-
class FacilityGroupings {
|
|
34
|
-
/**
|
|
35
|
-
* @param {Object} sdk An instance of the SDK so the module can communicate with other modules
|
|
36
|
-
* @param {Object} request An instance of the request module tied to this module's audience.
|
|
37
|
-
* @param {string} baseUrl The base URL provided by the parent module
|
|
38
|
-
*/
|
|
39
|
-
constructor(sdk, request, baseUrl) {
|
|
40
|
-
this._baseUrl = baseUrl;
|
|
41
|
-
this._request = request;
|
|
42
|
-
this._sdk = sdk;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Adds a facility to a facility grouping
|
|
47
|
-
*
|
|
48
|
-
* API Endpoint: '/groupings/:facilityGroupingId/facilities/:facilityId'
|
|
49
|
-
* Method: POST
|
|
50
|
-
*
|
|
51
|
-
* @param {string} facilityGroupingId UUID corresponding with a facility grouping
|
|
52
|
-
* @param {number} facilityId
|
|
53
|
-
*
|
|
54
|
-
* @returns {Promise}
|
|
55
|
-
* @fulfill {FacilityGroupingFacility} Information about the new facility/grouping relationship
|
|
56
|
-
* @reject {Error}
|
|
57
|
-
*
|
|
58
|
-
* @example
|
|
59
|
-
* contxtSdk.facilities.groupings
|
|
60
|
-
* .addFacility('b3dbaae3-25dd-475b-80dc-66296630a8d0', 4)
|
|
61
|
-
* .then((grouping) => console.log(grouping))
|
|
62
|
-
* .catch((err) => console.log(err));
|
|
63
|
-
*/
|
|
64
|
-
addFacility(facilityGroupingId, facilityId) {
|
|
65
|
-
let errorMsg;
|
|
66
|
-
|
|
67
|
-
if (!facilityGroupingId) {
|
|
68
|
-
errorMsg =
|
|
69
|
-
'A facilityGroupingId is required to create a relationship between a facility grouping and a facility.';
|
|
70
|
-
} else if (!facilityId) {
|
|
71
|
-
errorMsg =
|
|
72
|
-
'A facilityId is required to create a relationship between a facility grouping and a facility.';
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
if (errorMsg) {
|
|
76
|
-
return Promise.reject(new Error(errorMsg));
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return this._request
|
|
80
|
-
.post(
|
|
81
|
-
`${
|
|
82
|
-
this._baseUrl
|
|
83
|
-
}/groupings/${facilityGroupingId}/facility/${facilityId}`
|
|
84
|
-
)
|
|
85
|
-
.then((groupingFacility) => toCamelCase(groupingFacility));
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Creates a new facility grouping
|
|
90
|
-
*
|
|
91
|
-
* API Endpoint: '/groupings'
|
|
92
|
-
* Method: POST
|
|
93
|
-
*
|
|
94
|
-
* @param {Object} facilityGrouping
|
|
95
|
-
* @param {string} [facilityGrouping.description]
|
|
96
|
-
* @param {boolean} [facilityGrouping.isPrivate = false]
|
|
97
|
-
* @param {string} facilityGrouping.name
|
|
98
|
-
* @param {string} facilityGrouping.organizationId UUID
|
|
99
|
-
* @param {string} [facilityGrouping.parentGroupingId] UUID
|
|
100
|
-
*
|
|
101
|
-
* @returns {Promise}
|
|
102
|
-
* @fulfill {FacilityGrouping} Information about the new facility grouping
|
|
103
|
-
* @reject {Error}
|
|
104
|
-
*
|
|
105
|
-
* @example
|
|
106
|
-
* contxtSdk.facilities.groupings
|
|
107
|
-
* .create({
|
|
108
|
-
* description: 'US States of CT, MA, ME, NH, RI, VT',
|
|
109
|
-
* isPrivate: false,
|
|
110
|
-
* name: 'New England, USA',
|
|
111
|
-
* organizationId: '61f5fe1d-d202-4ae7-af76-8f37f5bbeec5',
|
|
112
|
-
* parentGroupingId: 'e9f8f89c-609c-4c83-8ebc-cea928af661e'
|
|
113
|
-
* })
|
|
114
|
-
* .then((grouping) => console.log(grouping))
|
|
115
|
-
* .catch((err) => console.log(err));
|
|
116
|
-
*/
|
|
117
|
-
create(grouping = {}) {
|
|
118
|
-
const requiredFields = ['name', 'organizationId'];
|
|
119
|
-
|
|
120
|
-
for (let i = 0; requiredFields.length > i; i++) {
|
|
121
|
-
const field = requiredFields[i];
|
|
122
|
-
|
|
123
|
-
if (!grouping[field]) {
|
|
124
|
-
return Promise.reject(
|
|
125
|
-
new Error(`A ${field} is required to create a new facility grouping.`)
|
|
126
|
-
);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
return this._request
|
|
131
|
-
.post(`${this._baseUrl}/groupings`, toSnakeCase(grouping))
|
|
132
|
-
.then((grouping) => toCamelCase(grouping));
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Delete a facility groupings
|
|
137
|
-
*
|
|
138
|
-
* API Endpoint: '/groupings/:facilityGroupingId'
|
|
139
|
-
* Method: DELETE
|
|
140
|
-
*
|
|
141
|
-
* @param {string} facilityGroupingId The id of the facility grouping (formatted as a UUID)
|
|
142
|
-
*
|
|
143
|
-
* @returns {Promise}
|
|
144
|
-
* @fulfill {undefined}
|
|
145
|
-
* @reject {Error}
|
|
146
|
-
*
|
|
147
|
-
* @example
|
|
148
|
-
* contxtSdk.facilities.groupings.delete(
|
|
149
|
-
* 'e4fec739-56aa-4b50-8dab-e9d6b9c91a5d'
|
|
150
|
-
* );
|
|
151
|
-
*/
|
|
152
|
-
delete(facilityGroupingId) {
|
|
153
|
-
if (!facilityGroupingId) {
|
|
154
|
-
return Promise.reject(
|
|
155
|
-
new Error(
|
|
156
|
-
'A facility grouping id is required for deleting a facility grouping.'
|
|
157
|
-
)
|
|
158
|
-
);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
return this._request.delete(
|
|
162
|
-
`${this._baseUrl}/groupings/${facilityGroupingId}`
|
|
163
|
-
);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* Get a listing of all facility groupings available to a user. Includes public groupings across
|
|
168
|
-
* any organization the user has access to and the user's private groupings.
|
|
169
|
-
*
|
|
170
|
-
* API Endpoint: '/groupings'
|
|
171
|
-
* Method: GET
|
|
172
|
-
*
|
|
173
|
-
* @returns {Promise}
|
|
174
|
-
* @fulfill {FacilityGrouping[]}
|
|
175
|
-
* @reject {Error}
|
|
176
|
-
*
|
|
177
|
-
* @example
|
|
178
|
-
* contxtSdk.facilites.groupings
|
|
179
|
-
* .getAll()
|
|
180
|
-
* .then((groupings) => console.log(groupings))
|
|
181
|
-
* .catch((err) => console.log(err));
|
|
182
|
-
*/
|
|
183
|
-
getAll() {
|
|
184
|
-
return this._request
|
|
185
|
-
.get(`${this._baseUrl}/groupings`)
|
|
186
|
-
.then((groupings) => toCamelCase(groupings));
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* Get a listing of all facility groupings for an organization. Includes public groupings
|
|
191
|
-
* across that specific organization and the user's private groupings for that organization.
|
|
192
|
-
*
|
|
193
|
-
* API Endpoint: '/organizations/:organizationId/groupings'
|
|
194
|
-
* Method: GET
|
|
195
|
-
*
|
|
196
|
-
* @param {string} organizationId UUID corresponding with an organization
|
|
197
|
-
*
|
|
198
|
-
* @returns {Promise}
|
|
199
|
-
* @fulfill {FacilityGrouping[]}
|
|
200
|
-
* @reject {Error}
|
|
201
|
-
*
|
|
202
|
-
* @example
|
|
203
|
-
* contxtSdk.facilites.groupings
|
|
204
|
-
* .getAllByOrganizationId('349dbd36-5dca-4a10-b54d-d0f71c3c8709')
|
|
205
|
-
* .then((groupings) => console.log(groupings))
|
|
206
|
-
* .catch((err) => console.log(err));
|
|
207
|
-
*/
|
|
208
|
-
getAllByOrganizationId(organizationId) {
|
|
209
|
-
if (!organizationId) {
|
|
210
|
-
return Promise.reject(
|
|
211
|
-
new Error(
|
|
212
|
-
"An organization id is required for getting a list of an organization's facility groupings"
|
|
213
|
-
)
|
|
214
|
-
);
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
return this._request
|
|
218
|
-
.get(`${this._baseUrl}/organizations/${organizationId}/groupings`)
|
|
219
|
-
.then((groupings) => toCamelCase(groupings));
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* Removes a facility from a facility grouping
|
|
224
|
-
*
|
|
225
|
-
* API Endpoint: '/groupings/:facilityGroupingId/facilities/:facilityId'
|
|
226
|
-
* Method: DELETE
|
|
227
|
-
*
|
|
228
|
-
* @param {string} facilityGroupingId UUID corresponding with a facility grouping
|
|
229
|
-
* @param {number} facilityId
|
|
230
|
-
*
|
|
231
|
-
* @returns {Promise}
|
|
232
|
-
* @reject {Error}
|
|
233
|
-
*
|
|
234
|
-
* @example
|
|
235
|
-
* contxtSdk.facilities.groupings
|
|
236
|
-
* .removeFacility('b3dbaae3-25dd-475b-80dc-66296630a8d0', 4)
|
|
237
|
-
* .catch((err) => console.log(err));
|
|
238
|
-
*/
|
|
239
|
-
removeFacility(facilityGroupingId, facilityId) {
|
|
240
|
-
let errorMsg;
|
|
241
|
-
|
|
242
|
-
if (!facilityGroupingId) {
|
|
243
|
-
errorMsg =
|
|
244
|
-
'A facilityGroupingId is required to remove a relationship between a facility grouping and a facility.';
|
|
245
|
-
} else if (!facilityId) {
|
|
246
|
-
errorMsg =
|
|
247
|
-
'A facilityId is required to remove a relationship between a facility grouping and a facility.';
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
if (errorMsg) {
|
|
251
|
-
return Promise.reject(new Error(errorMsg));
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
return this._request.delete(
|
|
255
|
-
`${this._baseUrl}/groupings/${facilityGroupingId}/facility/${facilityId}`
|
|
256
|
-
);
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* Updates an existing facility grouping
|
|
261
|
-
*
|
|
262
|
-
* API Endpoint: '/groupings/:facilityGroupingId'
|
|
263
|
-
* Method: PUT
|
|
264
|
-
*
|
|
265
|
-
* @param {String} facilityGroupingId
|
|
266
|
-
* @param {Object} update
|
|
267
|
-
* @param {string} [update.description]
|
|
268
|
-
* @param {boolean} [update.isPrivate]
|
|
269
|
-
* @param {string} [update.name]
|
|
270
|
-
* @param {string} [update.parentGroupingId] UUID corresponding with another facility grouping
|
|
271
|
-
*
|
|
272
|
-
* @returns {Promise}
|
|
273
|
-
* @fulfill {FacilityGrouping} Information about the updated facility grouping
|
|
274
|
-
* @reject {Error}
|
|
275
|
-
*
|
|
276
|
-
* @example
|
|
277
|
-
* contxtSdk.facilities.groupings
|
|
278
|
-
* .update('b3dbaae3-25dd-475b-80dc-66296630a8d0', {
|
|
279
|
-
* description: 'US States of CT, MA, ME, NH, RI, VT',
|
|
280
|
-
* isPrivate: false,
|
|
281
|
-
* name: 'New England, USA',
|
|
282
|
-
* parentGroupingId: 'e9f8f89c-609c-4c83-8ebc-cea928af661e'
|
|
283
|
-
* })
|
|
284
|
-
* .then((grouping) => console.log(grouping))
|
|
285
|
-
* .catch((err) => console.log(err));
|
|
286
|
-
*/
|
|
287
|
-
update(facilityGroupingId, update) {
|
|
288
|
-
if (!facilityGroupingId) {
|
|
289
|
-
return Promise.reject(
|
|
290
|
-
new Error(
|
|
291
|
-
'A facility grouping id is required to update a facility grouping.'
|
|
292
|
-
)
|
|
293
|
-
);
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
if (!update) {
|
|
297
|
-
return Promise.reject(
|
|
298
|
-
new Error('An update is required to update a facility grouping')
|
|
299
|
-
);
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
if (!isPlainObject(update)) {
|
|
303
|
-
return Promise.reject(
|
|
304
|
-
new Error(
|
|
305
|
-
'The facility grouping update must be a well-formed object with the data you wish to update.'
|
|
306
|
-
)
|
|
307
|
-
);
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
const formattedUpdate = toSnakeCase(update, {
|
|
311
|
-
excludeKeys: ['id', 'organizationId', 'ownerId']
|
|
312
|
-
});
|
|
313
|
-
|
|
314
|
-
return this._request
|
|
315
|
-
.put(`${this._baseUrl}/groupings/${facilityGroupingId}`, formattedUpdate)
|
|
316
|
-
.then((grouping) => toCamelCase(grouping));
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
export default FacilityGroupings;
|