Skip to main content

binance_sdk/nft/rest_api/
mod.rs

1/*
2 * Binance NFT REST API
3 *
4 * OpenAPI Specification for the Binance NFT 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    nft_api_client: NftApiClient,
32}
33
34impl RestApi {
35    pub fn new(configuration: ConfigurationRestApi) -> Self {
36        let nft_api_client = NftApiClient::new(configuration.clone());
37
38        Self {
39            configuration,
40            nft_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    /// Get NFT `Asset(USER_DATA)`
115    ///
116    /// Get NFT Asset
117    ///
118    /// Weight: 3000
119    ///
120    /// # Arguments
121    ///
122    /// - `params`: [`GetNftAssetParams`]
123    ///   The parameters for this operation.
124    ///
125    /// # Returns
126    ///
127    /// [`RestApiResponse<models::GetNftAssetResponse>`] 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/nft/rest-api/Get-NFT-Asset).
149    ///
150    pub async fn get_nft_asset(
151        &self,
152        params: GetNftAssetParams,
153    ) -> anyhow::Result<RestApiResponse<models::GetNftAssetResponse>> {
154        self.nft_api_client.get_nft_asset(params).await
155    }
156
157    /// Get NFT Deposit `History(USER_DATA)`
158    ///
159    /// et NFT Deposit History
160    ///
161    ///
162    /// * The max interval between startTime and endTime is 90 days.
163    /// * If startTime and endTime are not sent, the recent 7 days' data will be returned.
164    ///
165    /// Weight: 3000
166    ///
167    /// # Arguments
168    ///
169    /// - `params`: [`GetNftDepositHistoryParams`]
170    ///   The parameters for this operation.
171    ///
172    /// # Returns
173    ///
174    /// [`RestApiResponse<models::GetNftDepositHistoryResponse>`] 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/docs/nft/rest-api/Get-NFT-Deposit-History).
196    ///
197    pub async fn get_nft_deposit_history(
198        &self,
199        params: GetNftDepositHistoryParams,
200    ) -> anyhow::Result<RestApiResponse<models::GetNftDepositHistoryResponse>> {
201        self.nft_api_client.get_nft_deposit_history(params).await
202    }
203
204    /// Get NFT Transaction `History(USER_DATA)`
205    ///
206    /// Get NFT Transaction History
207    ///
208    /// * The max interval between startTime and endTime is 90 days.
209    /// * If startTime and endTime are not sent, the recent 7 days' data will be returned.
210    ///
211    /// Weight: 3000
212    ///
213    /// # Arguments
214    ///
215    /// - `params`: [`GetNftTransactionHistoryParams`]
216    ///   The parameters for this operation.
217    ///
218    /// # Returns
219    ///
220    /// [`RestApiResponse<models::GetNftTransactionHistoryResponse>`] on success.
221    ///
222    /// # Errors
223    ///
224    /// This function will return an [`anyhow::Error`] if:
225    /// - the HTTP request fails
226    /// - any parameter is invalid
227    /// - the response cannot be parsed
228    /// - or one of the following occurs:
229    ///   - `RequiredError`
230    ///   - `ConnectorClientError`
231    ///   - `UnauthorizedError`
232    ///   - `ForbiddenError`
233    ///   - `TooManyRequestsError`
234    ///   - `RateLimitBanError`
235    ///   - `ServerError`
236    ///   - `NotFoundError`
237    ///   - `NetworkError`
238    ///   - `BadRequestError`
239    ///
240    ///
241    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/nft/rest-api/Get-NFT-Transaction-History).
242    ///
243    pub async fn get_nft_transaction_history(
244        &self,
245        params: GetNftTransactionHistoryParams,
246    ) -> anyhow::Result<RestApiResponse<models::GetNftTransactionHistoryResponse>> {
247        self.nft_api_client
248            .get_nft_transaction_history(params)
249            .await
250    }
251
252    /// Get NFT Withdraw `History(USER_DATA)`
253    ///
254    /// Get NFT Withdraw History
255    ///
256    /// * The max interval between startTime and endTime is 90 days.
257    /// * If startTime and endTime are not sent, the recent 7 days' data will be returned.
258    ///
259    /// Weight: 3000
260    ///
261    /// # Arguments
262    ///
263    /// - `params`: [`GetNftWithdrawHistoryParams`]
264    ///   The parameters for this operation.
265    ///
266    /// # Returns
267    ///
268    /// [`RestApiResponse<models::GetNftWithdrawHistoryResponse>`] on success.
269    ///
270    /// # Errors
271    ///
272    /// This function will return an [`anyhow::Error`] if:
273    /// - the HTTP request fails
274    /// - any parameter is invalid
275    /// - the response cannot be parsed
276    /// - or one of the following occurs:
277    ///   - `RequiredError`
278    ///   - `ConnectorClientError`
279    ///   - `UnauthorizedError`
280    ///   - `ForbiddenError`
281    ///   - `TooManyRequestsError`
282    ///   - `RateLimitBanError`
283    ///   - `ServerError`
284    ///   - `NotFoundError`
285    ///   - `NetworkError`
286    ///   - `BadRequestError`
287    ///
288    ///
289    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/nft/rest-api/Get-NFT-Withdraw-History).
290    ///
291    pub async fn get_nft_withdraw_history(
292        &self,
293        params: GetNftWithdrawHistoryParams,
294    ) -> anyhow::Result<RestApiResponse<models::GetNftWithdrawHistoryResponse>> {
295        self.nft_api_client.get_nft_withdraw_history(params).await
296    }
297}