workspace-integrations
Version:
Webex Workspace Integrations NodeJS SDK
32 lines (31 loc) • 961 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const util_1 = require("../util");
const cache_1 = require("../cache");
class DevicesImpl {
constructor(http) {
this.http = http;
this.cache = new cache_1.default();
}
async getDevices(filters) {
let hasMore = false;
let result = [];
let start = 0;
const max = 999;
const params = (0, util_1.toUrlParams)(filters);
do {
const url = `/devices?max=${max}&start=${start}&${params}`;
const res = await this.http.get(url);
const list = res.items;
hasMore = list.length >= max;
result = result.concat(list);
start += max;
} while (hasMore);
return result;
}
async getDevice(deviceId) {
const url = '/devices/' + deviceId;
return this.cache.fetch(this.http, url);
}
}
exports.default = DevicesImpl;