Introduce getSubAccountAllApiKeys, update deleteSubApiKey

This commit is contained in:
Karim Sakhibgareev
2024-06-03 15:29:49 +01:00
parent 991e76207e
commit 152a1d6427
6 changed files with 60 additions and 8 deletions

View File

@@ -142,6 +142,8 @@ import {
WalletBalanceV5,
WithdrawParamsV5,
WithdrawalRecordV5,
SubAccountAllApiKeysResultV5,
GetSubAccountAllApiKeysParamsV5,
} from './types';
import { REST_CLIENT_TYPE_ENUM } from './util';
@@ -1295,6 +1297,17 @@ export class RestClientV5 extends BaseRestClient {
return this.getPrivate('/v5/user/query-sub-members');
}
/**
* Query all api keys information of a sub UID.
*/
getSubAccountAllApiKeys(
params: GetSubAccountAllApiKeysParamsV5,
): Promise<
APIResponseV3WithTime<SubAccountAllApiKeysResultV5>
> {
return this.getPrivate('/v5/user/sub-apikeys', params);
}
/**
* Froze sub uid. Use master user's api key only.
*
@@ -1361,12 +1374,16 @@ export class RestClientV5 extends BaseRestClient {
*
* TIP:
* The API key must have one of the permissions to be allowed to call the following API endpoint.
* - sub API key: "Account Transfer"
* - sub API key: "Account Transfer", "Sub Member Transfer"
* - master API Key: "Account Transfer", "Sub Member Transfer", "Withdrawal"
*
* DANGER: BE CAREFUL! The API key used to call this interface will be invalid immediately.
* DANGER: BE CAREFUL! The sub API key used to call this interface will be invalid immediately.
*/
deleteSubApiKey(): Promise<APIResponseV3WithTime<{}>> {
return this.postPrivate('/v5/user/delete-sub-api');
deleteSubApiKey(apikey?: string): Promise<APIResponseV3WithTime<{}>> {
return this.postPrivate(
'/v5/user/delete-sub-api',
apikey ? { apikey } : undefined,
);
}
/**

View File

@@ -39,3 +39,9 @@ export interface UpdateSubApiKeyUpdateParamsV5 {
export interface DeleteSubMemberParamsV5 {
subMemberId: string;
}
export interface GetSubAccountAllApiKeysParamsV5 {
subMemberId: string;
limit?: number;
cursor?: string;
}

View File

@@ -34,7 +34,7 @@ export interface ApiKeyInfoV5 {
secret: string;
permissions: PermissionsV5;
ips?: string[];
type: 1 | 2;
type: ApiKeyType;
deadlineDay?: number;
expiredAt?: string;
createdAt: string;
@@ -57,3 +57,22 @@ export interface UpdateApiKeyResultV5 {
permissions: PermissionsV5;
ips: string[];
}
export interface SubAccountAllApiKeysResultV5 {
result: {
id: string;
ips?: string[];
apiKey: string;
note: string;
status: number;
expiredAt?: string;
createdAt: string;
type: ApiKeyType;
permissions: PermissionsV5;
secret: string;
readOnly: 0 | 1;
deadlineDay?: number;
flag: string;
}[],
nextPageCursor: string;
}