1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 16:23:44 +00:00

refactor req/res models

This commit is contained in:
Kyle Spearrin
2018-05-15 12:18:47 -04:00
parent 1d3ed93bff
commit 07cc64c0b8
25 changed files with 363 additions and 229 deletions

View File

@@ -1,9 +1,3 @@
export abstract class BaseResponse {
export interface BaseResponse {
object: string;
constructor(object?: string) {
if (object != null) {
this.object = object;
}
}
}

View File

@@ -2,21 +2,15 @@ import { CipherView } from 'jslib/models/view/cipherView';
import { BaseResponse } from './baseResponse';
import { CipherType } from 'jslib/enums';
import { Cipher } from '../cipher';
export class CipherResponse extends BaseResponse {
export class CipherResponse extends Cipher implements BaseResponse {
object: string;
id: string;
organizationId: string;
type: CipherType;
name: string;
notes: string;
constructor(o: CipherView) {
super('item');
super(o);
this.object = 'item';
this.id = o.id;
this.organizationId = o.organizationId;
this.type = o.type;
this.name = o.name;
this.notes = o.notes;
}
}

View File

@@ -2,15 +2,15 @@ import { CollectionView } from 'jslib/models/view/collectionView';
import { BaseResponse } from './baseResponse';
export class CollectionResponse extends BaseResponse {
import { Collection } from '../collection';
export class CollectionResponse extends Collection implements BaseResponse {
object: string;
id: string;
organizationId: string;
name: string;
constructor(o: CollectionView) {
super('collection');
super(o);
this.object = 'collection';
this.id = o.id;
this.organizationId = o.organizationId;
this.name = o.name;
}
}

View File

@@ -2,13 +2,15 @@ import { FolderView } from 'jslib/models/view/folderView';
import { BaseResponse } from './baseResponse';
export class FolderResponse extends BaseResponse {
import { Folder } from '../folder';
export class FolderResponse extends Folder implements BaseResponse {
object: string;
id: string;
name: string;
constructor(o: FolderView) {
super('folder');
super(o);
this.object = 'folder';
this.id = o.id;
this.name = o.name;
}
}

View File

@@ -1,10 +1,11 @@
import { BaseResponse } from './baseResponse';
export class ListResponse extends BaseResponse {
export class ListResponse implements BaseResponse {
object: string;
data: BaseResponse[];
constructor(data: BaseResponse[]) {
super('list');
this.object = 'list';
this.data = data;
}
}

View File

@@ -1,14 +1,11 @@
import { CipherView } from 'jslib/models/view/cipherView';
import { BaseResponse } from './baseResponse';
import { CipherType } from 'jslib/enums';
export class StringResponse extends BaseResponse {
export class StringResponse implements BaseResponse {
object: string;
data: string;
constructor(data: string) {
super('string');
this.object = 'string';
this.data = data;
}
}

View File

@@ -1,10 +1,11 @@
import { BaseResponse } from './baseResponse';
export class TemplateResponse extends BaseResponse {
export class TemplateResponse implements BaseResponse {
object: string;
template: any;
constructor(template: any) {
super('template');
this.object = 'template';
this.template = template;
}
}