UNPKG

@crowdin/crowdin-api-client

Version:
169 lines (168 loc) 7.9 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Users = void 0; const core_1 = require("../core"); /** * Users API gives you the possibility to get profile information about the currently authenticated user. * * In Crowdin Enterprise users are the members of your organization with the defined access levels. * Use API to get the list of organization users and to check the information on a specific user. */ class Users extends core_1.CrowdinApi { listProjectMembers(projectId, options, deprecatedRole, deprecatedLanguageId, deprecatedLimit, deprecatedOffset) { let url = `${this.url}/projects/${projectId}/members`; if ((0, core_1.isOptionalString)(options, '1' in arguments)) { options = { search: options, role: deprecatedRole, languageId: deprecatedLanguageId, limit: deprecatedLimit, offset: deprecatedOffset, }; } url = this.addQueryParam(url, 'search', options.search); url = this.addQueryParam(url, 'role', options.role); url = this.addQueryParam(url, 'languageId', options.languageId); url = this.addQueryParam(url, 'workflowStepId', options.workflowStepId); url = this.addQueryParam(url, 'orderBy', options.orderBy); return this.getList(url, options.limit, options.offset); } /** * @param projectId project identifier * @param request request body * @see https://support.crowdin.com/enterprise/api/#operation/api.projects.members.post */ addProjectMember(projectId, request) { const url = `${this.url}/projects/${projectId}/members`; return this.post(url, request, this.defaultConfig()); } /** * @param projectId project identifier * @param memberId member identifier * @see https://developer.crowdin.com/api/v2/#operation/api.projects.members.get */ getProjectMemberPermissions(projectId, memberId) { const url = `${this.url}/projects/${projectId}/members/${memberId}`; return this.get(url, this.defaultConfig()); } /** * @param projectId project identifier * @param memberId member identifier * @see https://support.crowdin.com/enterprise/api/#operation/api.projects.members.put */ replaceProjectMemberPermissions(projectId, memberId, request = {}) { const url = `${this.url}/projects/${projectId}/members/${memberId}`; return this.put(url, request, this.defaultConfig()); } /** * @param projectId project identifier * @param memberId member identifier * @see https://support.crowdin.com/enterprise/api/#operation/api.projects.members.delete */ deleteMemberFromProject(projectId, memberId) { const url = `${this.url}/projects/${projectId}/members/${memberId}`; return this.delete(url, this.defaultConfig()); } listUsers(options, deprecatedSearch, deprecatedTwoFactor, deprecatedLimit, deprecatedOffset) { var _a, _b; let url = `${this.url}/users`; if ((0, core_1.isOptionalString)(options, '0' in arguments)) { options = { status: options, search: deprecatedSearch, twoFactor: deprecatedTwoFactor, limit: deprecatedLimit, offset: deprecatedOffset, }; } url = this.addQueryParam(url, 'status', options.status); url = this.addQueryParam(url, 'search', options.search); url = this.addQueryParam(url, 'twoFactor', options.twoFactor); url = this.addQueryParam(url, 'orderBy', options.orderBy); url = this.addQueryParam(url, 'organizationRoles', (_a = options === null || options === void 0 ? void 0 : options.organizationRoles) === null || _a === void 0 ? void 0 : _a.toString()); url = this.addQueryParam(url, 'teamId', options === null || options === void 0 ? void 0 : options.teamId); url = this.addQueryParam(url, 'projectIds', options === null || options === void 0 ? void 0 : options.projectIds); url = this.addQueryParam(url, 'projectRoles', (_b = options === null || options === void 0 ? void 0 : options.projectRoles) === null || _b === void 0 ? void 0 : _b.toString()); url = this.addQueryParam(url, 'languageIds', options === null || options === void 0 ? void 0 : options.languageIds); url = this.addQueryParam(url, 'groupIds', options === null || options === void 0 ? void 0 : options.groupIds); url = this.addQueryParam(url, 'lastSeenFrom', options === null || options === void 0 ? void 0 : options.lastSeenFrom); url = this.addQueryParam(url, 'lastSeenTo', options === null || options === void 0 ? void 0 : options.lastSeenTo); return this.getList(url, options.limit, options.offset); } /** * @param request request body * @see https://support.crowdin.com/enterprise/api/#operation/api.users.post */ inviteUser(request) { const url = `${this.url}/users`; return this.post(url, request, this.defaultConfig()); } /** * @param userId user identifier * @see https://support.crowdin.com/enterprise/api/#operation/api.users.getById */ getUserInfo(userId) { const url = `${this.url}/users/${userId}`; return this.get(url, this.defaultConfig()); } /** * @param userId user identifier * @see https://support.crowdin.com/enterprise/api/#operation/api.users.delete */ deleteUser(userId) { const url = `${this.url}/users/${userId}`; return this.delete(url, this.defaultConfig()); } /** * @param userId user identifier * @param request request body * @see https://support.crowdin.com/enterprise/api/#operation/api.users.patch */ editUser(userId, request) { const url = `${this.url}/users/${userId}`; return this.patch(url, request, this.defaultConfig()); } /** * @see https://developer.crowdin.com/api/v2/#operation/api.user.get */ getAuthenticatedUser() { const url = `${this.url}/user`; return this.get(url, this.defaultConfig()); } /** * @param request request body * @see https://developer.crowdin.com/api/v2/#operation/api.user.patch */ editAuthenticatedUser(request) { const url = `${this.url}/user`; return this.patch(url, request, this.defaultConfig()); } /** * @param userId user identifier * @param options request options * @see https://developer.crowdin.com/enterprise/api/v2/#operation/api.users.projects.permissions.getMany */ listUserProjectPermissions(userId, options) { const url = `${this.url}/users/${userId}/projects/permissions`; return this.getList(url, options === null || options === void 0 ? void 0 : options.limit, options === null || options === void 0 ? void 0 : options.offset); } /** * @param userId user identifier * @param request request body * @see https://developer.crowdin.com/enterprise/api/v2/#operation/api.users.projects.permissions.patch */ editUserProjectPermissions(userId, request) { const url = `${this.url}/users/${userId}/projects/permissions`; return this.patch(url, request, this.defaultConfig()); } /** * @param userId user identifier * @param options request options * @see https://developer.crowdin.com/enterprise/api/v2/#operation/api.users.projects.contributions.getMany */ listUserProjectContributions(userId, options) { const url = `${this.url}/users/${userId}/projects/contributions`; return this.getList(url, options === null || options === void 0 ? void 0 : options.limit, options === null || options === void 0 ? void 0 : options.offset); } } exports.Users = Users;