1
0
mirror of https://github.com/bitwarden/browser synced 2026-03-01 19:11:22 +00:00

[SM-288] Rename models to follow naming convention (#3795)

This commit is contained in:
Oscar Hinton
2022-10-14 18:25:50 +02:00
committed by GitHub
parent 1fd8d316a1
commit e941f06bac
445 changed files with 939 additions and 938 deletions

View File

@@ -0,0 +1,65 @@
import { Card as CardDomain } from "../domain/card";
import { EncString } from "../domain/enc-string";
import { CardView } from "../view/card.view";
export class CardExport {
static template(): CardExport {
const req = new CardExport();
req.cardholderName = "John Doe";
req.brand = "visa";
req.number = "4242424242424242";
req.expMonth = "04";
req.expYear = "2023";
req.code = "123";
return req;
}
static toView(req: CardExport, view = new CardView()) {
view.cardholderName = req.cardholderName;
view.brand = req.brand;
view.number = req.number;
view.expMonth = req.expMonth;
view.expYear = req.expYear;
view.code = req.code;
return view;
}
static toDomain(req: CardExport, domain = new CardDomain()) {
domain.cardholderName = req.cardholderName != null ? new EncString(req.cardholderName) : null;
domain.brand = req.brand != null ? new EncString(req.brand) : null;
domain.number = req.number != null ? new EncString(req.number) : null;
domain.expMonth = req.expMonth != null ? new EncString(req.expMonth) : null;
domain.expYear = req.expYear != null ? new EncString(req.expYear) : null;
domain.code = req.code != null ? new EncString(req.code) : null;
return domain;
}
cardholderName: string;
brand: string;
number: string;
expMonth: string;
expYear: string;
code: string;
constructor(o?: CardView | CardDomain) {
if (o == null) {
return;
}
if (o instanceof CardView) {
this.cardholderName = o.cardholderName;
this.brand = o.brand;
this.number = o.number;
this.expMonth = o.expMonth;
this.expYear = o.expYear;
this.code = o.code;
} else {
this.cardholderName = o.cardholderName?.encryptedString;
this.brand = o.brand?.encryptedString;
this.number = o.number?.encryptedString;
this.expMonth = o.expMonth?.encryptedString;
this.expYear = o.expYear?.encryptedString;
this.code = o.code?.encryptedString;
}
}
}