@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,705 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
8
|
-
|
|
9
|
-
var _lodash = require('lodash.has');
|
|
10
|
-
|
|
11
|
-
var _lodash2 = _interopRequireDefault(_lodash);
|
|
12
|
-
|
|
13
|
-
var _lodash3 = require('lodash.isplainobject');
|
|
14
|
-
|
|
15
|
-
var _lodash4 = _interopRequireDefault(_lodash3);
|
|
16
|
-
|
|
17
|
-
var _objects = require('../utils/objects');
|
|
18
|
-
|
|
19
|
-
var _url = require('../utils/url');
|
|
20
|
-
|
|
21
|
-
var _pagination = require('../utils/pagination');
|
|
22
|
-
|
|
23
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
24
|
-
|
|
25
|
-
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
|
26
|
-
|
|
27
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* @typedef {Object} AssetMetric
|
|
31
|
-
* @property {string} assetTypeId UUID corresponding with the asset type
|
|
32
|
-
* @property {string} createdAt ISO 8601 Extended Format date/time string
|
|
33
|
-
* @property {string} description
|
|
34
|
-
* @property {string} id UUID
|
|
35
|
-
* @property {string} label
|
|
36
|
-
* @property {string} organizationId UUID corresponding with the organization
|
|
37
|
-
* @property {string} timeInterval Options are "hourly", "daily", "weekly", "monthly", "yearly"
|
|
38
|
-
* @property {string} [units]
|
|
39
|
-
* @property {string} updatedAt ISO 8601 Extended Format date/time string
|
|
40
|
-
*/
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* @typedef {Object} AssetMetricsFromServer
|
|
44
|
-
* @property {Object} _metadata Metadata about the pagination settings
|
|
45
|
-
* @property {number} _metadata.offset Offset of records in subsequent queries
|
|
46
|
-
* @property {number} _metadata.totalRecords Total number of asset types found
|
|
47
|
-
* @property {AssetMetric[]} records
|
|
48
|
-
*/
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* @typedef {Object} AssetMetricValue
|
|
52
|
-
* @property {string} assetId UUID corresponding to the asset
|
|
53
|
-
* @property {string} assetMetricId UUID corresponding to the asset metric
|
|
54
|
-
* @property {string} createdAt ISO 8601 Extended Format date/time string
|
|
55
|
-
* @property {string} effectiveEndDate ISO 8601 Extended Format date/time string
|
|
56
|
-
* @property {string} effectiveStartDate ISO 8601 Extended Format date/time string
|
|
57
|
-
* @property {string} id UUID
|
|
58
|
-
* @property {string} notes
|
|
59
|
-
* @property {string} updatedAt ISO 8601 Extended Format date/time string
|
|
60
|
-
* @property {string} value
|
|
61
|
-
* @property {boolean} isEstimated Whether the value is an estimation or a true reading
|
|
62
|
-
*/
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* @typedef {Object} AssetMetricValuesFromServer
|
|
66
|
-
* @property {Object} _metadata Metadata about the pagination settings
|
|
67
|
-
* @property {number} _metadata.offset Offset of records in subsequent queries
|
|
68
|
-
* @property {number} _metadata.totalRecords Total number of asset types found
|
|
69
|
-
* @property {AssetMetricValue[]} records
|
|
70
|
-
*/
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* @typedef {Object} AssetMetricValueCompact
|
|
74
|
-
* @property {string} id the UUID corresponding to the asset metric value id
|
|
75
|
-
* @property {string} value
|
|
76
|
-
* @property {boolean} is_estimated
|
|
77
|
-
* @property {string} effectiveEndDate ISO 8601 Extended Format date/time string
|
|
78
|
-
* @property {string} effectiveStartDate ISO 8601 Extended Format date/time string
|
|
79
|
-
*/
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* @typedef {Object.<AssetMetric.label, AssetMetricValueCompact[]>} AssetMetricsKeyedByMetricId
|
|
83
|
-
*/
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* An object with asset ids as keys to another object with asset metric labels as keys.
|
|
87
|
-
* At this final level the object contains arrays of {@link AssetMetricValueCompact}
|
|
88
|
-
* @typedef {Object.<Asset.id, AssetMetricsKeyedByMetricId>} AssetMetricValuesByAssetIdMetricId
|
|
89
|
-
* @example
|
|
90
|
-
* {
|
|
91
|
-
* "b47e45af-3e18-408a-8070-008f9e6d7b42" : {
|
|
92
|
-
* "facility_daily_cuft": [
|
|
93
|
-
* {
|
|
94
|
-
* "id": "cf7e45af-3e18-408a-8070-008f9e6d7b3j",
|
|
95
|
-
* "value": 10,
|
|
96
|
-
* "isEstimated": false,
|
|
97
|
-
* "effectiveEndDate": "2018-07-10T11:04:24.631Z",
|
|
98
|
-
* "effectiveStartDate" "2018-07-10T11:04:24.631Z"
|
|
99
|
-
* }
|
|
100
|
-
* ]
|
|
101
|
-
* }
|
|
102
|
-
* }
|
|
103
|
-
*/
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Module that provides access to, and the manipulation of, information about different asset metrics
|
|
107
|
-
*
|
|
108
|
-
* @typicalname contxtSdk.assets.metrics
|
|
109
|
-
*/
|
|
110
|
-
var AssetMetrics = function () {
|
|
111
|
-
/**
|
|
112
|
-
* @param {Object} sdk An instance of the SDK so the module can communicate with other modules.
|
|
113
|
-
* @param {Object} request An instance of the request module tied to this module's audience.
|
|
114
|
-
* @param {string} baseUrl The base URL provided by the parent module
|
|
115
|
-
*/
|
|
116
|
-
function AssetMetrics(sdk, request, baseUrl) {
|
|
117
|
-
_classCallCheck(this, AssetMetrics);
|
|
118
|
-
|
|
119
|
-
this._baseUrl = baseUrl;
|
|
120
|
-
this._request = request;
|
|
121
|
-
this._sdk = sdk;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Creates a new asset metric
|
|
126
|
-
*
|
|
127
|
-
* API Endpoint: '/assets/types/:assetTypeId/metrics'
|
|
128
|
-
* Method: POST
|
|
129
|
-
*
|
|
130
|
-
* @param {string} assetTypeId The UUID formatted ID of the asset type
|
|
131
|
-
* @param {Object} assetMetric
|
|
132
|
-
* @param {string} assetMetric.description
|
|
133
|
-
* @param {string} assetMetric.label
|
|
134
|
-
* @param {string} assetMetric.organizationId Organization ID (UUID) to which the metric belongs
|
|
135
|
-
* @param {string} assetMetric.timeInterval Options are "hourly", "daily", "weekly", "monthly", "yearly"
|
|
136
|
-
* @param {string} [assetMetric.units] Units of the metric
|
|
137
|
-
*
|
|
138
|
-
* @returns {Promise}
|
|
139
|
-
* @fulfill {AssetMetric} Information about the new asset metric
|
|
140
|
-
* @reject {Error}
|
|
141
|
-
*
|
|
142
|
-
* @example
|
|
143
|
-
* contxtSdk.assets.metrics
|
|
144
|
-
* .create('4f0e51c6-728b-4892-9863-6d002e61204d', {
|
|
145
|
-
* description: 'Number of injuries which occur in the facility each month',
|
|
146
|
-
* label: 'Facility Injuries',
|
|
147
|
-
* organizationId: 'b47e45af-3e18-408a-8070-008f9e6d7b42',
|
|
148
|
-
* timeInterval: 'monthly',
|
|
149
|
-
* units: 'injuries'
|
|
150
|
-
* })
|
|
151
|
-
* .then((assetMetric) => console.log(assetMetric))
|
|
152
|
-
* .catch((err) => console.log(err));
|
|
153
|
-
*/
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
_createClass(AssetMetrics, [{
|
|
157
|
-
key: 'create',
|
|
158
|
-
value: function create(assetTypeId) {
|
|
159
|
-
var assetMetric = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
160
|
-
|
|
161
|
-
if (!assetTypeId) {
|
|
162
|
-
return Promise.reject(new Error('An asset type ID is required to create an asset metric.'));
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
var hasFieldFns = {
|
|
166
|
-
default: function _default(object, key) {
|
|
167
|
-
return !!object[key];
|
|
168
|
-
},
|
|
169
|
-
organizationId: function organizationId(object, key) {
|
|
170
|
-
return (0, _lodash2.default)(object, key);
|
|
171
|
-
}
|
|
172
|
-
};
|
|
173
|
-
var requiredFields = ['description', 'label', 'organizationId', 'timeInterval'];
|
|
174
|
-
|
|
175
|
-
for (var i = 0; i < requiredFields.length; i++) {
|
|
176
|
-
var field = requiredFields[i];
|
|
177
|
-
var hasField = hasFieldFns[field] || hasFieldFns.default;
|
|
178
|
-
|
|
179
|
-
if (!hasField(assetMetric, field)) {
|
|
180
|
-
return Promise.reject(new Error('A ' + field + ' is required to create a new asset metric.'));
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
return this._request.post(this._baseUrl + '/assets/types/' + assetTypeId + '/metrics', (0, _objects.toSnakeCase)(assetMetric)).then(function (assetMetric) {
|
|
185
|
-
return (0, _objects.toCamelCase)(assetMetric);
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* Deletes an asset metric
|
|
191
|
-
*
|
|
192
|
-
* API Endpoint: '/assets/metrics/:assetMetricId'
|
|
193
|
-
* Method: DELETE
|
|
194
|
-
*
|
|
195
|
-
* @param {string} assetMetricId The UUID formatted ID of the asset metric
|
|
196
|
-
*
|
|
197
|
-
* @returns {Promise}
|
|
198
|
-
* @fulfill {undefined}
|
|
199
|
-
* @reject {Error}
|
|
200
|
-
*
|
|
201
|
-
* @example
|
|
202
|
-
* contxtSdk.assets.metrics.delete('4f0e51c6-728b-4892-9863-6d002e61204d');
|
|
203
|
-
*/
|
|
204
|
-
|
|
205
|
-
}, {
|
|
206
|
-
key: 'delete',
|
|
207
|
-
value: function _delete(assetMetricId) {
|
|
208
|
-
if (!assetMetricId) {
|
|
209
|
-
return Promise.reject(new Error('An asset metric ID is required for deleting an asset metric.'));
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
return this._request.delete(this._baseUrl + '/assets/metrics/' + assetMetricId);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
* Gets information about an asset metric
|
|
217
|
-
*
|
|
218
|
-
* API Endpoint: '/assets/metrics/:assetMetricId'
|
|
219
|
-
* Method: GET
|
|
220
|
-
*
|
|
221
|
-
* @param {string} assetMetricId The UUID formatted ID of the asset metric
|
|
222
|
-
*
|
|
223
|
-
* @returns {Promise}
|
|
224
|
-
* @fulfill {AssetMetric} Information about the asset metric
|
|
225
|
-
* @reject {Error}
|
|
226
|
-
*
|
|
227
|
-
* @example
|
|
228
|
-
* contxtSdk.assets.metrics
|
|
229
|
-
* .get('4f0e51c6-728b-4892-9863-6d002e61204d')
|
|
230
|
-
* .then((assetMetric) => console.log(assetMetric))
|
|
231
|
-
* .catch((err) => console.log(err));
|
|
232
|
-
*/
|
|
233
|
-
|
|
234
|
-
}, {
|
|
235
|
-
key: 'get',
|
|
236
|
-
value: function get(assetMetricId) {
|
|
237
|
-
if (!assetMetricId) {
|
|
238
|
-
return Promise.reject(new Error('An asset metric ID is required for getting information about an asset metric.'));
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
return this._request.get(this._baseUrl + '/assets/metrics/' + assetMetricId).then(function (assetMetric) {
|
|
242
|
-
return (0, _objects.toCamelCase)(assetMetric);
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
/**
|
|
247
|
-
* Gets a list of all asset metrics that belong to a given asset
|
|
248
|
-
*
|
|
249
|
-
* API Endpoint: '/assets/:assetId/metrics
|
|
250
|
-
* Method: GET
|
|
251
|
-
*
|
|
252
|
-
* @param {string} assetId The UUID formatted ID of the asset type
|
|
253
|
-
* @param {Object} [assetMetricsFilters] Specific information that is used to
|
|
254
|
-
* filter the list of asset metrics
|
|
255
|
-
* @param {String} [assetMetricsFilters.assetMetricLabel] The label of the
|
|
256
|
-
* associated asset metrics
|
|
257
|
-
* @param {Number} [assetMetricsFilters.limit] Maximum number of records to
|
|
258
|
-
* return per query
|
|
259
|
-
* @param {Number} [assetMetricsFilters.offset] How many records from the first
|
|
260
|
-
* record to start the query
|
|
261
|
-
*
|
|
262
|
-
* @returns {Promise}
|
|
263
|
-
* @fulfill {AssetMetricsFromServer}
|
|
264
|
-
* @reject {Error}
|
|
265
|
-
*
|
|
266
|
-
* @example
|
|
267
|
-
* contxtSdk.assets.metrics
|
|
268
|
-
* .getByAssetId(
|
|
269
|
-
* 'f3be81fd-4494-443b-87a3-320b1c9aa495',
|
|
270
|
-
* {
|
|
271
|
-
* assetMetricLabel: 'Square Footage',
|
|
272
|
-
* limit: 50,
|
|
273
|
-
* offset: 150
|
|
274
|
-
* }
|
|
275
|
-
* )
|
|
276
|
-
* .then((assetMetricData) => console.log(assetMetricData))
|
|
277
|
-
* .catch((err) => console.log(err));
|
|
278
|
-
*/
|
|
279
|
-
|
|
280
|
-
}, {
|
|
281
|
-
key: 'getByAssetId',
|
|
282
|
-
value: function getByAssetId(assetId, assetMetricsFilters) {
|
|
283
|
-
if (!assetId) {
|
|
284
|
-
return Promise.reject(new Error('An asset ID is required to get a list of all asset metrics.'));
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
return this._request.get(this._baseUrl + '/assets/' + assetId + '/metrics', {
|
|
288
|
-
params: (0, _objects.toSnakeCase)(assetMetricsFilters)
|
|
289
|
-
}).then(function (assetMetricsData) {
|
|
290
|
-
return (0, _pagination.formatPaginatedDataFromServer)(assetMetricsData);
|
|
291
|
-
});
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
/**
|
|
295
|
-
* Gets a list of all asset metrics that belong to a given type
|
|
296
|
-
*
|
|
297
|
-
* API Endpoint: '/assets/types/:assetTypeId/metrics
|
|
298
|
-
* Method: GET
|
|
299
|
-
*
|
|
300
|
-
* @param {string} assetTypeId The UUID formatted ID of the asset type
|
|
301
|
-
* @param {Object} [assetMetricsFilters] Specific information that is used to
|
|
302
|
-
* filter the list of asset metrics
|
|
303
|
-
* @param {Number} [assetMetricsFilters.limit] Maximum number of records to
|
|
304
|
-
* return per query
|
|
305
|
-
* @param {Number} [assetMetricsFilters.offset] How many records from the first
|
|
306
|
-
* record to start the query
|
|
307
|
-
* @param {String} [assetMetricsFilters.organizationId] The UUID formatted ID
|
|
308
|
-
* of the organization to filter asset metrics by
|
|
309
|
-
*
|
|
310
|
-
* @returns {Promise}
|
|
311
|
-
* @fulfill {AssetMetricsFromServer}
|
|
312
|
-
* @reject {Error}
|
|
313
|
-
*
|
|
314
|
-
* @example
|
|
315
|
-
* contxtSdk.assets.metrics
|
|
316
|
-
* .getByAssetTypeId(
|
|
317
|
-
* '4f0e51c6-728b-4892-9863-6d002e61204d'
|
|
318
|
-
* {
|
|
319
|
-
* limit: 50,
|
|
320
|
-
* offset: 150
|
|
321
|
-
* }
|
|
322
|
-
* )
|
|
323
|
-
* .then((assetMetrics) => console.log(assetMetrics))
|
|
324
|
-
* .catch((err) => console.log(err));
|
|
325
|
-
*/
|
|
326
|
-
|
|
327
|
-
}, {
|
|
328
|
-
key: 'getByAssetTypeId',
|
|
329
|
-
value: function getByAssetTypeId(assetTypeId, assetMetricsFilters) {
|
|
330
|
-
if (!assetTypeId) {
|
|
331
|
-
return Promise.reject(new Error('An asset type ID is required to get a list of all asset metrics.'));
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
return this._request.get(this._baseUrl + '/assets/types/' + assetTypeId + '/metrics', {
|
|
335
|
-
params: (0, _objects.toSnakeCase)(assetMetricsFilters)
|
|
336
|
-
}).then(function (assetMetricsData) {
|
|
337
|
-
return (0, _pagination.formatPaginatedDataFromServer)(assetMetricsData);
|
|
338
|
-
});
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
/**
|
|
342
|
-
* Updates an asset metric's data
|
|
343
|
-
*
|
|
344
|
-
* API Endpoint: '/assets/metrics/:assetMetricId'
|
|
345
|
-
* Method: PUT
|
|
346
|
-
*
|
|
347
|
-
* @param {string} assetMetricId The ID of the asset metric to update (formatted as a UUID)
|
|
348
|
-
* @param {Object} update An object containing the updated data for the asset metric
|
|
349
|
-
* @param {string} [update.description]
|
|
350
|
-
* @param {string} [update.label]
|
|
351
|
-
* @param {string} [update.timeInterval]
|
|
352
|
-
* @param {string} [update.units]
|
|
353
|
-
*
|
|
354
|
-
* @returns {Promise}
|
|
355
|
-
* @fulfill {undefined}
|
|
356
|
-
* @reject {Error}
|
|
357
|
-
*
|
|
358
|
-
* @example
|
|
359
|
-
* contxtSdk.assets.metrics
|
|
360
|
-
* .update('5f310899-d8f9-4dac-ae82-cedb2048a8ef', {
|
|
361
|
-
* description: 'An updated description of this metric'
|
|
362
|
-
* });
|
|
363
|
-
*/
|
|
364
|
-
|
|
365
|
-
}, {
|
|
366
|
-
key: 'update',
|
|
367
|
-
value: function update(assetMetricId, _update) {
|
|
368
|
-
if (!assetMetricId) {
|
|
369
|
-
return Promise.reject(new Error('An asset metric ID is required to update an asset metric.'));
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
if (!_update) {
|
|
373
|
-
return Promise.reject(new Error('An update is required to update an asset metric.'));
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
if (!(0, _lodash4.default)(_update)) {
|
|
377
|
-
return Promise.reject(new Error('The asset metric update must be a well-formed object with the data you wish to update.'));
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
var formattedUpdate = (0, _objects.toSnakeCase)(_update, {
|
|
381
|
-
excludeKeys: ['createdAt', 'id', 'label', 'organizationId', 'updatedAt']
|
|
382
|
-
});
|
|
383
|
-
|
|
384
|
-
return this._request.put(this._baseUrl + '/assets/metrics/' + assetMetricId, formattedUpdate);
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
/**
|
|
388
|
-
* Creates a new asset metric value
|
|
389
|
-
*
|
|
390
|
-
* API Endpoint: '/assets/:assetId/metrics/:assetMetricId/values'
|
|
391
|
-
* Method: POST
|
|
392
|
-
*
|
|
393
|
-
* @param {string} assetId The ID of the asset (formatted as a UUID)
|
|
394
|
-
* @param {Object} assetMetricValue
|
|
395
|
-
* @param {string} assetMetricValue.assetMetricId UUID corresponding to the asset metric
|
|
396
|
-
* @param {string} assetMetricValue.effectiveEndDate ISO 8601 Extended Format date/time string
|
|
397
|
-
* @param {string} assetMetricValue.effectiveStartDate ISO 8601 Extended Format date/time string
|
|
398
|
-
* @param {string} [assetMetricValue.notes]
|
|
399
|
-
* @param {string} assetMetricValue.value
|
|
400
|
-
* @param {boolean} [assetMetricValue.isEstimated] Whether the value is an estimation or a true reading
|
|
401
|
-
*
|
|
402
|
-
* @returns {Promise}
|
|
403
|
-
* @fulfill {AssetMetricValue}
|
|
404
|
-
* @reject {Error}
|
|
405
|
-
*
|
|
406
|
-
* @example
|
|
407
|
-
* contxtSdk.assets.metrics
|
|
408
|
-
* .createValue('1140cc2e-6d13-42ee-9941-487fe98f8e2d', {
|
|
409
|
-
* assetMetricId: 'cca11baa-cf7d-44c0-9d0a-6ad73d5f30cb',
|
|
410
|
-
* effectiveEndDate: '2018-08-28T18:18:18.264Z',
|
|
411
|
-
* effectiveStartDate: '2018-08-27T18:18:03.175Z',
|
|
412
|
-
* notes: 'Iure delectus non sunt a voluptates pariatur fuga.',
|
|
413
|
-
* value: '2000',
|
|
414
|
-
* isEstimated: true
|
|
415
|
-
* })
|
|
416
|
-
* .then((newAssetMetricValue) => {
|
|
417
|
-
* console.log(newAssetMetricValue);
|
|
418
|
-
* })
|
|
419
|
-
* .catch((error) => {
|
|
420
|
-
* console.error(error);
|
|
421
|
-
* });
|
|
422
|
-
*/
|
|
423
|
-
|
|
424
|
-
}, {
|
|
425
|
-
key: 'createValue',
|
|
426
|
-
value: function createValue(assetId) {
|
|
427
|
-
var assetMetricValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
428
|
-
|
|
429
|
-
var requiredFields = ['assetMetricId', 'effectiveEndDate', 'effectiveStartDate', 'value'];
|
|
430
|
-
|
|
431
|
-
if (!assetId) {
|
|
432
|
-
return Promise.reject(new Error('An asset ID is required to create a new asset metric value.'));
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
for (var i = 0; i < requiredFields.length; i++) {
|
|
436
|
-
var field = requiredFields[i];
|
|
437
|
-
|
|
438
|
-
if (!assetMetricValue[field]) {
|
|
439
|
-
return Promise.reject(new Error('A ' + field + ' is required to create a new asset metric value.'));
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
return this._request.post(this._baseUrl + '/assets/' + assetId + '/metrics/' + assetMetricValue.assetMetricId + '/values', (0, _objects.toSnakeCase)(assetMetricValue)).then(function (assetMetricValue) {
|
|
444
|
-
return (0, _objects.toCamelCase)(assetMetricValue);
|
|
445
|
-
});
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
/**
|
|
449
|
-
* Deletes an asset metric value
|
|
450
|
-
*
|
|
451
|
-
* API Endpoint: '/assets/metrics/values/:assetMetricValueId'
|
|
452
|
-
* Method: DELETE
|
|
453
|
-
*
|
|
454
|
-
* @param {string} assetMetricValueId The ID of the asset metric value (formatted as a UUID)
|
|
455
|
-
*
|
|
456
|
-
* @returns {Promise}
|
|
457
|
-
* @fulfill {undefined}
|
|
458
|
-
* @reject {Error}
|
|
459
|
-
*
|
|
460
|
-
* @example
|
|
461
|
-
* contxtSdk.assets.metrics.deleteValue(
|
|
462
|
-
* 'f4cd0d84-6c61-4d19-9322-7c1ab226dc83'
|
|
463
|
-
* );
|
|
464
|
-
*/
|
|
465
|
-
|
|
466
|
-
}, {
|
|
467
|
-
key: 'deleteValue',
|
|
468
|
-
value: function deleteValue(assetMetricValueId) {
|
|
469
|
-
if (!assetMetricValueId) {
|
|
470
|
-
return Promise.reject(new Error('An asset metric value ID is required for deleting an asset metric value.'));
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
return this._request.delete(this._baseUrl + '/assets/metrics/values/' + assetMetricValueId);
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
/**
|
|
477
|
-
* Gets asset metric values for a particular asset
|
|
478
|
-
*
|
|
479
|
-
* API Endpoint: '/assets/:assetId/metrics/values'
|
|
480
|
-
* Method: GET
|
|
481
|
-
*
|
|
482
|
-
* @param {String} assetId The ID of the asset (formatted as a UUID)
|
|
483
|
-
* @param {Object} [assetMetricValuesFilters] Specific information that is
|
|
484
|
-
* used to filter the list of asset metric values
|
|
485
|
-
* @param {String} [assetMetricValuesFilters.assetMetricLabel] The label of
|
|
486
|
-
* the associated asset metrics
|
|
487
|
-
* @param {String} [assetMetricValuesFilters.effectiveEndDate] Effective end
|
|
488
|
-
* date (ISO 8601 Extended formatted) of the asset metric values
|
|
489
|
-
* @param {String} [assetMetricValuesFilters.effectiveStartDate] Effective
|
|
490
|
-
* start date (ISO 8601 Extended formatted) of the asset metric values
|
|
491
|
-
* @param {Number} [assetMetricValuesFilters.limit] Maximum number of records
|
|
492
|
-
* to return per query
|
|
493
|
-
* @param {Number} [assetMetricValuesFilters.offset] How many records from the
|
|
494
|
-
* first record to start the query
|
|
495
|
-
*
|
|
496
|
-
* @returns {Promise}
|
|
497
|
-
* @fulfill {AssetMetricValuesFromServer}
|
|
498
|
-
* @rejects {Error}
|
|
499
|
-
*
|
|
500
|
-
* @example
|
|
501
|
-
* contxtSdk.assets.metrics
|
|
502
|
-
* .getValuesByAssetId(
|
|
503
|
-
* 'f9c606f3-d270-4623-bf3b-b085424d9a8b',
|
|
504
|
-
* {
|
|
505
|
-
* assetMetricLabel: 'Square Footage',
|
|
506
|
-
* effectiveEndDate: '2018-04-13T15:44:51.943Z'
|
|
507
|
-
* effectiveStartDate: '2017-12-13T15:42:01.376Z'
|
|
508
|
-
* limit: 10,
|
|
509
|
-
* offset: 200
|
|
510
|
-
* }
|
|
511
|
-
* )
|
|
512
|
-
* .then((assetMetricValuesData) => console.log(assetMetricValuesData))
|
|
513
|
-
* .catch((err) => console.log(err));
|
|
514
|
-
*/
|
|
515
|
-
|
|
516
|
-
}, {
|
|
517
|
-
key: 'getValuesByAssetId',
|
|
518
|
-
value: function getValuesByAssetId(assetId, assetMetricValuesFilters) {
|
|
519
|
-
if (!assetId) {
|
|
520
|
-
return Promise.reject(new Error('An asset ID is required to get a list of asset metric values.'));
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
return this._request.get(this._baseUrl + '/assets/' + assetId + '/metrics/values', {
|
|
524
|
-
params: (0, _objects.toSnakeCase)(assetMetricValuesFilters)
|
|
525
|
-
}).then(function (assetMetricValueData) {
|
|
526
|
-
return (0, _pagination.formatPaginatedDataFromServer)(assetMetricValueData);
|
|
527
|
-
});
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
/**
|
|
531
|
-
* Gets asset metric values for a particular asset and metric
|
|
532
|
-
*
|
|
533
|
-
* API Endpoint: '/assets/:assetId/metrics/:assetMetricId/values'
|
|
534
|
-
* Method: GET
|
|
535
|
-
*
|
|
536
|
-
* @param {String} assetId The ID of the asset (formatted as a UUID)
|
|
537
|
-
* @param {String} assetMetricId The ID of the asset metric (formatted as a
|
|
538
|
-
* UUID)
|
|
539
|
-
* @param {Object} [assetMetricValuesFilters] Specific information that is
|
|
540
|
-
* used to filter the list of asset metric values
|
|
541
|
-
* @param {String} [assetMetricValuesFilters.effectiveEndDate] Effective end
|
|
542
|
-
* date (ISO 8601 Extended formatted) of the asset metric values
|
|
543
|
-
* @param {String} [assetMetricValuesFilters.effectiveStartDate] Effective
|
|
544
|
-
* start date (ISO 8601 Extended formatted) of the asset metric values
|
|
545
|
-
* @param {Number} [assetMetricValuesFilters.limit] Maximum number of records
|
|
546
|
-
* to return per query
|
|
547
|
-
* @param {Number} [assetMetricValuesFilters.offset] How many records from the
|
|
548
|
-
* first record to start the query
|
|
549
|
-
*
|
|
550
|
-
* @returns {Promise}
|
|
551
|
-
* @fulfill {AssetMetricValuesFromServer}
|
|
552
|
-
* @rejects {Error}
|
|
553
|
-
*
|
|
554
|
-
* @example
|
|
555
|
-
* contxtSdk.assets.metrics
|
|
556
|
-
* .getValuesByMetricId(
|
|
557
|
-
* 'd7329ef3-ca63-4ad5-bb3e-632b702584f8',
|
|
558
|
-
* 'a1329ef3-ca63-4ad5-bb3e-632b702584f8',
|
|
559
|
-
* {
|
|
560
|
-
* limit: 10,
|
|
561
|
-
* effectiveStartDate: '2018-07-11T19:14:49.715Z'
|
|
562
|
-
* }
|
|
563
|
-
* )
|
|
564
|
-
* .then((assetMetricValuesData) => {
|
|
565
|
-
* console.log(assetMetricValuesData);
|
|
566
|
-
* })
|
|
567
|
-
* .catch((err) => console.log(err));
|
|
568
|
-
*/
|
|
569
|
-
|
|
570
|
-
}, {
|
|
571
|
-
key: 'getValuesByMetricId',
|
|
572
|
-
value: function getValuesByMetricId(assetId, assetMetricId, assetMetricValuesFilters) {
|
|
573
|
-
if (!assetId) {
|
|
574
|
-
return Promise.reject(new Error('An asset ID is required to get a list of asset metric values.'));
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
if (!assetMetricId) {
|
|
578
|
-
return Promise.reject(new Error('An asset metric ID is required to get a list of asset metric values.'));
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
return this._request.get(this._baseUrl + '/assets/' + assetId + '/metrics/' + assetMetricId + '/values', {
|
|
582
|
-
params: (0, _objects.toSnakeCase)(assetMetricValuesFilters)
|
|
583
|
-
}).then(function (assetMetricValueData) {
|
|
584
|
-
return (0, _pagination.formatPaginatedDataFromServer)(assetMetricValueData);
|
|
585
|
-
});
|
|
586
|
-
}
|
|
587
|
-
|
|
588
|
-
/**
|
|
589
|
-
* Gets asset metric values for a particular asset and metric
|
|
590
|
-
*
|
|
591
|
-
* API Endpoint: '/assets/metrics/values'
|
|
592
|
-
* Method: GET
|
|
593
|
-
*
|
|
594
|
-
* @param {Object} [assetMetricFilters] Specific information that is
|
|
595
|
-
* used to filter the list of asset metric values
|
|
596
|
-
* @param {String[]} assetMetricFilters.assetIds an array of asset ids
|
|
597
|
-
* to request the metrics for
|
|
598
|
-
* @param {String[]} assetMetricFilters.labels an array of metric labels
|
|
599
|
-
* to request the metrics for
|
|
600
|
-
* @param {String} [assetMetricFilters.effectiveEndDate] Effective end
|
|
601
|
-
* date (ISO 8601 Extended formatted) of the asset metric values
|
|
602
|
-
* @param {String} [assetMetricFilters.effectiveStartDate] Effective
|
|
603
|
-
* start date (ISO 8601 Extended formatted) of the asset metric values
|
|
604
|
-
* @returns {Promise}
|
|
605
|
-
* @fulfill {AssetMetricValuesByAssetIdMetricId}
|
|
606
|
-
* @rejects {Error}
|
|
607
|
-
*
|
|
608
|
-
* @example
|
|
609
|
-
* contxtSdk.assets.metrics
|
|
610
|
-
* .getValuesByMetricIdsAssetIds(
|
|
611
|
-
* {
|
|
612
|
-
* effectiveStartDate: '2018-07-11T19:14:49.715Z',
|
|
613
|
-
* effectiveEndDate: '2018-07-11T19:14:49.715Z',
|
|
614
|
-
* assetIds: ['2140cc2e-6d13-42ee-9941-487fe98f8e2d', '5540cc2e-6d13-42ee-9941-487fe98f8efc'],
|
|
615
|
-
* labels: ['facility_kwh', 'facility_cuft'],
|
|
616
|
-
* }
|
|
617
|
-
* )
|
|
618
|
-
* .then((assetMetricValuesByAssetIdMetricId) => {
|
|
619
|
-
* console.log(assetMetricValuesByAssetIdMetricId);
|
|
620
|
-
* })
|
|
621
|
-
* .catch((err) => console.log(err));
|
|
622
|
-
*/
|
|
623
|
-
|
|
624
|
-
}, {
|
|
625
|
-
key: 'getValuesByMetricIdsAssetIds',
|
|
626
|
-
value: function getValuesByMetricIdsAssetIds(assetMetricFilters) {
|
|
627
|
-
var requiredFields = ['assetIds', 'labels'];
|
|
628
|
-
|
|
629
|
-
for (var i = 0; i < requiredFields.length; i++) {
|
|
630
|
-
var field = requiredFields[i];
|
|
631
|
-
|
|
632
|
-
if (!assetMetricFilters[field]) {
|
|
633
|
-
return Promise.reject(new Error('The ' + field + ' param is required to fetch data.'));
|
|
634
|
-
}
|
|
635
|
-
}
|
|
636
|
-
|
|
637
|
-
return this._request.get(this._baseUrl + '/assets/metrics/values', {
|
|
638
|
-
params: (0, _objects.toSnakeCase)(assetMetricFilters),
|
|
639
|
-
paramsSerializer: _url.stringifyParamsWithCommaSeparatedArrays
|
|
640
|
-
}).then(function (assetMetricValues) {
|
|
641
|
-
var result = (0, _objects.toCamelCase)(assetMetricValues, {
|
|
642
|
-
excludeTransform: [].concat(_toConsumableArray(assetMetricFilters.labels), _toConsumableArray(assetMetricFilters.assetIds))
|
|
643
|
-
});
|
|
644
|
-
|
|
645
|
-
return result;
|
|
646
|
-
});
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
/**
|
|
650
|
-
* Updates an asset metric value
|
|
651
|
-
*
|
|
652
|
-
* API Endpoint: '/assets/metrics/values/:assetMetricValueId'
|
|
653
|
-
* Method: PUT
|
|
654
|
-
*
|
|
655
|
-
* @param {string} assetMetricValueId The ID of the asset metric value to update (formatted as a UUID)
|
|
656
|
-
* @param {Object} update An object containing the updated data for the asset metric value
|
|
657
|
-
* @param {string} [update.effectiveEndDate] ISO 8601 Extended Format date/time string
|
|
658
|
-
* @param {string} [update.effectiveStartDate] ISO 8601 Extended Format date/time string
|
|
659
|
-
* @param {string} [update.notes]
|
|
660
|
-
* @param {string} [update.value]
|
|
661
|
-
* @param {boolean} [update.isEstimated] Whether the value is an estimation or a true reading
|
|
662
|
-
*
|
|
663
|
-
* @returns {Promise}
|
|
664
|
-
* @fulfill {undefined}
|
|
665
|
-
* @reject {Error}
|
|
666
|
-
*
|
|
667
|
-
* @example
|
|
668
|
-
* contxtSdk.assets.metrics
|
|
669
|
-
* .updateValue('2140cc2e-6d13-42ee-9941-487fe98f8e2d', {
|
|
670
|
-
* effectiveEndDate: '2018-07-10T11:04:24.631Z',
|
|
671
|
-
* notes: 'Dolores et sapiente sunt doloribus aut in.',
|
|
672
|
-
* value: '61456',
|
|
673
|
-
* isEstimated: true
|
|
674
|
-
* })
|
|
675
|
-
* .catch((err) => console.log(err));
|
|
676
|
-
*/
|
|
677
|
-
|
|
678
|
-
}, {
|
|
679
|
-
key: 'updateValue',
|
|
680
|
-
value: function updateValue(assetMetricValueId, update) {
|
|
681
|
-
if (!assetMetricValueId) {
|
|
682
|
-
return Promise.reject(new Error('An asset metric value ID is required to update an asset metric value.'));
|
|
683
|
-
}
|
|
684
|
-
|
|
685
|
-
if (!update) {
|
|
686
|
-
return Promise.reject(new Error('An update is required to update an asset metric value.'));
|
|
687
|
-
}
|
|
688
|
-
|
|
689
|
-
if (!(0, _lodash4.default)(update)) {
|
|
690
|
-
return Promise.reject(new Error('The asset metric value update must be a well-formed object with the data you wish to update.'));
|
|
691
|
-
}
|
|
692
|
-
|
|
693
|
-
var formattedUpdate = (0, _objects.toSnakeCase)(update, {
|
|
694
|
-
excludeKeys: ['assetId', 'assetMetricId', 'id']
|
|
695
|
-
});
|
|
696
|
-
|
|
697
|
-
return this._request.put(this._baseUrl + '/assets/metrics/values/' + assetMetricValueId, formattedUpdate);
|
|
698
|
-
}
|
|
699
|
-
}]);
|
|
700
|
-
|
|
701
|
-
return AssetMetrics;
|
|
702
|
-
}();
|
|
703
|
-
|
|
704
|
-
exports.default = AssetMetrics;
|
|
705
|
-
//# sourceMappingURL=assetMetrics.js.map
|