chore: prettier
This commit is contained in:
parent
4797ea7be2
commit
3250edf166
|
@ -1,13 +1,15 @@
|
|||
import {
|
||||
LoginRequest, LoginResponse,
|
||||
LoginRequest,
|
||||
LoginResponse,
|
||||
OTPDisableRequest,
|
||||
OTPGenerateResponse,
|
||||
OTPValidateRequest,
|
||||
OTPVerifyRequest,
|
||||
PasswordResetVerifyRequest, postApiAuthPasswordResetRequest,
|
||||
PasswordResetVerifyRequest,
|
||||
postApiAuthPasswordResetRequest,
|
||||
RegisterRequest,
|
||||
VerifyEmailRequest,
|
||||
} from './account/generated/index.js';
|
||||
} from "./account/generated/index.js";
|
||||
import {
|
||||
postApiAuthLogin,
|
||||
postApiAuthRegister,
|
||||
|
@ -18,8 +20,8 @@ import {
|
|||
postApiAuthOtpDisable,
|
||||
PasswordResetRequest,
|
||||
postApiAuthPasswordResetConfirm,
|
||||
} from './account/generated/index.js';
|
||||
import { AxiosResponse } from 'axios';
|
||||
} from "./account/generated/index.js";
|
||||
import { AxiosResponse } from "axios";
|
||||
|
||||
export default class AccountApi {
|
||||
private apiUrl: string;
|
||||
|
@ -34,7 +36,9 @@ export default class AccountApi {
|
|||
}
|
||||
|
||||
public async login(loginRequest: LoginRequest): Promise<boolean> {
|
||||
let ret = this.checkSuccessVal<LoginResponse>(await postApiAuthLogin(loginRequest, { baseURL: this.apiUrl }))
|
||||
let ret = this.checkSuccessVal<LoginResponse>(
|
||||
await postApiAuthLogin(loginRequest, { baseURL: this.apiUrl }),
|
||||
);
|
||||
if (ret) {
|
||||
this.jwtToken = (ret as LoginResponse).token;
|
||||
}
|
||||
|
@ -43,41 +47,67 @@ export default class AccountApi {
|
|||
}
|
||||
|
||||
public async register(registerRequest: RegisterRequest): Promise<boolean> {
|
||||
return this.checkSuccessBool(await postApiAuthRegister(registerRequest, this.buildOptions()));
|
||||
return this.checkSuccessBool(
|
||||
await postApiAuthRegister(registerRequest, this.buildOptions()),
|
||||
);
|
||||
}
|
||||
|
||||
public async verifyEmail(verifyEmailRequest: VerifyEmailRequest): Promise<boolean> {
|
||||
return this.checkSuccessBool(await postApiAuthVerifyEmail(verifyEmailRequest, this.buildOptions()));
|
||||
public async verifyEmail(
|
||||
verifyEmailRequest: VerifyEmailRequest,
|
||||
): Promise<boolean> {
|
||||
return this.checkSuccessBool(
|
||||
await postApiAuthVerifyEmail(verifyEmailRequest, this.buildOptions()),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public async generateOtp(): Promise<boolean | OTPGenerateResponse> {
|
||||
return this.checkSuccessVal<OTPGenerateResponse>(await getApiAuthOtpGenerate( this.buildOptions()));
|
||||
return this.checkSuccessVal<OTPGenerateResponse>(
|
||||
await getApiAuthOtpGenerate(this.buildOptions()),
|
||||
);
|
||||
}
|
||||
|
||||
public async verifyOtp(otpVerifyRequest: OTPVerifyRequest): Promise<boolean> {
|
||||
return this.checkSuccessBool(await postApiAuthOtpVerify(otpVerifyRequest, this.buildOptions()));
|
||||
return this.checkSuccessBool(
|
||||
await postApiAuthOtpVerify(otpVerifyRequest, this.buildOptions()),
|
||||
);
|
||||
}
|
||||
|
||||
public async validateOtp(otpValidateRequest: OTPValidateRequest): Promise<boolean> {
|
||||
return this.checkSuccessBool(await postApiAuthOtpValidate(otpValidateRequest, this.buildOptions()));
|
||||
public async validateOtp(
|
||||
otpValidateRequest: OTPValidateRequest,
|
||||
): Promise<boolean> {
|
||||
return this.checkSuccessBool(
|
||||
await postApiAuthOtpValidate(otpValidateRequest, this.buildOptions()),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public async disableOtp(otpDisableRequest: OTPDisableRequest): Promise<boolean> {
|
||||
return this.checkSuccessBool(await postApiAuthOtpDisable(otpDisableRequest, this.buildOptions()));
|
||||
public async disableOtp(
|
||||
otpDisableRequest: OTPDisableRequest,
|
||||
): Promise<boolean> {
|
||||
return this.checkSuccessBool(
|
||||
await postApiAuthOtpDisable(otpDisableRequest, this.buildOptions()),
|
||||
);
|
||||
}
|
||||
|
||||
public async requestPasswordReset(
|
||||
passwordResetRequest: PasswordResetRequest,
|
||||
): Promise<boolean> {
|
||||
return this.checkSuccessBool(await postApiAuthPasswordResetRequest(passwordResetRequest, this.buildOptions()));
|
||||
return this.checkSuccessBool(
|
||||
await postApiAuthPasswordResetRequest(
|
||||
passwordResetRequest,
|
||||
this.buildOptions(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public async confirmPasswordReset(
|
||||
passwordResetVerifyRequest: PasswordResetVerifyRequest,
|
||||
): Promise<boolean> {
|
||||
return this.checkSuccessBool(await postApiAuthPasswordResetConfirm(passwordResetVerifyRequest, this.buildOptions()));
|
||||
return this.checkSuccessBool(
|
||||
await postApiAuthPasswordResetConfirm(
|
||||
passwordResetVerifyRequest,
|
||||
this.buildOptions(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
private checkSuccessBool(ret: AxiosResponse<void>): boolean {
|
||||
|
|
|
@ -12,15 +12,15 @@ paths:
|
|||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/LoginRequest'
|
||||
$ref: "#/components/schemas/LoginRequest"
|
||||
responses:
|
||||
'200':
|
||||
"200":
|
||||
description: Successfully logged in
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/LoginResponse'
|
||||
'401':
|
||||
$ref: "#/components/schemas/LoginResponse"
|
||||
"401":
|
||||
description: Unauthorized
|
||||
/api/auth/register:
|
||||
post:
|
||||
|
@ -30,11 +30,11 @@ paths:
|
|||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/RegisterRequest'
|
||||
$ref: "#/components/schemas/RegisterRequest"
|
||||
responses:
|
||||
'200':
|
||||
"200":
|
||||
description: Successfully registered
|
||||
'400':
|
||||
"400":
|
||||
description: Bad Request
|
||||
/api/auth/verify-email:
|
||||
post:
|
||||
|
@ -44,20 +44,20 @@ paths:
|
|||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/VerifyEmailRequest'
|
||||
$ref: "#/components/schemas/VerifyEmailRequest"
|
||||
responses:
|
||||
'200':
|
||||
"200":
|
||||
description: Email verified successfully
|
||||
/api/auth/otp/generate:
|
||||
get:
|
||||
summary: Generate OTP for two-factor authentication
|
||||
responses:
|
||||
'200':
|
||||
"200":
|
||||
description: OTP generated successfully
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/OTPGenerateResponse'
|
||||
$ref: "#/components/schemas/OTPGenerateResponse"
|
||||
/api/auth/otp/verify:
|
||||
post:
|
||||
summary: Verify OTP for enabling two-factor authentication
|
||||
|
@ -66,9 +66,9 @@ paths:
|
|||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/OTPVerifyRequest'
|
||||
$ref: "#/components/schemas/OTPVerifyRequest"
|
||||
responses:
|
||||
'200':
|
||||
"200":
|
||||
description: OTP verified successfully
|
||||
/api/auth/otp/validate:
|
||||
post:
|
||||
|
@ -78,9 +78,9 @@ paths:
|
|||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/OTPValidateRequest'
|
||||
$ref: "#/components/schemas/OTPValidateRequest"
|
||||
responses:
|
||||
'200':
|
||||
"200":
|
||||
description: OTP validated successfully
|
||||
/api/auth/otp/disable:
|
||||
post:
|
||||
|
@ -90,9 +90,9 @@ paths:
|
|||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/OTPDisableRequest'
|
||||
$ref: "#/components/schemas/OTPDisableRequest"
|
||||
responses:
|
||||
'200':
|
||||
"200":
|
||||
description: OTP disabled successfully
|
||||
/api/auth/password-reset/request:
|
||||
post:
|
||||
|
@ -102,9 +102,9 @@ paths:
|
|||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/PasswordResetRequest'
|
||||
$ref: "#/components/schemas/PasswordResetRequest"
|
||||
responses:
|
||||
'200':
|
||||
"200":
|
||||
description: Password reset requested successfully
|
||||
/api/auth/password-reset/confirm:
|
||||
post:
|
||||
|
@ -114,9 +114,9 @@ paths:
|
|||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/PasswordResetVerifyRequest'
|
||||
$ref: "#/components/schemas/PasswordResetVerifyRequest"
|
||||
responses:
|
||||
'200':
|
||||
"200":
|
||||
description: Password reset successfully
|
||||
|
||||
components:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import AccountApi from './account.js';
|
||||
import AccountApi from "./account.js";
|
||||
|
||||
export class Sdk {
|
||||
private apiUrl: string;
|
||||
|
|
Loading…
Reference in New Issue