feat: add account info endpoint
This commit is contained in:
parent
5e68896eea
commit
31505980c9
|
@ -1,4 +1,6 @@
|
|||
import {
|
||||
AccountInfoResponse,
|
||||
getApiAccount,
|
||||
LoginRequest,
|
||||
LoginResponse,
|
||||
OTPDisableRequest,
|
||||
|
@ -185,6 +187,17 @@ export class AccountApi {
|
|||
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 {
|
||||
return ret.status === 200;
|
||||
}
|
||||
|
|
|
@ -130,6 +130,18 @@ paths:
|
|||
$ref: "#/components/schemas/PingResponse"
|
||||
"401":
|
||||
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:
|
||||
schemas:
|
||||
|
@ -225,3 +237,14 @@ components:
|
|||
properties:
|
||||
ping:
|
||||
type: string
|
||||
AccountInfoResponse:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: number
|
||||
first_name:
|
||||
type: string
|
||||
last_name:
|
||||
type: string
|
||||
email:
|
||||
type: string
|
||||
|
|
Loading…
Reference in New Issue