1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-19 09:43:23 +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,14 +1,16 @@
import { BaseResponse } from './baseResponse';
import { SelectionReadOnlyResponse } from './selectionReadOnlyResponse';
export class CollectionResponse {
export class CollectionResponse extends BaseResponse {
id: string;
organizationId: string;
name: string;
constructor(response: any) {
this.id = response.Id;
this.organizationId = response.OrganizationId;
this.name = response.Name;
super(response);
this.id = this.getResponseProperty('Id');
this.organizationId = this.getResponseProperty('OrganizationId');
this.name = this.getResponseProperty('Name');
}
}
@@ -17,7 +19,7 @@ export class CollectionDetailsResponse extends CollectionResponse {
constructor(response: any) {
super(response);
this.readOnly = response.ReadOnly || false;
this.readOnly = this.getResponseProperty('ReadOnly') || false;
}
}
@@ -26,8 +28,9 @@ export class CollectionGroupDetailsResponse extends CollectionResponse {
constructor(response: any) {
super(response);
if (response.Groups != null) {
this.groups = response.Groups.map((g: any) => new SelectionReadOnlyResponse(g));
const groups = this.getResponseProperty('Groups');
if (groups != null) {
this.groups = groups.map((g: any) => new SelectionReadOnlyResponse(g));
}
}
}