put profile
This commit is contained in:
parent
6e501dddb9
commit
d98aeab0c8
|
@ -12,6 +12,7 @@ import { PasswordHintRequest } from '../models/request/passwordHintRequest';
|
|||
import { RegisterRequest } from '../models/request/registerRequest';
|
||||
import { TokenRequest } from '../models/request/tokenRequest';
|
||||
import { TwoFactorEmailRequest } from '../models/request/twoFactorEmailRequest';
|
||||
import { UpdateProfileRequest } from '../models/request/updateProfileRequest';
|
||||
|
||||
import { CipherResponse } from '../models/response/cipherResponse';
|
||||
import { FolderResponse } from '../models/response/folderResponse';
|
||||
|
@ -20,8 +21,6 @@ import { IdentityTwoFactorResponse } from '../models/response/identityTwoFactorR
|
|||
import { ProfileResponse } from '../models/response/profileResponse';
|
||||
import { SyncResponse } from '../models/response/syncResponse';
|
||||
|
||||
import { AttachmentView } from '../models/view/attachmentView';
|
||||
|
||||
export abstract class ApiService {
|
||||
urlsSet: boolean;
|
||||
apiBaseUrl: string;
|
||||
|
@ -32,6 +31,7 @@ export abstract class ApiService {
|
|||
refreshIdentityToken: () => Promise<any>;
|
||||
postTwoFactorEmail: (request: TwoFactorEmailRequest) => Promise<any>;
|
||||
getProfile: () => Promise<ProfileResponse>;
|
||||
putProfile: (request: UpdateProfileRequest) => Promise<ProfileResponse>;
|
||||
getAccountRevisionDate: () => Promise<number>;
|
||||
postPasswordHint: (request: PasswordHintRequest) => Promise<any>;
|
||||
postRegister: (request: RegisterRequest) => Promise<any>;
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
export class UpdateProfileRequest {
|
||||
name: string;
|
||||
masterPasswordHint: string;
|
||||
culture = 'en-US'; // deprecated
|
||||
|
||||
constructor(name: string, masterPasswordHint: string) {
|
||||
this.name = name;
|
||||
this.masterPasswordHint = masterPasswordHint ? masterPasswordHint : null;
|
||||
}
|
||||
}
|
|
@ -18,6 +18,7 @@ import { PasswordHintRequest } from '../models/request/passwordHintRequest';
|
|||
import { RegisterRequest } from '../models/request/registerRequest';
|
||||
import { TokenRequest } from '../models/request/tokenRequest';
|
||||
import { TwoFactorEmailRequest } from '../models/request/twoFactorEmailRequest';
|
||||
import { UpdateProfileRequest } from '../models/request/updateProfileRequest';
|
||||
|
||||
import { CipherResponse } from '../models/response/cipherResponse';
|
||||
import { ErrorResponse } from '../models/response/errorResponse';
|
||||
|
@ -172,6 +173,30 @@ export class ApiService implements ApiServiceAbstraction {
|
|||
}
|
||||
}
|
||||
|
||||
async putProfile(request: UpdateProfileRequest): Promise<ProfileResponse> {
|
||||
const authHeader = await this.handleTokenState();
|
||||
const response = await fetch(new Request(this.apiBaseUrl + '/accounts/profile', {
|
||||
body: JSON.stringify(request),
|
||||
cache: 'no-cache',
|
||||
credentials: this.getCredentials(),
|
||||
headers: new Headers({
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json; charset=utf-8',
|
||||
'Authorization': authHeader,
|
||||
'Device-Type': this.deviceType,
|
||||
}),
|
||||
method: 'PUT',
|
||||
}));
|
||||
|
||||
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> {
|
||||
const authHeader = await this.handleTokenState();
|
||||
const response = await fetch(new Request(this.apiBaseUrl + '/accounts/revision-date', {
|
||||
|
|
Loading…
Reference in New Issue