add account profile api
This commit is contained in:
parent
b5db9edc3f
commit
c3dad8fd1a
|
@ -12,6 +12,7 @@ import { CipherResponse } from '../models/response/cipherResponse';
|
||||||
import { FolderResponse } from '../models/response/folderResponse';
|
import { FolderResponse } from '../models/response/folderResponse';
|
||||||
import { IdentityTokenResponse } from '../models/response/identityTokenResponse';
|
import { IdentityTokenResponse } from '../models/response/identityTokenResponse';
|
||||||
import { IdentityTwoFactorResponse } from '../models/response/identityTwoFactorResponse';
|
import { IdentityTwoFactorResponse } from '../models/response/identityTwoFactorResponse';
|
||||||
|
import { ProfileResponse } from '../models/response/profileResponse';
|
||||||
import { SyncResponse } from '../models/response/syncResponse';
|
import { SyncResponse } from '../models/response/syncResponse';
|
||||||
|
|
||||||
export abstract class ApiService {
|
export abstract class ApiService {
|
||||||
|
@ -25,6 +26,7 @@ export abstract class ApiService {
|
||||||
postIdentityToken: (request: TokenRequest) => Promise<IdentityTokenResponse | IdentityTwoFactorResponse>;
|
postIdentityToken: (request: TokenRequest) => Promise<IdentityTokenResponse | IdentityTwoFactorResponse>;
|
||||||
refreshIdentityToken: () => Promise<any>;
|
refreshIdentityToken: () => Promise<any>;
|
||||||
postTwoFactorEmail: (request: TwoFactorEmailRequest) => Promise<any>;
|
postTwoFactorEmail: (request: TwoFactorEmailRequest) => Promise<any>;
|
||||||
|
getProfile: () => Promise<ProfileResponse>;
|
||||||
getAccountRevisionDate: () => Promise<number>;
|
getAccountRevisionDate: () => Promise<number>;
|
||||||
postPasswordHint: (request: PasswordHintRequest) => Promise<any>;
|
postPasswordHint: (request: PasswordHintRequest) => Promise<any>;
|
||||||
postRegister: (request: RegisterRequest) => Promise<any>;
|
postRegister: (request: RegisterRequest) => Promise<any>;
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
export enum OrganizationUserStatusType {
|
||||||
|
Invited = 0,
|
||||||
|
Accepted = 1,
|
||||||
|
Confirmed = 2,
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
export enum OrganizationUserType {
|
||||||
|
Owner = 0,
|
||||||
|
Admin = 1,
|
||||||
|
User = 2,
|
||||||
|
}
|
|
@ -1,27 +1,36 @@
|
||||||
|
import { OrganizationUserStatusType } from '../../enums/organizationUserStatusType';
|
||||||
|
import { OrganizationUserType } from '../../enums/organizationUserType';
|
||||||
|
|
||||||
export class ProfileOrganizationResponse {
|
export class ProfileOrganizationResponse {
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
useGroups: boolean;
|
useGroups: boolean;
|
||||||
useDirectory: boolean;
|
useDirectory: boolean;
|
||||||
|
useEvents: boolean;
|
||||||
useTotp: boolean;
|
useTotp: boolean;
|
||||||
|
use2fa: boolean;
|
||||||
seats: number;
|
seats: number;
|
||||||
maxCollections: number;
|
maxCollections: number;
|
||||||
maxStorageGb?: number;
|
maxStorageGb?: number;
|
||||||
key: string;
|
key: string;
|
||||||
status: number; // TODO: map to enum
|
status: OrganizationUserStatusType;
|
||||||
type: number; // TODO: map to enum
|
type: OrganizationUserType;
|
||||||
|
enabled: boolean;
|
||||||
|
|
||||||
constructor(response: any) {
|
constructor(response: any) {
|
||||||
this.id = response.Id;
|
this.id = response.Id;
|
||||||
this.name = response.Name;
|
this.name = response.Name;
|
||||||
this.useGroups = response.UseGroups;
|
this.useGroups = response.UseGroups;
|
||||||
this.useDirectory = response.UseDirectory;
|
this.useDirectory = response.UseDirectory;
|
||||||
|
this.useEvents = response.UseEvents;
|
||||||
this.useTotp = response.UseTotp;
|
this.useTotp = response.UseTotp;
|
||||||
|
this.use2fa = response.Use2fa;
|
||||||
this.seats = response.Seats;
|
this.seats = response.Seats;
|
||||||
this.maxCollections = response.MaxCollections;
|
this.maxCollections = response.MaxCollections;
|
||||||
this.maxStorageGb = response.MaxStorageGb;
|
this.maxStorageGb = response.MaxStorageGb;
|
||||||
this.key = response.Key;
|
this.key = response.Key;
|
||||||
this.status = response.Status;
|
this.status = response.Status;
|
||||||
this.type = response.Type;
|
this.type = response.Type;
|
||||||
|
this.enabled = response.Enabled;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ import { ErrorResponse } from '../models/response/errorResponse';
|
||||||
import { FolderResponse } from '../models/response/folderResponse';
|
import { FolderResponse } from '../models/response/folderResponse';
|
||||||
import { IdentityTokenResponse } from '../models/response/identityTokenResponse';
|
import { IdentityTokenResponse } from '../models/response/identityTokenResponse';
|
||||||
import { IdentityTwoFactorResponse } from '../models/response/identityTwoFactorResponse';
|
import { IdentityTwoFactorResponse } from '../models/response/identityTwoFactorResponse';
|
||||||
|
import { ProfileResponse } from '../models/response/profileResponse';
|
||||||
import { SyncResponse } from '../models/response/syncResponse';
|
import { SyncResponse } from '../models/response/syncResponse';
|
||||||
|
|
||||||
export class ApiService implements ApiServiceAbstraction {
|
export class ApiService implements ApiServiceAbstraction {
|
||||||
|
@ -134,6 +135,26 @@ export class ApiService implements ApiServiceAbstraction {
|
||||||
|
|
||||||
// Account APIs
|
// Account APIs
|
||||||
|
|
||||||
|
async getProfile(): Promise<ProfileResponse> {
|
||||||
|
const authHeader = await this.handleTokenState();
|
||||||
|
const response = await fetch(new Request(this.baseUrl + '/accounts/profile', {
|
||||||
|
cache: 'no-cache',
|
||||||
|
headers: new Headers({
|
||||||
|
'Accept': 'application/json',
|
||||||
|
'Authorization': authHeader,
|
||||||
|
'Device-Type': this.deviceType,
|
||||||
|
}),
|
||||||
|
}));
|
||||||
|
|
||||||
|
if (response.status === 200) {
|
||||||
|
const responseJson = await response.json();
|
||||||
|
return new ProfileResponse(responseJson);
|
||||||
|
} else {
|
||||||
|
const error = await this.handleError(response, false);
|
||||||
|
return Promise.reject(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async getAccountRevisionDate(): Promise<number> {
|
async getAccountRevisionDate(): Promise<number> {
|
||||||
const authHeader = await this.handleTokenState();
|
const authHeader = await this.handleTokenState();
|
||||||
const response = await fetch(new Request(this.baseUrl + '/accounts/revision-date', {
|
const response = await fetch(new Request(this.baseUrl + '/accounts/revision-date', {
|
||||||
|
|
Loading…
Reference in New Issue