Skip to main content

binance_sdk/mining/rest_api/
mod.rs

1/*
2 * Binance Mining REST API
3 *
4 * OpenAPI Specification for the Binance Mining REST 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    mining_api_client: MiningApiClient,
32}
33
34impl RestApi {
35    pub fn new(configuration: ConfigurationRestApi) -> Self {
36        let mining_api_client = MiningApiClient::new(configuration.clone());
37
38        Self {
39            configuration,
40            mining_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: 5
119    ///
120    /// # Arguments
121    ///
122    /// - `params`: [`AccountListParams`]
123    ///   The parameters for this operation.
124    ///
125    /// # Returns
126    ///
127    /// [`RestApiResponse<models::AccountListResponse>`] on success.
128    ///
129    /// # Errors
130    ///
131    /// This function will return an [`anyhow::Error`] if:
132    /// - the HTTP request fails
133    /// - any parameter is invalid
134    /// - the response cannot be parsed
135    /// - or one of the following occurs:
136    ///   - `RequiredError`
137    ///   - `ConnectorClientError`
138    ///   - `UnauthorizedError`
139    ///   - `ForbiddenError`
140    ///   - `TooManyRequestsError`
141    ///   - `RateLimitBanError`
142    ///   - `ServerError`
143    ///   - `NotFoundError`
144    ///   - `NetworkError`
145    ///   - `BadRequestError`
146    ///
147    ///
148    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/mining/rest-api/Account-List).
149    ///
150    pub async fn account_list(
151        &self,
152        params: AccountListParams,
153    ) -> anyhow::Result<RestApiResponse<models::AccountListResponse>> {
154        self.mining_api_client.account_list(params).await
155    }
156
157    /// Acquiring `Algorithm(MARKET_DATA)`
158    ///
159    /// Acquiring Algorithm
160    ///
161    /// Weight: 1
162    ///
163    /// # Arguments
164    ///
165    /// - `params`: [`AcquiringAlgorithmParams`]
166    ///   The parameters for this operation.
167    ///
168    /// # Returns
169    ///
170    /// [`RestApiResponse<models::AcquiringAlgorithmResponse>`] on success.
171    ///
172    /// # Errors
173    ///
174    /// This function will return an [`anyhow::Error`] if:
175    /// - the HTTP request fails
176    /// - any parameter is invalid
177    /// - the response cannot be parsed
178    /// - or one of the following occurs:
179    ///   - `RequiredError`
180    ///   - `ConnectorClientError`
181    ///   - `UnauthorizedError`
182    ///   - `ForbiddenError`
183    ///   - `TooManyRequestsError`
184    ///   - `RateLimitBanError`
185    ///   - `ServerError`
186    ///   - `NotFoundError`
187    ///   - `NetworkError`
188    ///   - `BadRequestError`
189    ///
190    ///
191    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/mining/rest-api/Acquiring-Algorithm).
192    ///
193    pub async fn acquiring_algorithm(
194        &self,
195    ) -> anyhow::Result<RestApiResponse<models::AcquiringAlgorithmResponse>> {
196        self.mining_api_client.acquiring_algorithm().await
197    }
198
199    /// Acquiring `CoinName(MARKET_DATA)`
200    ///
201    /// Acquiring `CoinName`
202    ///
203    /// Weight: 1
204    ///
205    /// # Arguments
206    ///
207    /// - `params`: [`AcquiringCoinnameParams`]
208    ///   The parameters for this operation.
209    ///
210    /// # Returns
211    ///
212    /// [`RestApiResponse<models::AcquiringCoinnameResponse>`] on success.
213    ///
214    /// # Errors
215    ///
216    /// This function will return an [`anyhow::Error`] if:
217    /// - the HTTP request fails
218    /// - any parameter is invalid
219    /// - the response cannot be parsed
220    /// - or one of the following occurs:
221    ///   - `RequiredError`
222    ///   - `ConnectorClientError`
223    ///   - `UnauthorizedError`
224    ///   - `ForbiddenError`
225    ///   - `TooManyRequestsError`
226    ///   - `RateLimitBanError`
227    ///   - `ServerError`
228    ///   - `NotFoundError`
229    ///   - `NetworkError`
230    ///   - `BadRequestError`
231    ///
232    ///
233    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/mining/rest-api/Acquiring-CoinName).
234    ///
235    pub async fn acquiring_coinname(
236        &self,
237    ) -> anyhow::Result<RestApiResponse<models::AcquiringCoinnameResponse>> {
238        self.mining_api_client.acquiring_coinname().await
239    }
240
241    /// Cancel hashrate resale `configuration(USER_DATA)`
242    ///
243    ///
244    /// Weight: 5
245    ///
246    /// # Arguments
247    ///
248    /// - `params`: [`CancelHashrateResaleConfigurationParams`]
249    ///   The parameters for this operation.
250    ///
251    /// # Returns
252    ///
253    /// [`RestApiResponse<models::CancelHashrateResaleConfigurationResponse>`] on success.
254    ///
255    /// # Errors
256    ///
257    /// This function will return an [`anyhow::Error`] if:
258    /// - the HTTP request fails
259    /// - any parameter is invalid
260    /// - the response cannot be parsed
261    /// - or one of the following occurs:
262    ///   - `RequiredError`
263    ///   - `ConnectorClientError`
264    ///   - `UnauthorizedError`
265    ///   - `ForbiddenError`
266    ///   - `TooManyRequestsError`
267    ///   - `RateLimitBanError`
268    ///   - `ServerError`
269    ///   - `NotFoundError`
270    ///   - `NetworkError`
271    ///   - `BadRequestError`
272    ///
273    ///
274    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/mining/rest-api/Cancel-hashrate-resale-configuration).
275    ///
276    pub async fn cancel_hashrate_resale_configuration(
277        &self,
278        params: CancelHashrateResaleConfigurationParams,
279    ) -> anyhow::Result<RestApiResponse<models::CancelHashrateResaleConfigurationResponse>> {
280        self.mining_api_client
281            .cancel_hashrate_resale_configuration(params)
282            .await
283    }
284
285    /// Earnings `List(USER_DATA)`
286    ///
287    /// Query Earnings List
288    ///
289    /// Weight: 5
290    ///
291    /// # Arguments
292    ///
293    /// - `params`: [`EarningsListParams`]
294    ///   The parameters for this operation.
295    ///
296    /// # Returns
297    ///
298    /// [`RestApiResponse<models::EarningsListResponse>`] on success.
299    ///
300    /// # Errors
301    ///
302    /// This function will return an [`anyhow::Error`] if:
303    /// - the HTTP request fails
304    /// - any parameter is invalid
305    /// - the response cannot be parsed
306    /// - or one of the following occurs:
307    ///   - `RequiredError`
308    ///   - `ConnectorClientError`
309    ///   - `UnauthorizedError`
310    ///   - `ForbiddenError`
311    ///   - `TooManyRequestsError`
312    ///   - `RateLimitBanError`
313    ///   - `ServerError`
314    ///   - `NotFoundError`
315    ///   - `NetworkError`
316    ///   - `BadRequestError`
317    ///
318    ///
319    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/mining/rest-api/Earnings-List).
320    ///
321    pub async fn earnings_list(
322        &self,
323        params: EarningsListParams,
324    ) -> anyhow::Result<RestApiResponse<models::EarningsListResponse>> {
325        self.mining_api_client.earnings_list(params).await
326    }
327
328    /// Extra Bonus `List(USER_DATA)`
329    ///
330    /// Extra Bonus List
331    ///
332    /// Weight: 5
333    ///
334    /// # Arguments
335    ///
336    /// - `params`: [`ExtraBonusListParams`]
337    ///   The parameters for this operation.
338    ///
339    /// # Returns
340    ///
341    /// [`RestApiResponse<models::ExtraBonusListResponse>`] on success.
342    ///
343    /// # Errors
344    ///
345    /// This function will return an [`anyhow::Error`] if:
346    /// - the HTTP request fails
347    /// - any parameter is invalid
348    /// - the response cannot be parsed
349    /// - or one of the following occurs:
350    ///   - `RequiredError`
351    ///   - `ConnectorClientError`
352    ///   - `UnauthorizedError`
353    ///   - `ForbiddenError`
354    ///   - `TooManyRequestsError`
355    ///   - `RateLimitBanError`
356    ///   - `ServerError`
357    ///   - `NotFoundError`
358    ///   - `NetworkError`
359    ///   - `BadRequestError`
360    ///
361    ///
362    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/mining/rest-api/Extra-Bonus-List).
363    ///
364    pub async fn extra_bonus_list(
365        &self,
366        params: ExtraBonusListParams,
367    ) -> anyhow::Result<RestApiResponse<models::ExtraBonusListResponse>> {
368        self.mining_api_client.extra_bonus_list(params).await
369    }
370
371    /// Hashrate Resale `Detail(USER_DATA)`
372    ///
373    /// Hashrate Resale `Detail(USER_DATA)`
374    ///
375    /// Weight: 5
376    ///
377    /// # Arguments
378    ///
379    /// - `params`: [`HashrateResaleDetailParams`]
380    ///   The parameters for this operation.
381    ///
382    /// # Returns
383    ///
384    /// [`RestApiResponse<models::HashrateResaleDetailResponse>`] on success.
385    ///
386    /// # Errors
387    ///
388    /// This function will return an [`anyhow::Error`] if:
389    /// - the HTTP request fails
390    /// - any parameter is invalid
391    /// - the response cannot be parsed
392    /// - or one of the following occurs:
393    ///   - `RequiredError`
394    ///   - `ConnectorClientError`
395    ///   - `UnauthorizedError`
396    ///   - `ForbiddenError`
397    ///   - `TooManyRequestsError`
398    ///   - `RateLimitBanError`
399    ///   - `ServerError`
400    ///   - `NotFoundError`
401    ///   - `NetworkError`
402    ///   - `BadRequestError`
403    ///
404    ///
405    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/mining/rest-api/Hashrate-Resale-Detail).
406    ///
407    pub async fn hashrate_resale_detail(
408        &self,
409        params: HashrateResaleDetailParams,
410    ) -> anyhow::Result<RestApiResponse<models::HashrateResaleDetailResponse>> {
411        self.mining_api_client.hashrate_resale_detail(params).await
412    }
413
414    /// Hashrate Resale List
415    ///
416    /// Hashrate Resale List
417    ///
418    /// Weight: 5
419    ///
420    /// # Arguments
421    ///
422    /// - `params`: [`HashrateResaleListParams`]
423    ///   The parameters for this operation.
424    ///
425    /// # Returns
426    ///
427    /// [`RestApiResponse<models::HashrateResaleListResponse>`] on success.
428    ///
429    /// # Errors
430    ///
431    /// This function will return an [`anyhow::Error`] if:
432    /// - the HTTP request fails
433    /// - any parameter is invalid
434    /// - the response cannot be parsed
435    /// - or one of the following occurs:
436    ///   - `RequiredError`
437    ///   - `ConnectorClientError`
438    ///   - `UnauthorizedError`
439    ///   - `ForbiddenError`
440    ///   - `TooManyRequestsError`
441    ///   - `RateLimitBanError`
442    ///   - `ServerError`
443    ///   - `NotFoundError`
444    ///   - `NetworkError`
445    ///   - `BadRequestError`
446    ///
447    ///
448    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/mining/rest-api/Hashrate-Resale-List).
449    ///
450    pub async fn hashrate_resale_list(
451        &self,
452        params: HashrateResaleListParams,
453    ) -> anyhow::Result<RestApiResponse<models::HashrateResaleListResponse>> {
454        self.mining_api_client.hashrate_resale_list(params).await
455    }
456
457    /// Hashrate Resale `Request(USER_DATA)`
458    ///
459    /// Hashrate Resale Request
460    ///
461    /// Weight: 5
462    ///
463    /// # Arguments
464    ///
465    /// - `params`: [`HashrateResaleRequestParams`]
466    ///   The parameters for this operation.
467    ///
468    /// # Returns
469    ///
470    /// [`RestApiResponse<models::HashrateResaleRequestResponse>`] on success.
471    ///
472    /// # Errors
473    ///
474    /// This function will return an [`anyhow::Error`] if:
475    /// - the HTTP request fails
476    /// - any parameter is invalid
477    /// - the response cannot be parsed
478    /// - or one of the following occurs:
479    ///   - `RequiredError`
480    ///   - `ConnectorClientError`
481    ///   - `UnauthorizedError`
482    ///   - `ForbiddenError`
483    ///   - `TooManyRequestsError`
484    ///   - `RateLimitBanError`
485    ///   - `ServerError`
486    ///   - `NotFoundError`
487    ///   - `NetworkError`
488    ///   - `BadRequestError`
489    ///
490    ///
491    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/mining/rest-api/Hashrate-Resale-Request).
492    ///
493    pub async fn hashrate_resale_request(
494        &self,
495        params: HashrateResaleRequestParams,
496    ) -> anyhow::Result<RestApiResponse<models::HashrateResaleRequestResponse>> {
497        self.mining_api_client.hashrate_resale_request(params).await
498    }
499
500    /// Mining Account `Earning(USER_DATA)`
501    ///
502    /// Mining Account Earning
503    ///
504    /// Weight: 5
505    ///
506    /// # Arguments
507    ///
508    /// - `params`: [`MiningAccountEarningParams`]
509    ///   The parameters for this operation.
510    ///
511    /// # Returns
512    ///
513    /// [`RestApiResponse<models::MiningAccountEarningResponse>`] on success.
514    ///
515    /// # Errors
516    ///
517    /// This function will return an [`anyhow::Error`] if:
518    /// - the HTTP request fails
519    /// - any parameter is invalid
520    /// - the response cannot be parsed
521    /// - or one of the following occurs:
522    ///   - `RequiredError`
523    ///   - `ConnectorClientError`
524    ///   - `UnauthorizedError`
525    ///   - `ForbiddenError`
526    ///   - `TooManyRequestsError`
527    ///   - `RateLimitBanError`
528    ///   - `ServerError`
529    ///   - `NotFoundError`
530    ///   - `NetworkError`
531    ///   - `BadRequestError`
532    ///
533    ///
534    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/mining/rest-api/Mining-Account-Earning).
535    ///
536    pub async fn mining_account_earning(
537        &self,
538        params: MiningAccountEarningParams,
539    ) -> anyhow::Result<RestApiResponse<models::MiningAccountEarningResponse>> {
540        self.mining_api_client.mining_account_earning(params).await
541    }
542
543    /// Request for Detail Miner `List(USER_DATA)`
544    ///
545    /// Request for Detail Miner List
546    ///
547    /// Weight: 5
548    ///
549    /// # Arguments
550    ///
551    /// - `params`: [`RequestForDetailMinerListParams`]
552    ///   The parameters for this operation.
553    ///
554    /// # Returns
555    ///
556    /// [`RestApiResponse<models::RequestForDetailMinerListResponse>`] on success.
557    ///
558    /// # Errors
559    ///
560    /// This function will return an [`anyhow::Error`] if:
561    /// - the HTTP request fails
562    /// - any parameter is invalid
563    /// - the response cannot be parsed
564    /// - or one of the following occurs:
565    ///   - `RequiredError`
566    ///   - `ConnectorClientError`
567    ///   - `UnauthorizedError`
568    ///   - `ForbiddenError`
569    ///   - `TooManyRequestsError`
570    ///   - `RateLimitBanError`
571    ///   - `ServerError`
572    ///   - `NotFoundError`
573    ///   - `NetworkError`
574    ///   - `BadRequestError`
575    ///
576    ///
577    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/mining/rest-api/Request-for-Detail-Miner-List).
578    ///
579    pub async fn request_for_detail_miner_list(
580        &self,
581        params: RequestForDetailMinerListParams,
582    ) -> anyhow::Result<RestApiResponse<models::RequestForDetailMinerListResponse>> {
583        self.mining_api_client
584            .request_for_detail_miner_list(params)
585            .await
586    }
587
588    /// Request for Miner `List(USER_DATA)`
589    ///
590    /// Request for Miner List
591    ///
592    /// Weight: 5
593    ///
594    /// # Arguments
595    ///
596    /// - `params`: [`RequestForMinerListParams`]
597    ///   The parameters for this operation.
598    ///
599    /// # Returns
600    ///
601    /// [`RestApiResponse<models::RequestForMinerListResponse>`] on success.
602    ///
603    /// # Errors
604    ///
605    /// This function will return an [`anyhow::Error`] if:
606    /// - the HTTP request fails
607    /// - any parameter is invalid
608    /// - the response cannot be parsed
609    /// - or one of the following occurs:
610    ///   - `RequiredError`
611    ///   - `ConnectorClientError`
612    ///   - `UnauthorizedError`
613    ///   - `ForbiddenError`
614    ///   - `TooManyRequestsError`
615    ///   - `RateLimitBanError`
616    ///   - `ServerError`
617    ///   - `NotFoundError`
618    ///   - `NetworkError`
619    ///   - `BadRequestError`
620    ///
621    ///
622    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/mining/rest-api/Request-for-Miner-List).
623    ///
624    pub async fn request_for_miner_list(
625        &self,
626        params: RequestForMinerListParams,
627    ) -> anyhow::Result<RestApiResponse<models::RequestForMinerListResponse>> {
628        self.mining_api_client.request_for_miner_list(params).await
629    }
630
631    /// Statistic `List(USER_DATA)`
632    ///
633    /// Statistic List
634    ///
635    /// Weight: 5
636    ///
637    /// # Arguments
638    ///
639    /// - `params`: [`StatisticListParams`]
640    ///   The parameters for this operation.
641    ///
642    /// # Returns
643    ///
644    /// [`RestApiResponse<models::StatisticListResponse>`] on success.
645    ///
646    /// # Errors
647    ///
648    /// This function will return an [`anyhow::Error`] if:
649    /// - the HTTP request fails
650    /// - any parameter is invalid
651    /// - the response cannot be parsed
652    /// - or one of the following occurs:
653    ///   - `RequiredError`
654    ///   - `ConnectorClientError`
655    ///   - `UnauthorizedError`
656    ///   - `ForbiddenError`
657    ///   - `TooManyRequestsError`
658    ///   - `RateLimitBanError`
659    ///   - `ServerError`
660    ///   - `NotFoundError`
661    ///   - `NetworkError`
662    ///   - `BadRequestError`
663    ///
664    ///
665    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/mining/rest-api/Statistic-List).
666    ///
667    pub async fn statistic_list(
668        &self,
669        params: StatisticListParams,
670    ) -> anyhow::Result<RestApiResponse<models::StatisticListResponse>> {
671        self.mining_api_client.statistic_list(params).await
672    }
673}