Skip to main content

binance_sdk/mining/rest_api/
mod.rs

1/*
2 * Mining REST API
3 *
4 * Query mining status, earnings, and account data via the Binance Pool API.
5 *
6 * The version of the OpenAPI document: 1.0.0
7 *
8 *
9 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
10 * https://openapi-generator.tech
11 * Do not edit the class manually.
12 */
13
14#![allow(unused_imports)]
15use http::Method;
16use serde::de::DeserializeOwned;
17use serde_json::Value;
18use std::collections::BTreeMap;
19
20use crate::common::{config::ConfigurationRestApi, models::RestApiResponse, utils::send_request};
21
22mod apis;
23mod models;
24
25pub use apis::*;
26pub use models::*;
27
28#[derive(Debug, Clone)]
29pub struct RestApi {
30    configuration: ConfigurationRestApi,
31    api_client: ApiClient,
32}
33
34impl RestApi {
35    pub fn new(configuration: ConfigurationRestApi) -> Self {
36        let api_client = ApiClient::new(configuration.clone());
37
38        Self {
39            configuration,
40            api_client,
41        }
42    }
43
44    /// Send an unsigned request to the API
45    ///
46    /// # Arguments
47    ///
48    /// * `endpoint` - The API endpoint to send the request to
49    /// * `method` - The HTTP method to use for the request
50    /// * `query_params` - A map of query parameters to send with the request
51    /// * `body_params` - A map of body parameters to send with the request
52    ///
53    /// # Returns
54    ///
55    /// A `RestApiResponse` containing the deserialized response data on success, or an error if the request fails
56    ///
57    /// # Errors
58    ///
59    /// Returns an `anyhow::Error` if the HTTP request fails or if parsing the response fails
60    pub async fn send_request<R: DeserializeOwned + Send + 'static>(
61        &self,
62        endpoint: &str,
63        method: Method,
64        query_params: BTreeMap<String, Value>,
65        body_params: BTreeMap<String, Value>,
66    ) -> anyhow::Result<RestApiResponse<R>> {
67        send_request::<R>(
68            &self.configuration,
69            endpoint,
70            method,
71            query_params,
72            body_params,
73            None,
74            false,
75        )
76        .await
77    }
78
79    /// Send a signed request to the API
80    ///
81    /// # Arguments
82    ///
83    /// * `endpoint` - The API endpoint to send the request to
84    /// * `method` - The HTTP method to use for the request
85    /// * `query_params` - A map of query parameters to send with the request
86    /// * `body_params` - A map of body parameters to send with the request
87    ///
88    /// # Returns
89    ///
90    /// A `RestApiResponse` containing the deserialized response data on success, or an error if the request fails
91    ///
92    /// # Errors
93    ///
94    /// Returns an `anyhow::Error` if the HTTP request fails or if parsing the response fails
95    pub async fn send_signed_request<R: DeserializeOwned + Send + 'static>(
96        &self,
97        endpoint: &str,
98        method: Method,
99        query_params: BTreeMap<String, Value>,
100        body_params: BTreeMap<String, Value>,
101    ) -> anyhow::Result<RestApiResponse<R>> {
102        send_request::<R>(
103            &self.configuration,
104            endpoint,
105            method,
106            query_params,
107            body_params,
108            None,
109            true,
110        )
111        .await
112    }
113
114    /// Account List (`USER_DATA`)
115    ///
116    /// Query Account List
117    ///
118    /// Weight(IP): 1
119    ///
120    /// Security Type: `USER_DATA`
121    ///
122    /// # Arguments
123    ///
124    /// - `params`: [`AccountListParams`]
125    ///   The parameters for this operation.
126    ///
127    /// # Returns
128    ///
129    /// [`RestApiResponse<models::AccountListResponse>`] on success.
130    ///
131    /// # Errors
132    ///
133    /// This function will return an [`anyhow::Error`] if:
134    /// - the HTTP request fails
135    /// - any parameter is invalid
136    /// - the response cannot be parsed
137    /// - or one of the following occurs:
138    ///   - `RequiredError`
139    ///   - `ConnectorClientError`
140    ///   - `UnauthorizedError`
141    ///   - `ForbiddenError`
142    ///   - `TooManyRequestsError`
143    ///   - `RateLimitBanError`
144    ///   - `ServerError`
145    ///   - `NotFoundError`
146    ///   - `NetworkError`
147    ///   - `BadRequestError`
148    ///
149    ///
150    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/investment-and-services-mining/api/rest-api/~#account-list).
151    ///
152    pub async fn account_list(
153        &self,
154        params: AccountListParams,
155    ) -> anyhow::Result<RestApiResponse<models::AccountListResponse>> {
156        self.api_client.account_list(params).await
157    }
158
159    /// Acquiring Algorithm (`MARKET_DATA`)
160    ///
161    /// Acquiring Algorithm
162    ///
163    /// Weight(IP): 1
164    ///
165    /// Security Type: `MARKET_DATA`
166    ///
167    /// # Arguments
168    ///
169    /// - `params`: [`AcquiringAlgorithmParams`]
170    ///   The parameters for this operation.
171    ///
172    /// # Returns
173    ///
174    /// [`RestApiResponse<models::AcquiringAlgorithmResponse>`] on success.
175    ///
176    /// # Errors
177    ///
178    /// This function will return an [`anyhow::Error`] if:
179    /// - the HTTP request fails
180    /// - any parameter is invalid
181    /// - the response cannot be parsed
182    /// - or one of the following occurs:
183    ///   - `RequiredError`
184    ///   - `ConnectorClientError`
185    ///   - `UnauthorizedError`
186    ///   - `ForbiddenError`
187    ///   - `TooManyRequestsError`
188    ///   - `RateLimitBanError`
189    ///   - `ServerError`
190    ///   - `NotFoundError`
191    ///   - `NetworkError`
192    ///   - `BadRequestError`
193    ///
194    ///
195    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/investment-and-services-mining/api/rest-api/~#acquiring-algorithm).
196    ///
197    pub async fn acquiring_algorithm(
198        &self,
199    ) -> anyhow::Result<RestApiResponse<models::AcquiringAlgorithmResponse>> {
200        self.api_client.acquiring_algorithm().await
201    }
202
203    /// Acquiring `CoinName` (`MARKET_DATA`)
204    ///
205    /// Acquiring `CoinName`
206    ///
207    /// Weight(IP): 1
208    ///
209    /// Security Type: `MARKET_DATA`
210    ///
211    /// # Arguments
212    ///
213    /// - `params`: [`AcquiringCoinnameParams`]
214    ///   The parameters for this operation.
215    ///
216    /// # Returns
217    ///
218    /// [`RestApiResponse<models::AcquiringCoinnameResponse>`] on success.
219    ///
220    /// # Errors
221    ///
222    /// This function will return an [`anyhow::Error`] if:
223    /// - the HTTP request fails
224    /// - any parameter is invalid
225    /// - the response cannot be parsed
226    /// - or one of the following occurs:
227    ///   - `RequiredError`
228    ///   - `ConnectorClientError`
229    ///   - `UnauthorizedError`
230    ///   - `ForbiddenError`
231    ///   - `TooManyRequestsError`
232    ///   - `RateLimitBanError`
233    ///   - `ServerError`
234    ///   - `NotFoundError`
235    ///   - `NetworkError`
236    ///   - `BadRequestError`
237    ///
238    ///
239    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/investment-and-services-mining/api/rest-api/~#acquiring-coinname).
240    ///
241    pub async fn acquiring_coinname(
242        &self,
243    ) -> anyhow::Result<RestApiResponse<models::AcquiringCoinnameResponse>> {
244        self.api_client.acquiring_coinname().await
245    }
246
247    /// Cancel hashrate resale configuration (`USER_DATA`)
248    ///
249    /// Cancel hashrate resale configuration
250    ///
251    /// Weight(IP): 1
252    ///
253    /// Security Type: `USER_DATA`
254    ///
255    /// # Arguments
256    ///
257    /// - `params`: [`CancelHashrateResaleConfigurationParams`]
258    ///   The parameters for this operation.
259    ///
260    /// # Returns
261    ///
262    /// [`RestApiResponse<models::CancelHashrateResaleConfigurationResponse>`] on success.
263    ///
264    /// # Errors
265    ///
266    /// This function will return an [`anyhow::Error`] if:
267    /// - the HTTP request fails
268    /// - any parameter is invalid
269    /// - the response cannot be parsed
270    /// - or one of the following occurs:
271    ///   - `RequiredError`
272    ///   - `ConnectorClientError`
273    ///   - `UnauthorizedError`
274    ///   - `ForbiddenError`
275    ///   - `TooManyRequestsError`
276    ///   - `RateLimitBanError`
277    ///   - `ServerError`
278    ///   - `NotFoundError`
279    ///   - `NetworkError`
280    ///   - `BadRequestError`
281    ///
282    ///
283    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/investment-and-services-mining/api/rest-api/~#cancel-hashrate-resale-configuration).
284    ///
285    pub async fn cancel_hashrate_resale_configuration(
286        &self,
287        params: CancelHashrateResaleConfigurationParams,
288    ) -> anyhow::Result<RestApiResponse<models::CancelHashrateResaleConfigurationResponse>> {
289        self.api_client
290            .cancel_hashrate_resale_configuration(params)
291            .await
292    }
293
294    /// Earnings List (`USER_DATA`)
295    ///
296    /// Query Earnings List
297    ///
298    /// Weight(IP): 1
299    ///
300    /// Security Type: `USER_DATA`
301    ///
302    /// # Arguments
303    ///
304    /// - `params`: [`EarningsListParams`]
305    ///   The parameters for this operation.
306    ///
307    /// # Returns
308    ///
309    /// [`RestApiResponse<models::EarningsListResponse>`] on success.
310    ///
311    /// # Errors
312    ///
313    /// This function will return an [`anyhow::Error`] if:
314    /// - the HTTP request fails
315    /// - any parameter is invalid
316    /// - the response cannot be parsed
317    /// - or one of the following occurs:
318    ///   - `RequiredError`
319    ///   - `ConnectorClientError`
320    ///   - `UnauthorizedError`
321    ///   - `ForbiddenError`
322    ///   - `TooManyRequestsError`
323    ///   - `RateLimitBanError`
324    ///   - `ServerError`
325    ///   - `NotFoundError`
326    ///   - `NetworkError`
327    ///   - `BadRequestError`
328    ///
329    ///
330    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/investment-and-services-mining/api/rest-api/~#earnings-list).
331    ///
332    pub async fn earnings_list(
333        &self,
334        params: EarningsListParams,
335    ) -> anyhow::Result<RestApiResponse<models::EarningsListResponse>> {
336        self.api_client.earnings_list(params).await
337    }
338
339    /// Extra Bonus List (`USER_DATA`)
340    ///
341    /// Extra Bonus List
342    ///
343    /// Weight(IP): 1
344    ///
345    /// Security Type: `USER_DATA`
346    ///
347    /// # Arguments
348    ///
349    /// - `params`: [`ExtraBonusListParams`]
350    ///   The parameters for this operation.
351    ///
352    /// # Returns
353    ///
354    /// [`RestApiResponse<models::ExtraBonusListResponse>`] on success.
355    ///
356    /// # Errors
357    ///
358    /// This function will return an [`anyhow::Error`] if:
359    /// - the HTTP request fails
360    /// - any parameter is invalid
361    /// - the response cannot be parsed
362    /// - or one of the following occurs:
363    ///   - `RequiredError`
364    ///   - `ConnectorClientError`
365    ///   - `UnauthorizedError`
366    ///   - `ForbiddenError`
367    ///   - `TooManyRequestsError`
368    ///   - `RateLimitBanError`
369    ///   - `ServerError`
370    ///   - `NotFoundError`
371    ///   - `NetworkError`
372    ///   - `BadRequestError`
373    ///
374    ///
375    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/investment-and-services-mining/api/rest-api/~#extra-bonus-list).
376    ///
377    pub async fn extra_bonus_list(
378        &self,
379        params: ExtraBonusListParams,
380    ) -> anyhow::Result<RestApiResponse<models::ExtraBonusListResponse>> {
381        self.api_client.extra_bonus_list(params).await
382    }
383
384    /// Hashrate Resale Detail (`USER_DATA`)
385    ///
386    /// Hashrate Resale `Detail(USER_DATA)`
387    ///
388    /// Weight(IP): 1
389    ///
390    /// Security Type: `USER_DATA`
391    ///
392    /// # Arguments
393    ///
394    /// - `params`: [`HashrateResaleDetailParams`]
395    ///   The parameters for this operation.
396    ///
397    /// # Returns
398    ///
399    /// [`RestApiResponse<models::HashrateResaleDetailResponse>`] on success.
400    ///
401    /// # Errors
402    ///
403    /// This function will return an [`anyhow::Error`] if:
404    /// - the HTTP request fails
405    /// - any parameter is invalid
406    /// - the response cannot be parsed
407    /// - or one of the following occurs:
408    ///   - `RequiredError`
409    ///   - `ConnectorClientError`
410    ///   - `UnauthorizedError`
411    ///   - `ForbiddenError`
412    ///   - `TooManyRequestsError`
413    ///   - `RateLimitBanError`
414    ///   - `ServerError`
415    ///   - `NotFoundError`
416    ///   - `NetworkError`
417    ///   - `BadRequestError`
418    ///
419    ///
420    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/investment-and-services-mining/api/rest-api/~#hashrate-resale-detail).
421    ///
422    pub async fn hashrate_resale_detail(
423        &self,
424        params: HashrateResaleDetailParams,
425    ) -> anyhow::Result<RestApiResponse<models::HashrateResaleDetailResponse>> {
426        self.api_client.hashrate_resale_detail(params).await
427    }
428
429    /// Hashrate Resale List (`USER_DATA`)
430    ///
431    /// Hashrate Resale List
432    ///
433    /// Weight(IP): 1
434    ///
435    /// Security Type: `USER_DATA`
436    ///
437    /// # Arguments
438    ///
439    /// - `params`: [`HashrateResaleListParams`]
440    ///   The parameters for this operation.
441    ///
442    /// # Returns
443    ///
444    /// [`RestApiResponse<models::HashrateResaleListResponse>`] on success.
445    ///
446    /// # Errors
447    ///
448    /// This function will return an [`anyhow::Error`] if:
449    /// - the HTTP request fails
450    /// - any parameter is invalid
451    /// - the response cannot be parsed
452    /// - or one of the following occurs:
453    ///   - `RequiredError`
454    ///   - `ConnectorClientError`
455    ///   - `UnauthorizedError`
456    ///   - `ForbiddenError`
457    ///   - `TooManyRequestsError`
458    ///   - `RateLimitBanError`
459    ///   - `ServerError`
460    ///   - `NotFoundError`
461    ///   - `NetworkError`
462    ///   - `BadRequestError`
463    ///
464    ///
465    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/investment-and-services-mining/api/rest-api/~#hashrate-resale-list).
466    ///
467    pub async fn hashrate_resale_list(
468        &self,
469        params: HashrateResaleListParams,
470    ) -> anyhow::Result<RestApiResponse<models::HashrateResaleListResponse>> {
471        self.api_client.hashrate_resale_list(params).await
472    }
473
474    /// Hashrate Resale Request (`USER_DATA`)
475    ///
476    /// Hashrate Resale Request
477    ///
478    /// Weight(IP): 1
479    ///
480    /// Security Type: `USER_DATA`
481    ///
482    /// # Arguments
483    ///
484    /// - `params`: [`HashrateResaleRequestParams`]
485    ///   The parameters for this operation.
486    ///
487    /// # Returns
488    ///
489    /// [`RestApiResponse<models::HashrateResaleRequestResponse>`] on success.
490    ///
491    /// # Errors
492    ///
493    /// This function will return an [`anyhow::Error`] if:
494    /// - the HTTP request fails
495    /// - any parameter is invalid
496    /// - the response cannot be parsed
497    /// - or one of the following occurs:
498    ///   - `RequiredError`
499    ///   - `ConnectorClientError`
500    ///   - `UnauthorizedError`
501    ///   - `ForbiddenError`
502    ///   - `TooManyRequestsError`
503    ///   - `RateLimitBanError`
504    ///   - `ServerError`
505    ///   - `NotFoundError`
506    ///   - `NetworkError`
507    ///   - `BadRequestError`
508    ///
509    ///
510    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/investment-and-services-mining/api/rest-api/~#hashrate-resale-request).
511    ///
512    pub async fn hashrate_resale_request(
513        &self,
514        params: HashrateResaleRequestParams,
515    ) -> anyhow::Result<RestApiResponse<models::HashrateResaleRequestResponse>> {
516        self.api_client.hashrate_resale_request(params).await
517    }
518
519    /// Mining Account Earning (`USER_DATA`)
520    ///
521    /// Mining Account Earning
522    ///
523    /// Weight(IP): 1
524    ///
525    /// Security Type: `USER_DATA`
526    ///
527    /// # Arguments
528    ///
529    /// - `params`: [`MiningAccountEarningParams`]
530    ///   The parameters for this operation.
531    ///
532    /// # Returns
533    ///
534    /// [`RestApiResponse<models::MiningAccountEarningResponse>`] on success.
535    ///
536    /// # Errors
537    ///
538    /// This function will return an [`anyhow::Error`] if:
539    /// - the HTTP request fails
540    /// - any parameter is invalid
541    /// - the response cannot be parsed
542    /// - or one of the following occurs:
543    ///   - `RequiredError`
544    ///   - `ConnectorClientError`
545    ///   - `UnauthorizedError`
546    ///   - `ForbiddenError`
547    ///   - `TooManyRequestsError`
548    ///   - `RateLimitBanError`
549    ///   - `ServerError`
550    ///   - `NotFoundError`
551    ///   - `NetworkError`
552    ///   - `BadRequestError`
553    ///
554    ///
555    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/investment-and-services-mining/api/rest-api/~#mining-account-earning).
556    ///
557    pub async fn mining_account_earning(
558        &self,
559        params: MiningAccountEarningParams,
560    ) -> anyhow::Result<RestApiResponse<models::MiningAccountEarningResponse>> {
561        self.api_client.mining_account_earning(params).await
562    }
563
564    /// Request for Detail Miner List (`USER_DATA`)
565    ///
566    /// Request for Detail Miner List
567    ///
568    /// Weight(IP): 1
569    ///
570    /// Security Type: `USER_DATA`
571    ///
572    /// # Arguments
573    ///
574    /// - `params`: [`RequestForDetailMinerListParams`]
575    ///   The parameters for this operation.
576    ///
577    /// # Returns
578    ///
579    /// [`RestApiResponse<models::RequestForDetailMinerListResponse>`] on success.
580    ///
581    /// # Errors
582    ///
583    /// This function will return an [`anyhow::Error`] if:
584    /// - the HTTP request fails
585    /// - any parameter is invalid
586    /// - the response cannot be parsed
587    /// - or one of the following occurs:
588    ///   - `RequiredError`
589    ///   - `ConnectorClientError`
590    ///   - `UnauthorizedError`
591    ///   - `ForbiddenError`
592    ///   - `TooManyRequestsError`
593    ///   - `RateLimitBanError`
594    ///   - `ServerError`
595    ///   - `NotFoundError`
596    ///   - `NetworkError`
597    ///   - `BadRequestError`
598    ///
599    ///
600    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/investment-and-services-mining/api/rest-api/~#request-for-detail-miner-list).
601    ///
602    pub async fn request_for_detail_miner_list(
603        &self,
604        params: RequestForDetailMinerListParams,
605    ) -> anyhow::Result<RestApiResponse<models::RequestForDetailMinerListResponse>> {
606        self.api_client.request_for_detail_miner_list(params).await
607    }
608
609    /// Request for Miner List (`USER_DATA`)
610    ///
611    /// Request for Miner List
612    ///
613    /// Weight(IP): 1
614    ///
615    /// Security Type: `USER_DATA`
616    ///
617    /// # Arguments
618    ///
619    /// - `params`: [`RequestForMinerListParams`]
620    ///   The parameters for this operation.
621    ///
622    /// # Returns
623    ///
624    /// [`RestApiResponse<models::RequestForMinerListResponse>`] on success.
625    ///
626    /// # Errors
627    ///
628    /// This function will return an [`anyhow::Error`] if:
629    /// - the HTTP request fails
630    /// - any parameter is invalid
631    /// - the response cannot be parsed
632    /// - or one of the following occurs:
633    ///   - `RequiredError`
634    ///   - `ConnectorClientError`
635    ///   - `UnauthorizedError`
636    ///   - `ForbiddenError`
637    ///   - `TooManyRequestsError`
638    ///   - `RateLimitBanError`
639    ///   - `ServerError`
640    ///   - `NotFoundError`
641    ///   - `NetworkError`
642    ///   - `BadRequestError`
643    ///
644    ///
645    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/investment-and-services-mining/api/rest-api/~#request-for-miner-list).
646    ///
647    pub async fn request_for_miner_list(
648        &self,
649        params: RequestForMinerListParams,
650    ) -> anyhow::Result<RestApiResponse<models::RequestForMinerListResponse>> {
651        self.api_client.request_for_miner_list(params).await
652    }
653
654    /// Statistic List (`USER_DATA`)
655    ///
656    /// Statistic List
657    ///
658    /// Weight(IP): 1
659    ///
660    /// Security Type: `USER_DATA`
661    ///
662    /// # Arguments
663    ///
664    /// - `params`: [`StatisticListParams`]
665    ///   The parameters for this operation.
666    ///
667    /// # Returns
668    ///
669    /// [`RestApiResponse<models::StatisticListResponse>`] on success.
670    ///
671    /// # Errors
672    ///
673    /// This function will return an [`anyhow::Error`] if:
674    /// - the HTTP request fails
675    /// - any parameter is invalid
676    /// - the response cannot be parsed
677    /// - or one of the following occurs:
678    ///   - `RequiredError`
679    ///   - `ConnectorClientError`
680    ///   - `UnauthorizedError`
681    ///   - `ForbiddenError`
682    ///   - `TooManyRequestsError`
683    ///   - `RateLimitBanError`
684    ///   - `ServerError`
685    ///   - `NotFoundError`
686    ///   - `NetworkError`
687    ///   - `BadRequestError`
688    ///
689    ///
690    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/investment-and-services-mining/api/rest-api/~#statistic-list).
691    ///
692    pub async fn statistic_list(
693        &self,
694        params: StatisticListParams,
695    ) -> anyhow::Result<RestApiResponse<models::StatisticListResponse>> {
696        self.api_client.statistic_list(params).await
697    }
698}