forked from singlesly/bingx-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
61 lines (50 loc) · 1.57 KB
/
Copy pathindex.ts
File metadata and controls
61 lines (50 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import { ApiAccount } from '@app/bingx/account/api-account';
import { BingxRequestInterface } from '@app/bingx/endpoints/bingx-request.interface';
import { BingxResponseInterface } from '@app/bingx/endpoints/bingx-response.interface';
import { EndpointInterface } from '@app/bingx/endpoints/endpoint.interface';
import { BingxRequest } from '@app/bingx/endpoints/bingx-request';
import { BingxGenerateListenKeyEndpoint } from '@app/bingx/endpoints/bingx-generate-listen-key-endpoint';
async function examples() {
/** Basic usage **/
const account = new ApiAccount('aaaa', 'ddd');
const listenKeyResponseBingxResponse = await new BingxRequest(
new BingxGenerateListenKeyEndpoint(account),
).getResponse();
console.log(listenKeyResponseBingxResponse);
/**
* {
* code: 0,
* msg: "success",
* data: {
* listenKey: 'dawddawdda'
* }
* }
*/
/** Override Request Class **/
class RmqCustomRequest<T> implements BingxRequestInterface<T> {
constructor(private readonly endpoint: EndpointInterface<T>) {}
async getEndpoint(): Promise<Readonly<EndpointInterface<T>>> {
return this.endpoint;
}
getResponse(): Promise<Readonly<BingxResponseInterface<T>>> {
/**
* Logic to send request via rmq
*/
return {} as never;
}
}
const response = await new RmqCustomRequest(
new BingxGenerateListenKeyEndpoint(account),
).getResponse();
console.log(response);
/**
* {
* code: 0,
* msg: "success",
* data: {
* listenKey: 'dawddawdda'
* }
* }
*/
}
examples().then();