@edgeiq/edgeiq-api-js 1.2.15 → 1.2.16
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,7 +1,10 @@
|
|
|
1
1
|
import { BaseModelInterface } from '../core/ModelClass';
|
|
2
|
+
import { BulkActionResponse } from '../models';
|
|
2
3
|
import { DeviceTransferRequest, DeviceTransferRequestInput, DeviceTransferRequestsFilters, PaginatedDeviceTransferRequests } from './models';
|
|
3
4
|
interface DeviceTransferRequestsInterface extends BaseModelInterface<DeviceTransferRequest, DeviceTransferRequestInput, DeviceTransferRequestsFilters, PaginatedDeviceTransferRequests> {
|
|
4
5
|
update(deviceTransferRequest: DeviceTransferRequest): Promise<DeviceTransferRequest>;
|
|
6
|
+
accept(id: string, deviceTypeId: string): Promise<string>;
|
|
7
|
+
bulkAccept(ids: string[], deviceTypeId: string): Promise<BulkActionResponse>;
|
|
5
8
|
}
|
|
6
9
|
export declare const DeviceTransferRequests: DeviceTransferRequestsInterface;
|
|
7
10
|
export {};
|
|
@@ -194,5 +194,56 @@ exports.DeviceTransferRequests = (function (_super) {
|
|
|
194
194
|
});
|
|
195
195
|
});
|
|
196
196
|
};
|
|
197
|
+
class_1.accept = function (id, deviceTypeId) {
|
|
198
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
199
|
+
var axios, data, error_6;
|
|
200
|
+
return __generator(this, function (_a) {
|
|
201
|
+
switch (_a.label) {
|
|
202
|
+
case 0:
|
|
203
|
+
_a.trys.push([0, 2, , 3]);
|
|
204
|
+
this.logAction("Accepting device transfer request with id " + id);
|
|
205
|
+
axios = __1.EdgeIQAPI.getAxios();
|
|
206
|
+
data = JSON.stringify({ device_type_id: deviceTypeId });
|
|
207
|
+
return [4, axios.post(constants_1.Endpoints.deviceTransferRequest + "/" + id + "/transfer", data)];
|
|
208
|
+
case 1:
|
|
209
|
+
_a.sent();
|
|
210
|
+
return [2, 'Device transfer request accepted'];
|
|
211
|
+
case 2:
|
|
212
|
+
error_6 = _a.sent();
|
|
213
|
+
if ((0, helpers_1.isApiError)(error_6)) {
|
|
214
|
+
throw error_6;
|
|
215
|
+
}
|
|
216
|
+
throw error_6;
|
|
217
|
+
case 3: return [2];
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
};
|
|
222
|
+
class_1.bulkAccept = function (ids, deviceTypeId) {
|
|
223
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
224
|
+
var axios, result, error_7;
|
|
225
|
+
return __generator(this, function (_a) {
|
|
226
|
+
switch (_a.label) {
|
|
227
|
+
case 0:
|
|
228
|
+
_a.trys.push([0, 2, , 3]);
|
|
229
|
+
this.logAction("Accepting " + ids.length + " device transfer requests with device type with ID: " + deviceTypeId);
|
|
230
|
+
axios = __1.EdgeIQAPI.getAxios();
|
|
231
|
+
return [4, axios.post(constants_1.Endpoints.deviceTransferRequest + "/bulk/transfer", {
|
|
232
|
+
data: { ids: ids, device_type_id: deviceTypeId },
|
|
233
|
+
})];
|
|
234
|
+
case 1:
|
|
235
|
+
result = _a.sent();
|
|
236
|
+
return [2, result === null || result === void 0 ? void 0 : result.data];
|
|
237
|
+
case 2:
|
|
238
|
+
error_7 = _a.sent();
|
|
239
|
+
if ((0, helpers_1.isApiError)(error_7)) {
|
|
240
|
+
throw error_7;
|
|
241
|
+
}
|
|
242
|
+
throw error_7;
|
|
243
|
+
case 3: return [2];
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
});
|
|
247
|
+
};
|
|
197
248
|
return class_1;
|
|
198
249
|
}(ModelClass_1.BaseModelClass));
|