Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/bingx-client/services/listen-key.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { AccountInterface } from 'bingx-api/bingx/account/account.interface';
import { BingxGenerateListenKeyEndpoint } from 'bingx-api/bingx/endpoints/bingx-generate-listen-key-endpoint';
import { BingxGenerateListenKeyResponse } from 'bingx-api/bingx/endpoints/bingx-generate-listen-key-response';
import { BingxExtendListenKeyEndpoint } from 'bingx-api/bingx/endpoints/bingx-extend-listen-key-endpoint';
import { BingxCloseListenKeyEndpoint } from 'bingx-api/bingx/endpoints/bingx-close-listen-key-endpoint';
import { RequestExecutorInterface } from 'bingx-api/bingx/request-executor/request-executor.interface';

export class ListenKeyService {
Expand All @@ -13,4 +15,22 @@ export class ListenKeyService {
new BingxGenerateListenKeyEndpoint(account),
);
}

async extendListenKey(
listenKey: string,
account: AccountInterface,
): Promise<void> {
return this.requestExecutor.execute(
new BingxExtendListenKeyEndpoint(listenKey, account),
);
}

async closeListenKey(
listenKey: string,
account: AccountInterface,
): Promise<void> {
return this.requestExecutor.execute(
new BingxCloseListenKeyEndpoint(listenKey, account),
);
}
}
35 changes: 35 additions & 0 deletions src/bingx/endpoints/bingx-close-listen-key-endpoint.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import {
AccountInterface,
DefaultSignatureParameters,
Endpoint,
EndpointInterface,
SignatureParametersInterface,
} from 'bingx-api/bingx';

export class BingxCloseListenKeyEndpoint<R = void>
extends Endpoint
implements EndpointInterface<R>
{
constructor(
private readonly listenKey: string,
account: AccountInterface,
) {
super(account);
}

method(): 'get' | 'post' | 'put' | 'patch' | 'delete' {
return 'delete';
}

parameters(): SignatureParametersInterface {
return new DefaultSignatureParameters({
listenKey: this.listenKey,
});
}

path(): string {
return '/openApi/user/auth/userDataStream';
}

readonly t!: R;
}
1 change: 1 addition & 0 deletions src/bingx/endpoints/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ export * from './endpoint';
export * from './bingx-user-history-orders-endpoint';
export * from './bingx-user-history-orders-response';
export * from './bingx-cancel-order-endpoint';
export * from './bingx-close-listen-key-endpoint';