UNPKG

@xompass/sdk-cloud-api

Version:

Xompass Client for cloud-api

485 lines 19.5 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.SuperAdminApi = void 0; var SDKModels_1 = require("./SDKModels"); var core_1 = require("../core"); var XompassClient_1 = require("../../XompassClient"); /** * Api services for the `SuperAdmin` model. */ var SuperAdminApi = /** @class */ (function (_super) { __extends(SuperAdminApi, _super); function SuperAdminApi() { return _super !== null && _super.apply(this, arguments) || this; } SuperAdminApi.findByIdAccessTokens = function (id, fk, retry) { if (retry === void 0) { retry = false; } var _method = 'GET'; var _url = [ XompassClient_1.XompassClient.getPath() + '/' + XompassClient_1.XompassClient.getApiVersion(), '/SuperAdmins/:id/accessTokens/:fk' ].join(''); var _routeParams = { id: id, fk: fk }; var _postBody = {}; var _urlParams = {}; return _super.request.call(this, _method, _url, _routeParams, _urlParams, _postBody, retry); }; SuperAdminApi.updateByIdAccessTokens = function (id, fk, data, retry) { if (data === void 0) { data = {}; } if (retry === void 0) { retry = false; } var _method = 'PUT'; var _url = [ XompassClient_1.XompassClient.getPath() + '/' + XompassClient_1.XompassClient.getApiVersion(), '/SuperAdmins/:id/accessTokens/:fk' ].join(''); var _routeParams = { id: id, fk: fk }; var _postBody = data; var _urlParams = {}; return _super.request.call(this, _method, _url, _routeParams, _urlParams, _postBody, retry); }; SuperAdminApi.findByIdActivityLogs = function (id, fk, retry) { if (retry === void 0) { retry = false; } var _method = 'GET'; var _url = [ XompassClient_1.XompassClient.getPath() + '/' + XompassClient_1.XompassClient.getApiVersion(), '/SuperAdmins/:id/activityLogs/:fk' ].join(''); var _routeParams = { id: id, fk: fk }; var _postBody = {}; var _urlParams = {}; return _super.request.call(this, _method, _url, _routeParams, _urlParams, _postBody, retry); }; SuperAdminApi.findByIdTrackingLogs = function (id, fk, retry) { if (retry === void 0) { retry = false; } var _method = 'GET'; var _url = [ XompassClient_1.XompassClient.getPath() + '/' + XompassClient_1.XompassClient.getApiVersion(), '/SuperAdmins/:id/trackingLogs/:fk' ].join(''); var _routeParams = { id: id, fk: fk }; var _postBody = {}; var _urlParams = {}; return _super.request.call(this, _method, _url, _routeParams, _urlParams, _postBody, retry); }; SuperAdminApi.getCountry = function (id, refresh, retry) { if (refresh === void 0) { refresh = {}; } if (retry === void 0) { retry = false; } var _method = 'GET'; var _url = [ XompassClient_1.XompassClient.getPath() + '/' + XompassClient_1.XompassClient.getApiVersion(), '/SuperAdmins/:id/country' ].join(''); var _routeParams = { id: id }; var _postBody = {}; var _urlParams = {}; if (typeof refresh !== 'undefined' && refresh !== null) { _urlParams['refresh'] = refresh; } return _super.request.call(this, _method, _url, _routeParams, _urlParams, _postBody, retry); }; SuperAdminApi.getTimeZone = function (id, refresh, retry) { if (refresh === void 0) { refresh = {}; } if (retry === void 0) { retry = false; } var _method = 'GET'; var _url = [ XompassClient_1.XompassClient.getPath() + '/' + XompassClient_1.XompassClient.getApiVersion(), '/SuperAdmins/:id/timeZone' ].join(''); var _routeParams = { id: id }; var _postBody = {}; var _urlParams = {}; if (typeof refresh !== 'undefined' && refresh !== null) { _urlParams['refresh'] = refresh; } return _super.request.call(this, _method, _url, _routeParams, _urlParams, _postBody, retry); }; SuperAdminApi.getActivityLogs = function (id, filter, retry) { if (filter === void 0) { filter = {}; } if (retry === void 0) { retry = false; } var _method = 'GET'; var _url = [ XompassClient_1.XompassClient.getPath() + '/' + XompassClient_1.XompassClient.getApiVersion(), '/SuperAdmins/:id/activityLogs' ].join(''); var _routeParams = { id: id }; var _postBody = {}; var _urlParams = {}; if (typeof filter !== 'undefined' && filter !== null) { _urlParams['filter'] = filter; } return _super.request.call(this, _method, _url, _routeParams, _urlParams, _postBody, retry); }; SuperAdminApi.countActivityLogs = function (id, where, retry) { if (where === void 0) { where = {}; } if (retry === void 0) { retry = false; } var _method = 'GET'; var _url = [ XompassClient_1.XompassClient.getPath() + '/' + XompassClient_1.XompassClient.getApiVersion(), '/SuperAdmins/:id/activityLogs/count' ].join(''); var _routeParams = { id: id }; var _postBody = {}; var _urlParams = {}; if (typeof where !== 'undefined' && where !== null) { _urlParams['where'] = where; } return _super.request.call(this, _method, _url, _routeParams, _urlParams, _postBody, retry); }; SuperAdminApi.getTrackingLogs = function (id, filter, retry) { if (filter === void 0) { filter = {}; } if (retry === void 0) { retry = false; } var _method = 'GET'; var _url = [ XompassClient_1.XompassClient.getPath() + '/' + XompassClient_1.XompassClient.getApiVersion(), '/SuperAdmins/:id/trackingLogs' ].join(''); var _routeParams = { id: id }; var _postBody = {}; var _urlParams = {}; if (typeof filter !== 'undefined' && filter !== null) { _urlParams['filter'] = filter; } return _super.request.call(this, _method, _url, _routeParams, _urlParams, _postBody, retry); }; SuperAdminApi.countTrackingLogs = function (id, where, retry) { if (where === void 0) { where = {}; } if (retry === void 0) { retry = false; } var _method = 'GET'; var _url = [ XompassClient_1.XompassClient.getPath() + '/' + XompassClient_1.XompassClient.getApiVersion(), '/SuperAdmins/:id/trackingLogs/count' ].join(''); var _routeParams = { id: id }; var _postBody = {}; var _urlParams = {}; if (typeof where !== 'undefined' && where !== null) { _urlParams['where'] = where; } return _super.request.call(this, _method, _url, _routeParams, _urlParams, _postBody, retry); }; SuperAdminApi.login = function (credentials, include, rememberMe, retry) { if (include === void 0) { include = 'user'; } if (rememberMe === void 0) { rememberMe = true; } if (retry === void 0) { retry = false; } var _method = 'POST'; var _url = [ XompassClient_1.XompassClient.getPath() + '/' + XompassClient_1.XompassClient.getApiVersion(), '/SuperAdmins/login' ].join(''); var _routeParams = {}; var _postBody = credentials; var _urlParams = {}; if (typeof include !== 'undefined' && include !== null) { _urlParams['include'] = include; } return _super.request.call(this, _method, _url, _routeParams, _urlParams, _postBody, retry) .then(function (response) { response.ttl = parseInt(response.ttl, 10); response.rememberMe = rememberMe; core_1.XompassAuth.setToken(response); return response; }); }; SuperAdminApi.logout = function (retry) { if (retry === void 0) { retry = false; } var _method = 'POST'; var _url = [ XompassClient_1.XompassClient.getPath() + '/' + XompassClient_1.XompassClient.getApiVersion(), '/SuperAdmins/logout' ].join(''); var _routeParams = {}; var _postBody = {}; var _urlParams = {}; _urlParams['access_token'] = core_1.XompassAuth.getAccessTokenId(); core_1.XompassAuth.clear(); return _super.request.call(this, _method, _url, _routeParams, _urlParams, _postBody, retry); }; SuperAdminApi.verify = function (id, retry) { if (retry === void 0) { retry = false; } var _method = 'POST'; var _url = [ XompassClient_1.XompassClient.getPath() + '/' + XompassClient_1.XompassClient.getApiVersion(), '/SuperAdmins/:id/verify' ].join(''); var _routeParams = { id: id }; var _postBody = {}; var _urlParams = {}; return _super.request.call(this, _method, _url, _routeParams, _urlParams, _postBody, retry); }; SuperAdminApi.confirm = function (uid, token, redirect, retry) { if (redirect === void 0) { redirect = {}; } if (retry === void 0) { retry = false; } var _method = 'GET'; var _url = [ XompassClient_1.XompassClient.getPath() + '/' + XompassClient_1.XompassClient.getApiVersion(), '/SuperAdmins/confirm' ].join(''); var _routeParams = {}; var _postBody = {}; var _urlParams = {}; if (typeof uid !== 'undefined' && uid !== null) { _urlParams['uid'] = uid; } if (typeof token !== 'undefined' && token !== null) { _urlParams['token'] = token; } if (typeof redirect !== 'undefined' && redirect !== null) { _urlParams['redirect'] = redirect; } return _super.request.call(this, _method, _url, _routeParams, _urlParams, _postBody, retry); }; SuperAdminApi.resetPassword = function (options, retry) { if (retry === void 0) { retry = false; } var _method = 'POST'; var _url = [ XompassClient_1.XompassClient.getPath() + '/' + XompassClient_1.XompassClient.getApiVersion(), '/SuperAdmins/reset' ].join(''); var _routeParams = {}; var _postBody = options; var _urlParams = {}; return _super.request.call(this, _method, _url, _routeParams, _urlParams, _postBody, retry); }; SuperAdminApi.changePassword = function (oldPassword, newPassword, retry) { if (retry === void 0) { retry = false; } var _method = 'POST'; var _url = [ XompassClient_1.XompassClient.getPath() + '/' + XompassClient_1.XompassClient.getApiVersion(), '/SuperAdmins/change-password' ].join(''); var _routeParams = {}; var _postBody = { oldPassword: oldPassword, newPassword: newPassword }; var _urlParams = {}; return _super.request.call(this, _method, _url, _routeParams, _urlParams, _postBody, retry); }; SuperAdminApi.setPassword = function (newPassword, retry) { if (retry === void 0) { retry = false; } var _method = 'POST'; var _url = [ XompassClient_1.XompassClient.getPath() + '/' + XompassClient_1.XompassClient.getApiVersion(), '/SuperAdmins/reset-password' ].join(''); var _routeParams = {}; var _postBody = { newPassword: newPassword }; var _urlParams = {}; return _super.request.call(this, _method, _url, _routeParams, _urlParams, _postBody, retry); }; SuperAdminApi.otpLogin = function (credentials, include, retry) { if (include === void 0) { include = {}; } if (retry === void 0) { retry = false; } var _method = 'POST'; var _url = [ XompassClient_1.XompassClient.getPath() + '/' + XompassClient_1.XompassClient.getApiVersion(), '/SuperAdmins/otp/login' ].join(''); var _routeParams = {}; var _postBody = credentials; var _urlParams = {}; if (typeof include !== 'undefined' && include !== null) { _urlParams['include'] = include; } return _super.request.call(this, _method, _url, _routeParams, _urlParams, _postBody, retry); }; SuperAdminApi.otpDisable = function (id, retry) { if (retry === void 0) { retry = false; } var _method = 'PATCH'; var _url = [ XompassClient_1.XompassClient.getPath() + '/' + XompassClient_1.XompassClient.getApiVersion(), '/SuperAdmins/:id/otp/disable' ].join(''); var _routeParams = { id: id }; var _postBody = {}; var _urlParams = {}; return _super.request.call(this, _method, _url, _routeParams, _urlParams, _postBody, retry); }; SuperAdminApi.getMiniAppUserSessionsActive = function (id, retry) { if (retry === void 0) { retry = false; } var _method = 'GET'; var _url = [ XompassClient_1.XompassClient.getPath() + '/' + XompassClient_1.XompassClient.getApiVersion(), '/SuperAdmins/:id/miniapp/activeSessions' ].join(''); var _routeParams = { id: id }; var _postBody = {}; var _urlParams = {}; return _super.request.call(this, _method, _url, _routeParams, _urlParams, _postBody, retry); }; SuperAdminApi.MiniAppUserSessionActiveLogout = function (id, data, retry) { if (retry === void 0) { retry = false; } var _method = 'POST'; var _url = [ XompassClient_1.XompassClient.getPath() + '/' + XompassClient_1.XompassClient.getApiVersion(), '/SuperAdmins/:id/telegram/miniapp/logout' ].join(''); var _routeParams = { id: id }; var _postBody = data; var _urlParams = {}; return _super.request.call(this, _method, _url, _routeParams, _urlParams, _postBody, retry); }; SuperAdminApi.otpCheck = function (id, retry) { if (retry === void 0) { retry = false; } var _method = 'GET'; var _url = [ XompassClient_1.XompassClient.getPath() + '/' + XompassClient_1.XompassClient.getApiVersion(), '/SuperAdmins/:id/otp/check' ].join(''); var _routeParams = { id: id }; var _postBody = {}; var _urlParams = {}; return _super.request.call(this, _method, _url, _routeParams, _urlParams, _postBody, retry); }; SuperAdminApi.otpGenerate = function (id, retry) { if (retry === void 0) { retry = false; } var _method = 'GET'; var _url = [ XompassClient_1.XompassClient.getPath() + '/' + XompassClient_1.XompassClient.getApiVersion(), '/SuperAdmins/:id/otp/generate' ].join(''); var _routeParams = { id: id }; var _postBody = {}; var _urlParams = {}; return _super.request.call(this, _method, _url, _routeParams, _urlParams, _postBody, retry); }; SuperAdminApi.otpVerify = function (id, obj, retry) { if (obj === void 0) { obj = {}; } if (retry === void 0) { retry = false; } var _method = 'POST'; var _url = [ XompassClient_1.XompassClient.getPath() + '/' + XompassClient_1.XompassClient.getApiVersion(), '/SuperAdmins/:id/otp/verify' ].join(''); var _routeParams = { id: id }; var _postBody = obj; var _urlParams = {}; return _super.request.call(this, _method, _url, _routeParams, _urlParams, _postBody, retry); }; SuperAdminApi.verifyAccount = function (options, retry) { if (retry === void 0) { retry = false; } var _method = 'POST'; var _url = [ XompassClient_1.XompassClient.getPath() + '/' + XompassClient_1.XompassClient.getApiVersion(), '/SuperAdmins/verify' ].join(''); var _routeParams = {}; var _postBody = options; var _urlParams = {}; return _super.request.call(this, _method, _url, _routeParams, _urlParams, _postBody, retry); }; SuperAdminApi.getCurrent = function (filter, retry) { if (filter === void 0) { filter = {}; } if (retry === void 0) { retry = false; } var _method = 'GET'; var _url = [ XompassClient_1.XompassClient.getPath() + '/' + XompassClient_1.XompassClient.getApiVersion(), '' + '/:id' ].join(''); var id = core_1.XompassAuth.getCurrentUserId(); if (id == null) { id = '__anonymous__'; } var _routeParams = { id: id }; var _urlParams = {}; var _postBody = {}; if (filter) { _urlParams.filter = filter; } return _super.request.call(this, _method, _url, _routeParams, _urlParams, _postBody, retry); }; SuperAdminApi.getCachedCurrent = function () { return core_1.XompassAuth.getCurrentUserData(); }; SuperAdminApi.getCurrentToken = function () { return core_1.XompassAuth.getToken(); }; /** * * @returns True if the current user is authenticated (logged in). */ SuperAdminApi.isAuthenticated = function () { var userId = this.getCurrentId(); var token = this.getCurrentToken(); if (userId === '' || userId == null || userId === 'null' || !token) { return false; } var now = new Date(); var created = new Date(token.created || 0); var ttl = token.ttl || 0; return new Date(created.getTime() + ttl * 1000) > now; }; /** * * @returns object Id of the currently logged-in user or null. */ SuperAdminApi.getCurrentId = function () { return core_1.XompassAuth.getCurrentUserId(); }; /** * The name of the model represented by this $resource, * i.e. `SuperAdmin`. */ SuperAdminApi.getModelName = function () { return 'SuperAdmin'; }; SuperAdminApi.model = SDKModels_1.SDKModels.get('SuperAdmin'); return SuperAdminApi; }(core_1.XompassBaseUserApi)); exports.SuperAdminApi = SuperAdminApi; //# sourceMappingURL=SuperAdmin.js.map