feat: add account info endpoint

This commit is contained in:
Derrick Hammer 2024-03-14 06:57:49 -04:00
parent 5e68896eea
commit 31505980c9
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
2 changed files with 36 additions and 0 deletions

View File

@ -1,4 +1,6 @@
import { import {
AccountInfoResponse,
getApiAccount,
LoginRequest, LoginRequest,
LoginResponse, LoginResponse,
OTPDisableRequest, OTPDisableRequest,
@ -185,6 +187,17 @@ export class AccountApi {
return this.checkSuccessVal(ret) && ret.data.ping == "pong"; return this.checkSuccessVal(ret) && ret.data.ping == "pong";
} }
public async info(): Promise<boolean | AccountInfoResponse> {
let ret: AxiosResponse<AccountInfoResponse>;
try {
ret = await getApiAccount(this.buildOptions());
} catch (e) {
return false;
}
return this.checkSuccessVal(ret);
}
private checkSuccessBool(ret: AxiosResponse<void>): boolean { private checkSuccessBool(ret: AxiosResponse<void>): boolean {
return ret.status === 200; return ret.status === 200;
} }

View File

@ -130,6 +130,18 @@ paths:
$ref: "#/components/schemas/PingResponse" $ref: "#/components/schemas/PingResponse"
"401": "401":
description: Unauthorized description: Unauthorized
/api/account:
get:
summary: Get account information
responses:
"200":
description: Account information retrieved successfully
content:
application/json:
schema:
$ref: "#/components/schemas/AccountInfoResponse"
"401":
description: Unauthorized
components: components:
schemas: schemas:
@ -225,3 +237,14 @@ components:
properties: properties:
ping: ping:
type: string type: string
AccountInfoResponse:
type: object
properties:
id:
type: number
first_name:
type: string
last_name:
type: string
email:
type: string