import { CrowdinApi , Pagination , ResponseList , ResponseObject } from '../core' ; export class Users extends CrowdinApi { param projectId param search param role param languageId param limit param offset listProjectMembers ( projectId , search ? , role ? , languageId ? , limit ? , offset ? ) ; listProjectMembers ( projectId , searchOrRequest ? , role ? , languageId ? , limit ? , offset ? ) { let url = `${ this . url }/projects/${ projectId }/members` ; let request ; if ( searchOrRequest && typeof searchOrRequest === 'object' ) { request = searchOrRequest ; } else { request = { search : searchOrRequest , role , languageId , limit , offset } ; } url = this . addQueryParam ( url , 'search' , request . search ) ; url = this . addQueryParam ( url , 'role' , request . role ) ; url = this . addQueryParam ( url , 'languageId' , request . languageId ) ; return this . getList ( url , request . limit , request . offset ) ; } param projectId param request addProjectMember ( projectId , request ) { const url = `${ this . url }/projects/${ projectId }/members` ; return this . post ( url , request , this . defaultConfig ( ) ) ; } param projectId param memberId getProjectMemberPermissions ( projectId , memberId ) { const url = `${ this . url }/projects/${ projectId }/members/${ memberId }` ; return this . get ( url , this . defaultConfig ( ) ) ; } param projectId param memberId replaceProjectMemberPermissions ( projectId , memberId , request ) { const url = `${ this . url }/projects/${ projectId }/members/${ memberId }` ; return this . put ( url , request , this . defaultConfig ( ) ) ; } param projectId param memberId deleteMemberFromProject ( projectId , memberId ) { const url = `${ this . url }/projects/${ projectId }/members/${ memberId }` ; return this . delete ( url , this . defaultConfig ( ) ) ; } param status param search param twoFactor param limit param offset listUsers ( status ? , search ? , twoFactor ? , limit ? , offset ? ) ; listUsers ( statusOrRequest ? , search ? , twoFactor ? , limit ? , offset ? ) { let url = `${ this . url }/users` ; let request ; if ( statusOrRequest && typeof statusOrRequest === 'object' ) { request = statusOrRequest ; } else { request = { status : statusOrRequest , search , twoFactor , limit , offset } ; } url = this . addQueryParam ( url , 'status' , request . status ) ; url = this . addQueryParam ( url , 'search' , request . search ) ; url = this . addQueryParam ( url , 'twoFactor' , request . twoFactor ) ; return this . getList ( url , request . limit , request . offset ) ; } param userId getUserInfo ( userId ) { const url = `${ this . url }/users/${ userId }` ; return this . get ( url , this . defaultConfig ( ) ) ; } getAuthenticatedUser ( ) { const url = `${ this . url }/user` ; return this . get ( url , this . defaultConfig ( ) ) ; } } export namespace UsersModel { export interface ListProjectMembersRequest { search ? : string ; role ? : Role ; languageId ? : string ; limit ? : number ; offset ? : number ; } export interface ListUsersRequest { status ? : Status ; search ? : string ; twoFactor ? : TwoFactor ; limit ? : number ; offset ? : number ; } export interface User { id : number ; username : string ; email : string ; firstName : string ; lastName : string ; status : Status ; avatarUrl : string ; createdAt : string ; lastSeen : string ; twoFactor : string ; isAdmin : boolean ; timezone : string ; } export enum Status { ACTIVE = 'active' , PENDING = 'pending' , BLOCKED = 'blocked' } export enum TwoFactor { ENABLED = 'enabled' , DISABLED = 'disabled' } export interface ProjectMember { id : number ; username : string ; fullName : string ; role : Role ; permissions : { [ lang ] : LanguageRole | string ; } ; avatarUrl : string ; joinedAt : string ; timezone : string ; } export interface EnterpriseProjectMember { id : number ; username : string ; firstName : string ; lastName : string ; isManager : boolean ; managerOfGroup : Group ; accessToAllWorkflowSteps : boolean ; permissions : { [ lang ] : { workflowStepIds : number [ ] ; } ; } ; givenAccessAt : string ; } export interface Group { id : number ; name : string ; } export enum Role { ALL = 'all' , OWNER = 'owner' , MANAGER = 'manager' , PROOFREADER = 'proofreader' , TRANSLATOR = 'translator' , BLOCKED = 'blocked' } export enum LanguageRole { PROOFREADER = 'proofreader' , TRANSLATOR = 'translator' , DENIED = 'denied' } export interface AddProjectMemberRequest { userIds : number [ ] ; accessToAllWorkflowSteps ? : boolean ; managerAccess ? : boolean ; permissions ? : any ; } export interface AddProjectMemberResponse { skipped : ResponseObject < ProjectMember > [ ] ; added : ResponseObject < ProjectMember > [ ] ; pagination : Pagination ; } export interface ReplaceProjectMemberRequest { accessToAllWorkflowSteps ? : boolean ; managerAccess ? : boolean ; permissions ? : any ; } }