diff --git a/src/abstractions/api.service.ts b/src/abstractions/api.service.ts index 6600b8ccbb..07cc8118d0 100644 --- a/src/abstractions/api.service.ts +++ b/src/abstractions/api.service.ts @@ -16,6 +16,11 @@ import { ImportDirectoryRequest } from '../models/request/importDirectoryRequest import { ImportOrganizationCiphersRequest } from '../models/request/importOrganizationCiphersRequest'; import { KeysRequest } from '../models/request/keysRequest'; import { OrganizationCreateRequest } from '../models/request/organizationCreateRequest'; +import { OrganizationUserAcceptRequest } from '../models/request/organizationUserAcceptRequest'; +import { OrganizationUserConfirmRequest } from '../models/request/organizationUserConfirmRequest'; +import { OrganizationUserInviteRequest } from '../models/request/organizationUserInviteRequest'; +import { OrganizationUserUpdateGroupsRequest } from '../models/request/organizationUserUpdateGroupsRequest'; +import { OrganizationUserUpdateRequest } from '../models/request/organizationUserUpdateRequest'; import { PasswordHintRequest } from '../models/request/passwordHintRequest'; import { PasswordRequest } from '../models/request/passwordRequest'; import { PasswordVerificationRequest } from '../models/request/passwordVerificationRequest'; @@ -53,7 +58,10 @@ import { IdentityTokenResponse } from '../models/response/identityTokenResponse' import { IdentityTwoFactorResponse } from '../models/response/identityTwoFactorResponse'; import { ListResponse } from '../models/response/listResponse'; import { OrganizationResponse } from '../models/response/organizationResponse'; -import { OrganizationUserUserDetailsResponse } from '../models/response/organizationUserResponse'; +import { + OrganizationUserDetailsResponse, + OrganizationUserUserDetailsResponse, +} from '../models/response/organizationUserResponse'; import { ProfileResponse } from '../models/response/profileResponse'; import { SyncResponse } from '../models/response/syncResponse'; import { TwoFactorAuthenticatorResponse } from '../models/response/twoFactorAuthenticatorResponse'; @@ -138,7 +146,19 @@ export abstract class ApiService { deleteGroup: (organizationId: string, id: string) => Promise; deleteGroupUser: (organizationId: string, id: string, organizationUserId: string) => Promise; + getOrganizationUser: (organizationId: string, id: string) => Promise; + getOrganizationUserGroups: (organizationId: string, id: string) => Promise; getOrganizationUsers: (organizationId: string) => Promise>; + postOrganizationUserInvite: (organizationId: string, request: OrganizationUserInviteRequest) => Promise; + postOrganizationUserReinvite: (organizationId: string, id: string) => Promise; + postOrganizationUserAccept: (organizationId: string, id: string, + request: OrganizationUserAcceptRequest) => Promise; + postOrganizationUserConfirm: (organizationId: string, id: string, + request: OrganizationUserConfirmRequest) => Promise; + putOrganizationUser: (organizationId: string, id: string, request: OrganizationUserUpdateRequest) => Promise; + putOrganizationUserGroups: (organizationId: string, id: string, + request: OrganizationUserUpdateGroupsRequest) => Promise; + deleteOrganizationUser: (organizationId: string, id: string) => Promise; getSync: () => Promise; postImportDirectory: (organizationId: string, request: ImportDirectoryRequest) => Promise; diff --git a/src/models/request/organizationUserAcceptRequest.ts b/src/models/request/organizationUserAcceptRequest.ts new file mode 100644 index 0000000000..acd36a679e --- /dev/null +++ b/src/models/request/organizationUserAcceptRequest.ts @@ -0,0 +1,3 @@ +export class OrganizationUserAcceptRequest { + token: string; +} diff --git a/src/models/request/organizationUserConfirmRequest.ts b/src/models/request/organizationUserConfirmRequest.ts new file mode 100644 index 0000000000..c4d233052a --- /dev/null +++ b/src/models/request/organizationUserConfirmRequest.ts @@ -0,0 +1,3 @@ +export class OrganizationUserConfirmRequest { + key: string; +} diff --git a/src/models/request/organizationUserInviteRequest.ts b/src/models/request/organizationUserInviteRequest.ts new file mode 100644 index 0000000000..79371e99ed --- /dev/null +++ b/src/models/request/organizationUserInviteRequest.ts @@ -0,0 +1,10 @@ +import { OrganizationUserType } from '../../enums/organizationUserType'; + +import { SelectionReadOnlyRequest } from './selectionReadOnlyRequest'; + +export class OrganizationUserInviteRequest { + emails: string[] = []; + type: OrganizationUserType; + accessAll: boolean; + collections: SelectionReadOnlyRequest[] = []; +} diff --git a/src/models/request/organizationUserUpdateGroupsRequest.ts b/src/models/request/organizationUserUpdateGroupsRequest.ts new file mode 100644 index 0000000000..0d7805ccdf --- /dev/null +++ b/src/models/request/organizationUserUpdateGroupsRequest.ts @@ -0,0 +1,3 @@ +export class OrganizationUserUpdateGroupsRequest { + groupIds: string[] = []; +} diff --git a/src/models/request/organizationUserUpdateRequest.ts b/src/models/request/organizationUserUpdateRequest.ts new file mode 100644 index 0000000000..7b8c9cd237 --- /dev/null +++ b/src/models/request/organizationUserUpdateRequest.ts @@ -0,0 +1,9 @@ +import { OrganizationUserType } from '../../enums/organizationUserType'; + +import { SelectionReadOnlyRequest } from './selectionReadOnlyRequest'; + +export class OrganizationUserUpdateRequest { + type: OrganizationUserType; + accessAll: boolean; + collections: SelectionReadOnlyRequest[] = []; +} diff --git a/src/services/api.service.ts b/src/services/api.service.ts index 54a34f2d0d..4a72e469ad 100644 --- a/src/services/api.service.ts +++ b/src/services/api.service.ts @@ -22,6 +22,11 @@ import { ImportDirectoryRequest } from '../models/request/importDirectoryRequest import { ImportOrganizationCiphersRequest } from '../models/request/importOrganizationCiphersRequest'; import { KeysRequest } from '../models/request/keysRequest'; import { OrganizationCreateRequest } from '../models/request/organizationCreateRequest'; +import { OrganizationUserAcceptRequest } from '../models/request/organizationUserAcceptRequest'; +import { OrganizationUserConfirmRequest } from '../models/request/organizationUserConfirmRequest'; +import { OrganizationUserInviteRequest } from '../models/request/organizationUserInviteRequest'; +import { OrganizationUserUpdateGroupsRequest } from '../models/request/organizationUserUpdateGroupsRequest'; +import { OrganizationUserUpdateRequest } from '../models/request/organizationUserUpdateRequest'; import { PasswordHintRequest } from '../models/request/passwordHintRequest'; import { PasswordRequest } from '../models/request/passwordRequest'; import { PasswordVerificationRequest } from '../models/request/passwordVerificationRequest'; @@ -60,7 +65,10 @@ import { IdentityTokenResponse } from '../models/response/identityTokenResponse' import { IdentityTwoFactorResponse } from '../models/response/identityTwoFactorResponse'; import { ListResponse } from '../models/response/listResponse'; import { OrganizationResponse } from '../models/response/organizationResponse'; -import { OrganizationUserUserDetailsResponse } from '../models/response/organizationUserResponse'; +import { + OrganizationUserDetailsResponse, + OrganizationUserUserDetailsResponse, +} from '../models/response/organizationUserResponse'; import { ProfileResponse } from '../models/response/profileResponse'; import { SyncResponse } from '../models/response/syncResponse'; import { TwoFactorAuthenticatorResponse } from '../models/response/twoFactorAuthenticatorResponse'; @@ -444,11 +452,54 @@ export class ApiService implements ApiServiceAbstraction { // Organization User APIs + async getOrganizationUser(organizationId: string, id: string): Promise { + const r = await this.send('GET', '/organizations/' + organizationId + '/users/' + id, null, true, true); + return new OrganizationUserDetailsResponse(r); + } + + async getOrganizationUserGroups(organizationId: string, id: string): Promise { + const r = await this.send('GET', '/organizations/' + organizationId + '/users/' + id + '/groups', + null, true, true); + return r; + } + async getOrganizationUsers(organizationId: string): Promise> { const r = await this.send('GET', '/organizations/' + organizationId + '/users', null, true, true); return new ListResponse(r, OrganizationUserUserDetailsResponse); } + postOrganizationUserInvite(organizationId: string, request: OrganizationUserInviteRequest): Promise { + return this.send('POST', '/organizations/' + organizationId + '/users/invite', request, true, false); + } + + postOrganizationUserReinvite(organizationId: string, id: string): Promise { + return this.send('POST', '/organizations/' + organizationId + '/users/' + id + '/reinvite', null, true, false); + } + + postOrganizationUserAccept(organizationId: string, id: string, + request: OrganizationUserAcceptRequest): Promise { + return this.send('POST', '/organizations/' + organizationId + '/users/' + id + '/accept', request, true, false); + } + + postOrganizationUserConfirm(organizationId: string, id: string, + request: OrganizationUserConfirmRequest): Promise { + return this.send('POST', '/organizations/' + organizationId + '/users/' + id + '/confirm', + request, true, false); + } + + putOrganizationUser(organizationId: string, id: string, request: OrganizationUserUpdateRequest): Promise { + return this.send('PUT', '/organizations/' + organizationId + '/users/' + id, request, true, false); + } + + putOrganizationUserGroups(organizationId: string, id: string, + request: OrganizationUserUpdateGroupsRequest): Promise { + return this.send('PUT', '/organizations/' + organizationId + '/users/' + id + '/groups', request, true, false); + } + + deleteOrganizationUser(organizationId: string, id: string): Promise { + return this.send('DELETE', '/organizations/' + organizationId + '/users/' + id, null, true, false); + } + // Sync APIs async getSync(): Promise {