@@ -75,3 +75,275 @@ type ConvertTradeHistoryItem struct {
75
75
InverseRatio string `json:"inverseRatio"`
76
76
CreateTime int64 `json:"createTime"`
77
77
}
78
+
79
+ // ConvertExchangeInfoService create a new convert exchange info service
80
+ type ConvertExchangeInfoService struct {
81
+ c * Client
82
+ fromAsset * string
83
+ toAsset * string
84
+ }
85
+
86
+ // FromAsset set fromAsset
87
+ func (s * ConvertExchangeInfoService ) FromAsset (fromAsset string ) * ConvertExchangeInfoService {
88
+ s .fromAsset = & fromAsset
89
+ return s
90
+ }
91
+
92
+ // ToAsset set toAsset
93
+ func (s * ConvertExchangeInfoService ) ToAsset (toAsset string ) * ConvertExchangeInfoService {
94
+ s .toAsset = & toAsset
95
+ return s
96
+ }
97
+
98
+ // Do send request
99
+ func (s * ConvertExchangeInfoService ) Do (ctx context.Context , opts ... RequestOption ) ([]* ConvertExchangeInfo , error ) {
100
+ r := & request {
101
+ method : http .MethodGet ,
102
+ endpoint : "/sapi/v1/convert/exchangeInfo" ,
103
+ secType : secTypeSigned ,
104
+ }
105
+ if s .fromAsset != nil {
106
+ r .setParam ("fromAsset" , * s .fromAsset )
107
+ }
108
+ if s .toAsset != nil {
109
+ r .setParam ("toAsset" , * s .toAsset )
110
+ }
111
+
112
+ data , err := s .c .callAPI (ctx , r , opts ... )
113
+ if err != nil {
114
+ return nil , err
115
+ }
116
+ var res []* ConvertExchangeInfo
117
+ if err = json .Unmarshal (data , & res ); err != nil {
118
+ return nil , err
119
+ }
120
+ return res , nil
121
+ }
122
+
123
+ // ConvertExchangeInfo define the convert exchange info
124
+ type ConvertExchangeInfo struct {
125
+ FromAsset string `json:"fromAsset"`
126
+ ToAsset string `json:"toAsset"`
127
+ FromAssetMinAmount string `json:"fromAssetMinAmount"`
128
+ FromAssetMaxAmount string `json:"fromAssetMaxAmount"`
129
+ ToAssetMinAmount string `json:"toAssetMinAmount"`
130
+ ToAssetMaxAmount string `json:"toAssetMaxAmount"`
131
+ }
132
+
133
+ // ConvertGetQuoteService create a new convert quote service
134
+ type ConvertGetQuoteService struct {
135
+ c * Client
136
+ fromAsset string
137
+ toAsset string
138
+ fromAmount * string
139
+ toAmount * string
140
+ walletType * string // SPOT, FUNDING
141
+ validTime * string // 10s, 30s, 1m, 2m, default 10s
142
+ }
143
+
144
+ // ConvertAssetInfoService create a new convert asset info service
145
+ type ConvertAssetInfoService struct {
146
+ c * Client
147
+ }
148
+
149
+ // Do send request
150
+ func (s * ConvertAssetInfoService ) Do (ctx context.Context , opts ... RequestOption ) ([]* ConvertAssetInfo , error ) {
151
+ r := & request {
152
+ method : http .MethodGet ,
153
+ endpoint : "/sapi/v1/convert/assetInfo" ,
154
+ secType : secTypeSigned ,
155
+ }
156
+
157
+ data , err := s .c .callAPI (ctx , r , opts ... )
158
+ if err != nil {
159
+ return nil , err
160
+ }
161
+ var res []* ConvertAssetInfo
162
+ if err = json .Unmarshal (data , & res ); err != nil {
163
+ return nil , err
164
+ }
165
+ return res , nil
166
+ }
167
+
168
+ // ConvertAssetInfo define the convert asset info
169
+ type ConvertAssetInfo struct {
170
+ Asset string `json:"asset"`
171
+ Fraction int `json:"fraction"`
172
+ }
173
+
174
+ // FromAsset set fromAsset
175
+ func (s * ConvertGetQuoteService ) FromAsset (fromAsset string ) * ConvertGetQuoteService {
176
+ s .fromAsset = fromAsset
177
+ return s
178
+ }
179
+
180
+ // ToAsset set fromAsset
181
+ func (s * ConvertGetQuoteService ) ToAsset (toAsset string ) * ConvertGetQuoteService {
182
+ s .toAsset = toAsset
183
+ return s
184
+ }
185
+
186
+ // FromAmount set fromAmount
187
+ func (s * ConvertGetQuoteService ) FromAmount (fromAmount string ) * ConvertGetQuoteService {
188
+ s .fromAmount = & fromAmount
189
+ return s
190
+ }
191
+
192
+ // ToAmount set toAmount
193
+ func (s * ConvertGetQuoteService ) ToAmount (toAmount string ) * ConvertGetQuoteService {
194
+ s .toAmount = & toAmount
195
+ return s
196
+ }
197
+
198
+ // WalletType set walletType
199
+ // SPOT or FUNDING. Default is SPOT
200
+ func (s * ConvertGetQuoteService ) WalletType (walletType string ) * ConvertGetQuoteService {
201
+ s .walletType = & walletType
202
+ return s
203
+ }
204
+
205
+ // ValidTime set validTime
206
+ // 10s, 30s, 1m, 2m, default 10s
207
+ func (s * ConvertGetQuoteService ) ValidTime (validTime string ) * ConvertGetQuoteService {
208
+ s .validTime = & validTime
209
+ return s
210
+ }
211
+
212
+ // Do send request
213
+ func (s * ConvertGetQuoteService ) Do (ctx context.Context , opts ... RequestOption ) (* ConvertQuote , error ) {
214
+ r := & request {
215
+ method : http .MethodPost ,
216
+ endpoint : "/sapi/v1/convert/getQuote" ,
217
+ secType : secTypeSigned ,
218
+ }
219
+
220
+ r .setParam ("fromAsset" , s .fromAsset )
221
+ r .setParam ("toAsset" , s .toAsset )
222
+
223
+ if s .fromAmount != nil {
224
+ r .setParam ("fromAmount" , * s .fromAmount )
225
+ }
226
+ if s .toAmount != nil {
227
+ r .setParam ("toAmount" , * s .toAmount )
228
+ }
229
+ if s .walletType != nil {
230
+ r .setParam ("walletType" , * s .walletType )
231
+ }
232
+ if s .validTime != nil {
233
+ r .setParam ("validTime" , * s .validTime )
234
+ }
235
+
236
+ data , err := s .c .callAPI (ctx , r , opts ... )
237
+ if err != nil {
238
+ return nil , err
239
+ }
240
+ var res ConvertQuote
241
+ if err = json .Unmarshal (data , & res ); err != nil {
242
+ return nil , err
243
+ }
244
+ return & res , nil
245
+ }
246
+
247
+ // ConvertQuote define the convert quote
248
+ type ConvertQuote struct {
249
+ QuoteId string `json:"quoteId"`
250
+ Ratio string `json:"ratio"`
251
+ InverseRatio string `json:"inverseRatio"`
252
+ ValidTime int64 `json:"validTime"`
253
+ ToAmount string `json:"toAmount"`
254
+ FromAmount string `json:"fromAmount"`
255
+ }
256
+
257
+ type ConvertAcceptQuoteService struct {
258
+ c * Client
259
+ quoteId string
260
+ }
261
+
262
+ // QuoteId set quoteId
263
+ func (s * ConvertAcceptQuoteService ) QuoteId (quoteId string ) * ConvertAcceptQuoteService {
264
+ s .quoteId = quoteId
265
+ return s
266
+ }
267
+
268
+ // Do send request
269
+ func (s * ConvertAcceptQuoteService ) Do (ctx context.Context , opts ... RequestOption ) (* ConvertAcceptQuote , error ) {
270
+ r := & request {
271
+ method : http .MethodPost ,
272
+ endpoint : "/sapi/v1/convert/acceptQuote" ,
273
+ secType : secTypeSigned ,
274
+ }
275
+ r .setParam ("quoteId" , s .quoteId )
276
+
277
+ data , err := s .c .callAPI (ctx , r , opts ... )
278
+ if err != nil {
279
+ return nil , err
280
+ }
281
+ var res ConvertAcceptQuote
282
+ if err = json .Unmarshal (data , & res ); err != nil {
283
+ return nil , err
284
+ }
285
+ return & res , nil
286
+ }
287
+
288
+ // ConvertAcceptQuote define the convert accept quote
289
+ type ConvertAcceptQuote struct {
290
+ OrderId string `json:"orderId"`
291
+ CreateTime int64 `json:"createTime"`
292
+ OrderStatus string `json:"orderStatus"`
293
+ }
294
+
295
+ // ConvertOrderStatusService check order status
296
+ type ConvertOrderStatusService struct {
297
+ c * Client
298
+ orderId * string
299
+ quoteId * string
300
+ }
301
+
302
+ // OrderId set orderId
303
+ func (s * ConvertOrderStatusService ) OrderId (orderId string ) * ConvertOrderStatusService {
304
+ s .orderId = & orderId
305
+ return s
306
+ }
307
+
308
+ // QuoteId set quoteId
309
+ func (s * ConvertOrderStatusService ) QuoteId (quoteId string ) * ConvertOrderStatusService {
310
+ s .quoteId = & quoteId
311
+ return s
312
+ }
313
+
314
+ // Do send request
315
+ func (s * ConvertOrderStatusService ) Do (ctx context.Context , opts ... RequestOption ) (* ConvertOrderStatus , error ) {
316
+ r := & request {
317
+ method : http .MethodGet ,
318
+ endpoint : "/sapi/v1/convert/orderStatus" ,
319
+ secType : secTypeSigned ,
320
+ }
321
+ if s .orderId != nil {
322
+ r .setParam ("orderId" , * s .orderId )
323
+ }
324
+ if s .quoteId != nil {
325
+ r .setParam ("quoteId" , * s .quoteId )
326
+ }
327
+ data , err := s .c .callAPI (ctx , r , opts ... )
328
+ if err != nil {
329
+ return nil , err
330
+ }
331
+ res := ConvertOrderStatus {}
332
+ if err = json .Unmarshal (data , & res ); err != nil {
333
+ return nil , err
334
+ }
335
+ return & res , nil
336
+ }
337
+
338
+ // ConvertOrderStatus define the convert order status
339
+ type ConvertOrderStatus struct {
340
+ OrderId int64 `json:"orderId"`
341
+ OrderStatus string `json:"orderStatus"`
342
+ FromAsset string `json:"fromAsset"`
343
+ FromAmount string `json:"fromAmount"`
344
+ ToAsset string `json:"toAsset"`
345
+ ToAmount string `json:"toAmount"`
346
+ Ratio string `json:"ratio"`
347
+ InverseRatio string `json:"inverseRatio"`
348
+ CreateTime int64 `json:"createTime"`
349
+ }
0 commit comments