mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 08:43:33 +00:00
apis for groups and collections
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { CollectionResponse } from '../response/collectionResponse';
|
||||
import { CollectionDetailsResponse } from '../response/collectionResponse';
|
||||
|
||||
export class CollectionData {
|
||||
id: string;
|
||||
@@ -6,7 +6,7 @@ export class CollectionData {
|
||||
name: string;
|
||||
readOnly: boolean;
|
||||
|
||||
constructor(response: CollectionResponse) {
|
||||
constructor(response: CollectionDetailsResponse) {
|
||||
this.id = response.id;
|
||||
this.organizationId = response.organizationId;
|
||||
this.name = response.name;
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import { Collection } from '../domain/collection';
|
||||
|
||||
import { SelectionReadOnlyRequest } from './selectionReadOnlyRequest';
|
||||
|
||||
export class CollectionRequest {
|
||||
name: string;
|
||||
groups: SelectionReadOnlyRequest[] = [];
|
||||
|
||||
constructor(collection: Collection) {
|
||||
this.name = collection.name ? collection.name.encryptedString : null;
|
||||
|
||||
8
src/models/request/groupRequest.ts
Normal file
8
src/models/request/groupRequest.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { SelectionReadOnlyRequest } from './selectionReadOnlyRequest';
|
||||
|
||||
export class GroupRequest {
|
||||
name: string;
|
||||
accessAll: boolean;
|
||||
externalId: string;
|
||||
collections: SelectionReadOnlyRequest[] = [];
|
||||
}
|
||||
9
src/models/request/selectionReadOnlyRequest.ts
Normal file
9
src/models/request/selectionReadOnlyRequest.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
export class SelectionReadOnlyRequest {
|
||||
id: string;
|
||||
readOnly: boolean;
|
||||
|
||||
constructor(id: string, readOnly: boolean) {
|
||||
this.id = id;
|
||||
this.readOnly = readOnly;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,33 @@
|
||||
import { SelectionReadOnlyResponse } from './selectionReadOnlyResponse';
|
||||
|
||||
export class CollectionResponse {
|
||||
id: string;
|
||||
organizationId: string;
|
||||
name: string;
|
||||
readOnly: boolean;
|
||||
|
||||
constructor(response: any) {
|
||||
this.id = response.Id;
|
||||
this.organizationId = response.OrganizationId;
|
||||
this.name = response.Name;
|
||||
}
|
||||
}
|
||||
|
||||
export class CollectionDetailsResponse extends CollectionResponse {
|
||||
readOnly: boolean;
|
||||
|
||||
constructor(response: any) {
|
||||
super(response);
|
||||
this.readOnly = response.ReadOnly || false;
|
||||
}
|
||||
}
|
||||
|
||||
export class CollectionGroupDetailsResponse extends CollectionResponse {
|
||||
groups: SelectionReadOnlyResponse[] = [];
|
||||
|
||||
constructor(response: any) {
|
||||
super(response);
|
||||
if (response.Groups != null) {
|
||||
this.groups = response.Collections.map((g: any) => new SelectionReadOnlyResponse(g));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
22
src/models/response/collectionUserResponse.ts
Normal file
22
src/models/response/collectionUserResponse.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { OrganizationUserStatusType } from '../../enums/organizationUserStatusType';
|
||||
import { OrganizationUserType } from '../../enums/organizationUserType';
|
||||
|
||||
export class CollectionUserResponse {
|
||||
organizationUserId: string;
|
||||
accessAll: boolean;
|
||||
name: string;
|
||||
email: string;
|
||||
type: OrganizationUserType;
|
||||
status: OrganizationUserStatusType;
|
||||
readOnly: boolean;
|
||||
|
||||
constructor(response: any) {
|
||||
this.organizationUserId = response.OrganizationUserId;
|
||||
this.accessAll = response.AccessAll;
|
||||
this.name = response.Name;
|
||||
this.email = response.Email;
|
||||
this.type = response.Type;
|
||||
this.status = response.Status;
|
||||
this.readOnly = response.ReadOnly;
|
||||
}
|
||||
}
|
||||
28
src/models/response/groupResponse.ts
Normal file
28
src/models/response/groupResponse.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { SelectionReadOnlyResponse } from './selectionReadOnlyResponse';
|
||||
|
||||
export class GroupResponse {
|
||||
id: string;
|
||||
organizationId: string;
|
||||
name: string;
|
||||
accessAll: boolean;
|
||||
externalId: string;
|
||||
|
||||
constructor(response: any) {
|
||||
this.id = response.Id;
|
||||
this.organizationId = response.OrganizationId;
|
||||
this.name = response.Name;
|
||||
this.accessAll = response.AccessAll;
|
||||
this.externalId = response.ExternalId;
|
||||
}
|
||||
}
|
||||
|
||||
export class GroupDetailsResponse extends GroupResponse {
|
||||
collections: SelectionReadOnlyResponse[] = [];
|
||||
|
||||
constructor(response: any) {
|
||||
super(response);
|
||||
if (response.Collections != null) {
|
||||
this.collections = response.Collections.map((c: any) => new SelectionReadOnlyResponse(c));
|
||||
}
|
||||
}
|
||||
}
|
||||
20
src/models/response/groupUserResponse.ts
Normal file
20
src/models/response/groupUserResponse.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { OrganizationUserStatusType } from '../../enums/organizationUserStatusType';
|
||||
import { OrganizationUserType } from '../../enums/organizationUserType';
|
||||
|
||||
export class GroupUserResponse {
|
||||
organizationUserId: string;
|
||||
accessAll: boolean;
|
||||
name: string;
|
||||
email: string;
|
||||
type: OrganizationUserType;
|
||||
status: OrganizationUserStatusType;
|
||||
|
||||
constructor(response: any) {
|
||||
this.organizationUserId = response.OrganizationUserId;
|
||||
this.accessAll = response.AccessAll;
|
||||
this.name = response.Name;
|
||||
this.email = response.Email;
|
||||
this.type = response.Type;
|
||||
this.status = response.Status;
|
||||
}
|
||||
}
|
||||
9
src/models/response/selectionReadOnlyResponse.ts
Normal file
9
src/models/response/selectionReadOnlyResponse.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
export class SelectionReadOnlyResponse {
|
||||
id: string;
|
||||
readOnly: boolean;
|
||||
|
||||
constructor(response: any) {
|
||||
this.id = response.Id;
|
||||
this.readOnly = response.ReadOnly;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { CipherResponse } from './cipherResponse';
|
||||
import { CollectionResponse } from './collectionResponse';
|
||||
import { CollectionDetailsResponse } from './collectionResponse';
|
||||
import { DomainsResponse } from './domainsResponse';
|
||||
import { FolderResponse } from './folderResponse';
|
||||
import { ProfileResponse } from './profileResponse';
|
||||
@@ -7,7 +7,7 @@ import { ProfileResponse } from './profileResponse';
|
||||
export class SyncResponse {
|
||||
profile?: ProfileResponse;
|
||||
folders: FolderResponse[] = [];
|
||||
collections: CollectionResponse[] = [];
|
||||
collections: CollectionDetailsResponse[] = [];
|
||||
ciphers: CipherResponse[] = [];
|
||||
domains?: DomainsResponse;
|
||||
|
||||
@@ -24,7 +24,7 @@ export class SyncResponse {
|
||||
|
||||
if (response.Collections) {
|
||||
response.Collections.forEach((collection: any) => {
|
||||
this.collections.push(new CollectionResponse(collection));
|
||||
this.collections.push(new CollectionDetailsResponse(collection));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user