-
Notifications
You must be signed in to change notification settings - Fork 210
Expand file tree
/
Copy pathrest-api.ts
More file actions
188 lines (176 loc) · 7.73 KB
/
rest-api.ts
File metadata and controls
188 lines (176 loc) · 7.73 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
/**
* Binance Dual Investment REST API
*
* OpenAPI Specification for the Binance Dual Investment REST API
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import { ConfigurationRestAPI, RestApiResponse, sendRequest } from '@binance/common';
import { MarketDataApi } from './modules/market-data-api';
import { TradeApi } from './modules/trade-api';
import type { GetDualInvestmentProductListRequest } from './modules/market-data-api';
import type {
ChangeAutoCompoundStatusRequest,
CheckDualInvestmentAccountsRequest,
GetDualInvestmentPositionsRequest,
SubscribeDualInvestmentProductsRequest,
} from './modules/trade-api';
import type { GetDualInvestmentProductListResponse } from './types';
import type {
ChangeAutoCompoundStatusResponse,
CheckDualInvestmentAccountsResponse,
GetDualInvestmentPositionsResponse,
SubscribeDualInvestmentProductsResponse,
} from './types';
export class RestAPI {
private configuration: ConfigurationRestAPI;
private marketDataApi: MarketDataApi;
private tradeApi: TradeApi;
constructor(configuration: ConfigurationRestAPI) {
this.configuration = configuration;
this.marketDataApi = new MarketDataApi(configuration);
this.tradeApi = new TradeApi(configuration);
}
/**
* Generic function to send a request.
* @param endpoint - The API endpoint to call.
* @param method - HTTP method to use (GET, POST, DELETE, etc.).
* @param queryParams - Query parameters for the request.
* @param bodyParams - Body parameters for the request.
*
* @returns A promise resolving to the response data object.
*/
sendRequest<T>(
endpoint: string,
method: 'GET' | 'POST' | 'DELETE' | 'PUT' | 'PATCH',
queryParams: Record<string, unknown> = {},
bodyParams: Record<string, unknown> = {}
): Promise<RestApiResponse<T>> {
return sendRequest<T>(
this.configuration,
endpoint,
method,
queryParams,
bodyParams,
undefined
);
}
/**
* Generic function to send a signed request.
* @param endpoint - The API endpoint to call.
* @param method - HTTP method to use (GET, POST, DELETE, etc.).
* @param queryParams - Query parameters for the request.
* @param bodyParams - Body parameters for the request.
*
* @returns A promise resolving to the response data object.
*/
sendSignedRequest<T>(
endpoint: string,
method: 'GET' | 'POST' | 'DELETE' | 'PUT' | 'PATCH',
queryParams: Record<string, unknown> = {},
bodyParams: Record<string, unknown> = {}
): Promise<RestApiResponse<T>> {
return sendRequest<T>(
this.configuration,
endpoint,
method,
queryParams,
bodyParams,
undefined,
{ isSigned: true }
);
}
/**
* Get Dual Investment product list
*
* Weight: 1(IP)
*
* @summary Get Dual Investment product list
* @param {GetDualInvestmentProductListRequest} requestParameters Request parameters.
*
* @returns {Promise<RestApiResponse<GetDualInvestmentProductListResponse>>}
* @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
* @see {@link https://developers.binance.com/docs/advanced_earn/dual-investment/market-data/Get-Dual-Investment-product-list Binance API Documentation}
*/
getDualInvestmentProductList(
requestParameters: GetDualInvestmentProductListRequest
): Promise<RestApiResponse<GetDualInvestmentProductListResponse>> {
return this.marketDataApi.getDualInvestmentProductList(requestParameters);
}
/**
* Change Auto-Compound status
*
* Weight: 1(IP)
*
* @summary Change Auto-Compound status(USER_DATA)
* @param {ChangeAutoCompoundStatusRequest} requestParameters Request parameters.
*
* @returns {Promise<RestApiResponse<ChangeAutoCompoundStatusResponse>>}
* @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
* @see {@link https://developers.binance.com/docs/advanced_earn/dual-investment/trade/Change-Auto-Compound-status Binance API Documentation}
*/
changeAutoCompoundStatus(
requestParameters: ChangeAutoCompoundStatusRequest
): Promise<RestApiResponse<ChangeAutoCompoundStatusResponse>> {
return this.tradeApi.changeAutoCompoundStatus(requestParameters);
}
/**
* Check Dual Investment accounts
*
* Weight: 1(IP)
*
* @summary Check Dual Investment accounts(USER_DATA)
* @param {CheckDualInvestmentAccountsRequest} requestParameters Request parameters.
*
* @returns {Promise<RestApiResponse<CheckDualInvestmentAccountsResponse>>}
* @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
* @see {@link https://developers.binance.com/docs/advanced_earn/dual-investment/trade/Check-Dual-Investment-accounts Binance API Documentation}
*/
checkDualInvestmentAccounts(
requestParameters: CheckDualInvestmentAccountsRequest = {}
): Promise<RestApiResponse<CheckDualInvestmentAccountsResponse>> {
return this.tradeApi.checkDualInvestmentAccounts(requestParameters);
}
/**
* Get Dual Investment positions (batch)
*
* Weight: 1(IP)
*
* @summary Get Dual Investment positions(USER_DATA)
* @param {GetDualInvestmentPositionsRequest} requestParameters Request parameters.
*
* @returns {Promise<RestApiResponse<GetDualInvestmentPositionsResponse>>}
* @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
* @see {@link https://developers.binance.com/docs/advanced_earn/dual-investment/trade/Get-Dual-Investment-positions Binance API Documentation}
*/
getDualInvestmentPositions(
requestParameters: GetDualInvestmentPositionsRequest = {}
): Promise<RestApiResponse<GetDualInvestmentPositionsResponse>> {
return this.tradeApi.getDualInvestmentPositions(requestParameters);
}
/**
* Subscribe Dual Investment products
*
* Products are not available. // this means APR changes to lower value, or orders are not unavailable.
* Failed. This means System or network errors.
*
* Weight: 1(IP)
*
* @summary Subscribe Dual Investment products(USER_DATA)
* @param {SubscribeDualInvestmentProductsRequest} requestParameters Request parameters.
*
* @returns {Promise<RestApiResponse<SubscribeDualInvestmentProductsResponse>>}
* @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError}
* @see {@link https://developers.binance.com/docs/advanced_earn/dual-investment/trade/Subscribe-Dual-Investment-products Binance API Documentation}
*/
subscribeDualInvestmentProducts(
requestParameters: SubscribeDualInvestmentProductsRequest
): Promise<RestApiResponse<SubscribeDualInvestmentProductsResponse>> {
return this.tradeApi.subscribeDualInvestmentProducts(requestParameters);
}
}