UNPKG

workspace-integrations

Version:
32 lines (31 loc) 979 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const util_1 = require("../util"); const cache_1 = require("../cache"); class WorkspacesImpl { constructor(http) { this.http = http; this.cache = new cache_1.default(); } async getWorkspaces(filters) { let hasMore = false; let result = []; let start = 0; const max = 999; const params = (0, util_1.toUrlParams)(filters); do { const url = `/workspaces?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; } getWorkspace(workspaceId) { const url = '/workspaces/' + workspaceId; return this.cache.fetch(this.http, url); } } exports.default = WorkspacesImpl;