1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 16:23:44 +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,10 +1,11 @@
import { BaseResponse } from './baseResponse';
import { CipherResponse } from './cipherResponse';
import { CollectionDetailsResponse } from './collectionResponse';
import { DomainsResponse } from './domainsResponse';
import { FolderResponse } from './folderResponse';
import { ProfileResponse } from './profileResponse';
export class SyncResponse {
export class SyncResponse extends BaseResponse {
profile?: ProfileResponse;
folders: FolderResponse[] = [];
collections: CollectionDetailsResponse[] = [];
@@ -12,30 +13,31 @@ export class SyncResponse {
domains?: DomainsResponse;
constructor(response: any) {
if (response.Profile) {
this.profile = new ProfileResponse(response.Profile);
super(response);
const profile = this.getResponseProperty('Profile');
if (profile != null) {
this.profile = new ProfileResponse(profile);
}
if (response.Folders) {
response.Folders.forEach((folder: any) => {
this.folders.push(new FolderResponse(folder));
});
const folders = this.getResponseProperty('Folders');
if (folders != null) {
this.folders = folders.map((f: any) => new FolderResponse(f));
}
if (response.Collections) {
response.Collections.forEach((collection: any) => {
this.collections.push(new CollectionDetailsResponse(collection));
});
const collections = this.getResponseProperty('Collections');
if (collections != null) {
this.collections = collections.map((c: any) => new CollectionDetailsResponse(c));
}
if (response.Ciphers) {
response.Ciphers.forEach((cipher: any) => {
this.ciphers.push(new CipherResponse(cipher));
});
const ciphers = this.getResponseProperty('Ciphers');
if (ciphers != null) {
this.ciphers = ciphers.map((c: any) => new CipherResponse(c));
}
if (response.Domains) {
this.domains = new DomainsResponse(response.Domains);
const domains = this.getResponseProperty('Domains');
if (domains != null) {
this.domains = new DomainsResponse(domains);
}
}
}