bitwarden-estensione-browser/apps/cli/src/models/response/cipherResponse.ts

34 lines
1.2 KiB
TypeScript
Raw Normal View History

2022-03-03 18:24:41 +01:00
import { CipherType } from "jslib-common/enums/cipherType";
import { CipherWithIdExport } from "jslib-common/models/export/cipherWithIdsExport";
2021-12-20 18:04:00 +01:00
import { CipherView } from "jslib-common/models/view/cipherView";
import { BaseResponse } from "jslib-node/cli/models/response/baseResponse";
2019-03-16 03:34:59 +01:00
2021-12-20 18:04:00 +01:00
import { AttachmentResponse } from "./attachmentResponse";
import { LoginResponse } from "./loginResponse";
import { PasswordHistoryResponse } from "./passwordHistoryResponse";
export class CipherResponse extends CipherWithIdExport implements BaseResponse {
2021-12-20 18:04:00 +01:00
object: string;
attachments: AttachmentResponse[];
revisionDate: Date;
2022-02-04 23:50:59 +01:00
deletedDate: Date;
2021-12-20 18:04:00 +01:00
passwordHistory: PasswordHistoryResponse[];
2018-05-14 20:54:19 +02:00
2021-12-20 18:04:00 +01:00
constructor(o: CipherView) {
super();
this.object = "item";
this.build(o);
if (o.attachments != null) {
this.attachments = o.attachments.map((a) => new AttachmentResponse(a));
2018-05-14 20:54:19 +02:00
}
2021-12-20 18:04:00 +01:00
this.revisionDate = o.revisionDate;
2022-02-04 23:50:59 +01:00
this.deletedDate = o.deletedDate;
2021-12-20 18:04:00 +01:00
if (o.passwordHistory != null) {
this.passwordHistory = o.passwordHistory.map((h) => new PasswordHistoryResponse(h));
}
if (o.type === CipherType.Login && o.login != null) {
this.login = new LoginResponse(o.login);
}
}
2018-05-14 20:54:19 +02:00
}