1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-17 16:53:34 +00:00

support camel or pascal case in API responses

This commit is contained in:
Kyle Spearrin
2019-03-01 00:13:37 -05:00
parent 62e9c75357
commit 48164a31d9
43 changed files with 637 additions and 449 deletions

View File

@@ -1,4 +1,6 @@
export class CardApi {
import { BaseResponse } from '../response/baseResponse';
export class CardApi extends BaseResponse {
cardholderName: string;
brand: string;
number: string;
@@ -6,12 +8,16 @@ export class CardApi {
expYear: string;
code: string;
constructor(data: any) {
this.cardholderName = data.CardholderName;
this.brand = data.Brand;
this.number = data.Number;
this.expMonth = data.ExpMonth;
this.expYear = data.ExpYear;
this.code = data.Code;
constructor(data: any = null) {
super(data);
if (data == null) {
return;
}
this.cardholderName = this.getResponseProperty('CardholderName');
this.brand = this.getResponseProperty('Brand');
this.number = this.getResponseProperty('Number');
this.expMonth = this.getResponseProperty('ExpMonth');
this.expYear = this.getResponseProperty('ExpYear');
this.code = this.getResponseProperty('Code');
}
}

View File

@@ -1,13 +1,19 @@
import { BaseResponse } from '../response/baseResponse';
import { FieldType } from '../../enums/fieldType';
export class FieldApi {
export class FieldApi extends BaseResponse {
name: string;
value: string;
type: FieldType;
constructor(response: any) {
this.type = response.Type;
this.name = response.Name;
this.value = response.Value;
constructor(data: any = null) {
super(data);
if (data == null) {
return;
}
this.type = this.getResponseProperty('Type');
this.name = this.getResponseProperty('Name');
this.value = this.getResponseProperty('Value');
}
}

View File

@@ -1,4 +1,6 @@
export class IdentityApi {
import { BaseResponse } from '../response/baseResponse';
export class IdentityApi extends BaseResponse {
title: string;
firstName: string;
middleName: string;
@@ -18,24 +20,28 @@ export class IdentityApi {
passportNumber: string;
licenseNumber: string;
constructor(data: any) {
this.title = data.Title;
this.firstName = data.FirstName;
this.middleName = data.MiddleName;
this.lastName = data.LastName;
this.address1 = data.Address1;
this.address2 = data.Address2;
this.address3 = data.Address3;
this.city = data.City;
this.state = data.State;
this.postalCode = data.PostalCode;
this.country = data.Country;
this.company = data.Company;
this.email = data.Email;
this.phone = data.Phone;
this.ssn = data.SSN;
this.username = data.Username;
this.passportNumber = data.PassportNumber;
this.licenseNumber = data.LicenseNumber;
constructor(data: any = null) {
super(data);
if (data == null) {
return;
}
this.title = this.getResponseProperty('Title');
this.firstName = this.getResponseProperty('FirstName');
this.middleName = this.getResponseProperty('MiddleName');
this.lastName = this.getResponseProperty('LastName');
this.address1 = this.getResponseProperty('Address1');
this.address2 = this.getResponseProperty('Address2');
this.address3 = this.getResponseProperty('Address3');
this.city = this.getResponseProperty('City');
this.state = this.getResponseProperty('State');
this.postalCode = this.getResponseProperty('PostalCode');
this.country = this.getResponseProperty('Country');
this.company = this.getResponseProperty('Company');
this.email = this.getResponseProperty('Email');
this.phone = this.getResponseProperty('Phone');
this.ssn = this.getResponseProperty('SSN');
this.username = this.getResponseProperty('Username');
this.passportNumber = this.getResponseProperty('PassportNumber');
this.licenseNumber = this.getResponseProperty('LicenseNumber');
}
}

View File

@@ -1,23 +1,27 @@
import { BaseResponse } from '../response/baseResponse';
import { LoginUriApi } from './loginUriApi';
export class LoginApi {
export class LoginApi extends BaseResponse {
uris: LoginUriApi[];
username: string;
password: string;
passwordRevisionDate: string;
totp: string;
constructor(data: any) {
this.username = data.Username;
this.password = data.Password;
this.passwordRevisionDate = data.PasswordRevisionDate;
this.totp = data.Totp;
constructor(data: any = null) {
super(data);
if (data == null) {
return;
}
this.username = this.getResponseProperty('Username');
this.password = this.getResponseProperty('Password');
this.passwordRevisionDate = this.getResponseProperty('PasswordRevisionDate');
this.totp = this.getResponseProperty('Totp');
if (data.Uris) {
this.uris = [];
data.Uris.forEach((u: any) => {
this.uris.push(new LoginUriApi(u));
});
const uris = this.getResponseProperty('Uris');
if (uris != null) {
this.uris = uris.map((u: any) => new LoginUriApi(u));
}
}
}

View File

@@ -1,11 +1,18 @@
import { BaseResponse } from '../response/baseResponse';
import { UriMatchType } from '../../enums/uriMatchType';
export class LoginUriApi {
export class LoginUriApi extends BaseResponse {
uri: string;
match: UriMatchType = null;
constructor(data: any) {
this.uri = data.Uri;
this.match = data.Match != null ? data.Match : null;
constructor(data: any = null) {
super(data);
if (data == null) {
return;
}
this.uri = this.getResponseProperty('Uri');
const match = this.getResponseProperty('Match');
this.match = match != null ? match : null;
}
}

View File

@@ -1,9 +1,15 @@
import { BaseResponse } from '../response/baseResponse';
import { SecureNoteType } from '../../enums/secureNoteType';
export class SecureNoteApi {
export class SecureNoteApi extends BaseResponse {
type: SecureNoteType;
constructor(data: any) {
this.type = data.Type;
constructor(data: any = null) {
super(data);
if (data == null) {
return;
}
this.type = this.getResponseProperty('Type');
}
}