1
0
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:
Kyle Spearrin
2018-07-06 12:40:43 -04:00
parent 4ae4b667ff
commit 2a526940fd
12 changed files with 198 additions and 9 deletions

View File

@@ -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;

View File

@@ -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;

View File

@@ -0,0 +1,8 @@
import { SelectionReadOnlyRequest } from './selectionReadOnlyRequest';
export class GroupRequest {
name: string;
accessAll: boolean;
externalId: string;
collections: SelectionReadOnlyRequest[] = [];
}

View File

@@ -0,0 +1,9 @@
export class SelectionReadOnlyRequest {
id: string;
readOnly: boolean;
constructor(id: string, readOnly: boolean) {
this.id = id;
this.readOnly = readOnly;
}
}

View File

@@ -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));
}
}
}

View 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;
}
}

View 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));
}
}
}

View 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;
}
}

View File

@@ -0,0 +1,9 @@
export class SelectionReadOnlyResponse {
id: string;
readOnly: boolean;
constructor(response: any) {
this.id = response.Id;
this.readOnly = response.ReadOnly;
}
}

View File

@@ -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));
});
}