1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-18 01:03:35 +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,8 +1,10 @@
import { OrganizationUserStatusType } from '../../enums/organizationUserStatusType';
import { OrganizationUserType } from '../../enums/organizationUserType';
import { BaseResponse } from './baseResponse';
import { SelectionReadOnlyResponse } from './selectionReadOnlyResponse';
export class OrganizationUserResponse {
export class OrganizationUserResponse extends BaseResponse {
id: string;
userId: string;
type: OrganizationUserType;
@@ -10,11 +12,12 @@ export class OrganizationUserResponse {
accessAll: boolean;
constructor(response: any) {
this.id = response.Id;
this.userId = response.UserId;
this.type = response.Type;
this.status = response.Status;
this.accessAll = response.AccessAll;
super(response);
this.id = this.getResponseProperty('Id');
this.userId = this.getResponseProperty('UserId');
this.type = this.getResponseProperty('Type');
this.status = this.getResponseProperty('Status');
this.accessAll = this.getResponseProperty('AccessAll');
}
}
@@ -25,9 +28,9 @@ export class OrganizationUserUserDetailsResponse extends OrganizationUserRespons
constructor(response: any) {
super(response);
this.name = response.Name;
this.email = response.Email;
this.twoFactorEnabled = response.TwoFactorEnabled;
this.name = this.getResponseProperty('Name');
this.email = this.getResponseProperty('Email');
this.twoFactorEnabled = this.getResponseProperty('TwoFactorEnabled');
}
}
@@ -36,8 +39,9 @@ export class OrganizationUserDetailsResponse extends OrganizationUserResponse {
constructor(response: any) {
super(response);
if (response.Collections != null) {
this.collections = response.Collections.map((c: any) => new SelectionReadOnlyResponse(c));
const collections = this.getResponseProperty('Collections');
if (collections != null) {
this.collections = collections.map((c: any) => new SelectionReadOnlyResponse(c));
}
}
}