UNPKG

@altostra/core

Version:

Core library for shared types and logic

1 lines 2.42 kB
"use strict";var _TeamsManager_backOfficeEndpoint,__awaiter=this&&this.__awaiter||function(e,t,a,r){return new(a||(a=Promise))((function(i,s){function n(e){try{c(r.next(e))}catch(e){s(e)}}function o(e){try{c(r.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof a?t:new a((function(e){e(t)}))).then(n,o)}c((r=r.apply(e,t||[])).next())}))},__classPrivateFieldSet=this&&this.__classPrivateFieldSet||function(e,t,a,r,i){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?i.call(e,a):i?i.value=a:t.set(e,a),a},__classPrivateFieldGet=this&&this.__classPrivateFieldGet||function(e,t,a,r){if("a"===a&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===a?r:"a"===a?r.call(e):r?r.value:t.get(e)};Object.defineProperty(exports,"__esModule",{value:!0}),exports.TeamsManager=void 0;const ServiceClientBase_1=require("../ServiceClientBase"),Types_1=require("./Types");class TeamsManager extends ServiceClientBase_1.ServiceClientBase{constructor(e,t,a={}){super({getToken:t,errorMapping:a}),_TeamsManager_backOfficeEndpoint.set(this,void 0),__classPrivateFieldSet(this,_TeamsManager_backOfficeEndpoint,e,"f")}getUserTeams(){return this._request({request:e=>__awaiter(this,void 0,void 0,(function*(){return yield e.get(__classPrivateFieldGet(this,_TeamsManager_backOfficeEndpoint,"f")+"/organization",{headers:yield this._getHeaders()})})),dataValidation:Types_1.isOrganizationsArray,errorWrapping:{message:"Unable to get team data for the currently logged-in user.\nPlease try again or contact support.",type:"get-teams"}})}getTeamUsers(){return __awaiter(this,void 0,void 0,(function*(){const{users:e}=yield this._request({request:e=>__awaiter(this,void 0,void 0,(function*(){return yield e.get(__classPrivateFieldGet(this,_TeamsManager_backOfficeEndpoint,"f")+"/users",{headers:yield this._getHeaders()})})),dataValidation:Types_1.isGetUsersInOrganizationResponse,errorWrapping:{}});return e}))}}exports.TeamsManager=TeamsManager,_TeamsManager_backOfficeEndpoint=new WeakMap;