chore: prettier

This commit is contained in:
Derrick Hammer 2024-03-13 10:22:23 -04:00
parent 4797ea7be2
commit 3250edf166
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
3 changed files with 341 additions and 311 deletions

View File

@ -1,13 +1,15 @@
import { import {
LoginRequest, LoginResponse, LoginRequest,
LoginResponse,
OTPDisableRequest, OTPDisableRequest,
OTPGenerateResponse, OTPGenerateResponse,
OTPValidateRequest, OTPValidateRequest,
OTPVerifyRequest, OTPVerifyRequest,
PasswordResetVerifyRequest, postApiAuthPasswordResetRequest, PasswordResetVerifyRequest,
postApiAuthPasswordResetRequest,
RegisterRequest, RegisterRequest,
VerifyEmailRequest, VerifyEmailRequest,
} from './account/generated/index.js'; } from "./account/generated/index.js";
import { import {
postApiAuthLogin, postApiAuthLogin,
postApiAuthRegister, postApiAuthRegister,
@ -18,8 +20,8 @@ import {
postApiAuthOtpDisable, postApiAuthOtpDisable,
PasswordResetRequest, PasswordResetRequest,
postApiAuthPasswordResetConfirm, postApiAuthPasswordResetConfirm,
} from './account/generated/index.js'; } from "./account/generated/index.js";
import { AxiosResponse } from 'axios'; import { AxiosResponse } from "axios";
export default class AccountApi { export default class AccountApi {
private apiUrl: string; private apiUrl: string;
@ -34,7 +36,9 @@ export default class AccountApi {
} }
public async login(loginRequest: LoginRequest): Promise<boolean> { 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) { if (ret) {
this.jwtToken = (ret as LoginResponse).token; this.jwtToken = (ret as LoginResponse).token;
} }
@ -43,41 +47,67 @@ export default class AccountApi {
} }
public async register(registerRequest: RegisterRequest): Promise<boolean> { 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> { public async verifyEmail(
return this.checkSuccessBool(await postApiAuthVerifyEmail(verifyEmailRequest, this.buildOptions())); verifyEmailRequest: VerifyEmailRequest,
): Promise<boolean> {
return this.checkSuccessBool(
await postApiAuthVerifyEmail(verifyEmailRequest, this.buildOptions()),
);
} }
public async generateOtp(): Promise<boolean | OTPGenerateResponse> { 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> { 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> { public async validateOtp(
return this.checkSuccessBool(await postApiAuthOtpValidate(otpValidateRequest, this.buildOptions())); otpValidateRequest: OTPValidateRequest,
): Promise<boolean> {
return this.checkSuccessBool(
await postApiAuthOtpValidate(otpValidateRequest, this.buildOptions()),
);
} }
public async disableOtp(
public async disableOtp(otpDisableRequest: OTPDisableRequest): Promise<boolean> { otpDisableRequest: OTPDisableRequest,
return this.checkSuccessBool(await postApiAuthOtpDisable(otpDisableRequest, this.buildOptions())); ): Promise<boolean> {
return this.checkSuccessBool(
await postApiAuthOtpDisable(otpDisableRequest, this.buildOptions()),
);
} }
public async requestPasswordReset( public async requestPasswordReset(
passwordResetRequest: PasswordResetRequest, passwordResetRequest: PasswordResetRequest,
): Promise<boolean> { ): Promise<boolean> {
return this.checkSuccessBool(await postApiAuthPasswordResetRequest(passwordResetRequest, this.buildOptions())); return this.checkSuccessBool(
await postApiAuthPasswordResetRequest(
passwordResetRequest,
this.buildOptions(),
),
);
} }
public async confirmPasswordReset( public async confirmPasswordReset(
passwordResetVerifyRequest: PasswordResetVerifyRequest, passwordResetVerifyRequest: PasswordResetVerifyRequest,
): Promise<boolean> { ): Promise<boolean> {
return this.checkSuccessBool(await postApiAuthPasswordResetConfirm(passwordResetVerifyRequest, this.buildOptions())); return this.checkSuccessBool(
await postApiAuthPasswordResetConfirm(
passwordResetVerifyRequest,
this.buildOptions(),
),
);
} }
private checkSuccessBool(ret: AxiosResponse<void>): boolean { private checkSuccessBool(ret: AxiosResponse<void>): boolean {

View File

@ -12,15 +12,15 @@ paths:
content: content:
application/json: application/json:
schema: schema:
$ref: '#/components/schemas/LoginRequest' $ref: "#/components/schemas/LoginRequest"
responses: responses:
'200': "200":
description: Successfully logged in description: Successfully logged in
content: content:
application/json: application/json:
schema: schema:
$ref: '#/components/schemas/LoginResponse' $ref: "#/components/schemas/LoginResponse"
'401': "401":
description: Unauthorized description: Unauthorized
/api/auth/register: /api/auth/register:
post: post:
@ -30,11 +30,11 @@ paths:
content: content:
application/json: application/json:
schema: schema:
$ref: '#/components/schemas/RegisterRequest' $ref: "#/components/schemas/RegisterRequest"
responses: responses:
'200': "200":
description: Successfully registered description: Successfully registered
'400': "400":
description: Bad Request description: Bad Request
/api/auth/verify-email: /api/auth/verify-email:
post: post:
@ -44,20 +44,20 @@ paths:
content: content:
application/json: application/json:
schema: schema:
$ref: '#/components/schemas/VerifyEmailRequest' $ref: "#/components/schemas/VerifyEmailRequest"
responses: responses:
'200': "200":
description: Email verified successfully description: Email verified successfully
/api/auth/otp/generate: /api/auth/otp/generate:
get: get:
summary: Generate OTP for two-factor authentication summary: Generate OTP for two-factor authentication
responses: responses:
'200': "200":
description: OTP generated successfully description: OTP generated successfully
content: content:
application/json: application/json:
schema: schema:
$ref: '#/components/schemas/OTPGenerateResponse' $ref: "#/components/schemas/OTPGenerateResponse"
/api/auth/otp/verify: /api/auth/otp/verify:
post: post:
summary: Verify OTP for enabling two-factor authentication summary: Verify OTP for enabling two-factor authentication
@ -66,9 +66,9 @@ paths:
content: content:
application/json: application/json:
schema: schema:
$ref: '#/components/schemas/OTPVerifyRequest' $ref: "#/components/schemas/OTPVerifyRequest"
responses: responses:
'200': "200":
description: OTP verified successfully description: OTP verified successfully
/api/auth/otp/validate: /api/auth/otp/validate:
post: post:
@ -78,9 +78,9 @@ paths:
content: content:
application/json: application/json:
schema: schema:
$ref: '#/components/schemas/OTPValidateRequest' $ref: "#/components/schemas/OTPValidateRequest"
responses: responses:
'200': "200":
description: OTP validated successfully description: OTP validated successfully
/api/auth/otp/disable: /api/auth/otp/disable:
post: post:
@ -90,9 +90,9 @@ paths:
content: content:
application/json: application/json:
schema: schema:
$ref: '#/components/schemas/OTPDisableRequest' $ref: "#/components/schemas/OTPDisableRequest"
responses: responses:
'200': "200":
description: OTP disabled successfully description: OTP disabled successfully
/api/auth/password-reset/request: /api/auth/password-reset/request:
post: post:
@ -102,9 +102,9 @@ paths:
content: content:
application/json: application/json:
schema: schema:
$ref: '#/components/schemas/PasswordResetRequest' $ref: "#/components/schemas/PasswordResetRequest"
responses: responses:
'200': "200":
description: Password reset requested successfully description: Password reset requested successfully
/api/auth/password-reset/confirm: /api/auth/password-reset/confirm:
post: post:
@ -114,9 +114,9 @@ paths:
content: content:
application/json: application/json:
schema: schema:
$ref: '#/components/schemas/PasswordResetVerifyRequest' $ref: "#/components/schemas/PasswordResetVerifyRequest"
responses: responses:
'200': "200":
description: Password reset successfully description: Password reset successfully
components: components:

View File

@ -1,4 +1,4 @@
import AccountApi from './account.js'; import AccountApi from "./account.js";
export class Sdk { export class Sdk {
private apiUrl: string; private apiUrl: string;