1use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::spot::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17#[derive(Clone, Debug, Default)]
19pub struct GetNftHistoryDepositV1Params {
20 pub timestamp: i64,
21 pub start_time: Option<i64>,
22 pub end_time: Option<i64>,
23 pub limit: Option<i32>,
25 pub page: Option<i32>,
27 pub recv_window: Option<i64>
28}
29
30#[derive(Clone, Debug, Default)]
32pub struct GetNftHistoryTransactionsV1Params {
33 pub order_type: i32,
35 pub timestamp: i64,
36 pub start_time: Option<i64>,
37 pub end_time: Option<i64>,
38 pub limit: Option<i32>,
40 pub page: Option<i32>,
42 pub recv_window: Option<i64>
43}
44
45#[derive(Clone, Debug, Default)]
47pub struct GetNftHistoryWithdrawV1Params {
48 pub timestamp: i64,
49 pub start_time: Option<i64>,
50 pub end_time: Option<i64>,
51 pub limit: Option<i32>,
53 pub page: Option<i32>,
55 pub recv_window: Option<i64>
56}
57
58#[derive(Clone, Debug, Default)]
60pub struct GetNftUserGetAssetV1Params {
61 pub timestamp: i64,
62 pub limit: Option<i32>,
64 pub page: Option<i32>,
66 pub recv_window: Option<i64>
67}
68
69
70#[derive(Debug, Clone, Serialize, Deserialize)]
72#[serde(untagged)]
73pub enum GetNftHistoryDepositV1Error {
74 Status4XX(models::ApiError),
75 Status5XX(models::ApiError),
76 UnknownValue(serde_json::Value),
77}
78
79#[derive(Debug, Clone, Serialize, Deserialize)]
81#[serde(untagged)]
82pub enum GetNftHistoryTransactionsV1Error {
83 Status4XX(models::ApiError),
84 Status5XX(models::ApiError),
85 UnknownValue(serde_json::Value),
86}
87
88#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum GetNftHistoryWithdrawV1Error {
92 Status4XX(models::ApiError),
93 Status5XX(models::ApiError),
94 UnknownValue(serde_json::Value),
95}
96
97#[derive(Debug, Clone, Serialize, Deserialize)]
99#[serde(untagged)]
100pub enum GetNftUserGetAssetV1Error {
101 Status4XX(models::ApiError),
102 Status5XX(models::ApiError),
103 UnknownValue(serde_json::Value),
104}
105
106
107pub async fn get_nft_history_deposit_v1(configuration: &configuration::Configuration, params: GetNftHistoryDepositV1Params) -> Result<models::GetNftHistoryDepositV1Resp, Error<GetNftHistoryDepositV1Error>> {
109
110 let uri_str = format!("{}/sapi/v1/nft/history/deposit", configuration.base_path);
111 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
112
113 let mut query_params: Vec<(String, String)> = Vec::new();
115
116 if let Some(ref param_value) = params.start_time {
117 query_params.push(("startTime".to_string(), param_value.to_string()));
118 }
119 if let Some(ref param_value) = params.end_time {
120 query_params.push(("endTime".to_string(), param_value.to_string()));
121 }
122 if let Some(ref param_value) = params.limit {
123 query_params.push(("limit".to_string(), param_value.to_string()));
124 }
125 if let Some(ref param_value) = params.page {
126 query_params.push(("page".to_string(), param_value.to_string()));
127 }
128 if let Some(ref param_value) = params.recv_window {
129 query_params.push(("recvWindow".to_string(), param_value.to_string()));
130 }
131 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
132
133 let mut header_params = std::collections::HashMap::new();
135
136 if let Some(ref binance_auth) = configuration.binance_auth {
138 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
140
141 let body_string: Option<Vec<u8>> = None;
143
144 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
146 Ok(sig) => sig,
147 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
148 };
149
150 query_params.push(("signature".to_string(), signature));
152 }
153
154 if !query_params.is_empty() {
156 req_builder = req_builder.query(&query_params);
157 }
158
159
160 if let Some(ref user_agent) = configuration.user_agent {
162 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
163 }
164
165 for (header_name, header_value) in header_params {
167 req_builder = req_builder.header(&header_name, &header_value);
168 }
169
170
171 let req = req_builder.build()?;
172 let resp = configuration.client.execute(req).await?;
173
174 let status = resp.status();
175 let content_type = resp
176 .headers()
177 .get("content-type")
178 .and_then(|v| v.to_str().ok())
179 .unwrap_or("application/octet-stream");
180 let content_type = super::ContentType::from(content_type);
181
182 if !status.is_client_error() && !status.is_server_error() {
183 let content = resp.text().await?;
184 match content_type {
185 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
186 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetNftHistoryDepositV1Resp`"))),
187 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetNftHistoryDepositV1Resp`")))),
188 }
189 } else {
190 let content = resp.text().await?;
191 let entity: Option<GetNftHistoryDepositV1Error> = serde_json::from_str(&content).ok();
192 Err(Error::ResponseError(ResponseContent { status, content, entity }))
193 }
194}
195
196pub async fn get_nft_history_transactions_v1(configuration: &configuration::Configuration, params: GetNftHistoryTransactionsV1Params) -> Result<models::GetNftHistoryTransactionsV1Resp, Error<GetNftHistoryTransactionsV1Error>> {
198
199 let uri_str = format!("{}/sapi/v1/nft/history/transactions", configuration.base_path);
200 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
201
202 let mut query_params: Vec<(String, String)> = Vec::new();
204
205 query_params.push(("orderType".to_string(), params.order_type.to_string()));
206 if let Some(ref param_value) = params.start_time {
207 query_params.push(("startTime".to_string(), param_value.to_string()));
208 }
209 if let Some(ref param_value) = params.end_time {
210 query_params.push(("endTime".to_string(), param_value.to_string()));
211 }
212 if let Some(ref param_value) = params.limit {
213 query_params.push(("limit".to_string(), param_value.to_string()));
214 }
215 if let Some(ref param_value) = params.page {
216 query_params.push(("page".to_string(), param_value.to_string()));
217 }
218 if let Some(ref param_value) = params.recv_window {
219 query_params.push(("recvWindow".to_string(), param_value.to_string()));
220 }
221 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
222
223 let mut header_params = std::collections::HashMap::new();
225
226 if let Some(ref binance_auth) = configuration.binance_auth {
228 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
230
231 let body_string: Option<Vec<u8>> = None;
233
234 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
236 Ok(sig) => sig,
237 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
238 };
239
240 query_params.push(("signature".to_string(), signature));
242 }
243
244 if !query_params.is_empty() {
246 req_builder = req_builder.query(&query_params);
247 }
248
249
250 if let Some(ref user_agent) = configuration.user_agent {
252 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
253 }
254
255 for (header_name, header_value) in header_params {
257 req_builder = req_builder.header(&header_name, &header_value);
258 }
259
260
261 let req = req_builder.build()?;
262 let resp = configuration.client.execute(req).await?;
263
264 let status = resp.status();
265 let content_type = resp
266 .headers()
267 .get("content-type")
268 .and_then(|v| v.to_str().ok())
269 .unwrap_or("application/octet-stream");
270 let content_type = super::ContentType::from(content_type);
271
272 if !status.is_client_error() && !status.is_server_error() {
273 let content = resp.text().await?;
274 match content_type {
275 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
276 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetNftHistoryTransactionsV1Resp`"))),
277 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetNftHistoryTransactionsV1Resp`")))),
278 }
279 } else {
280 let content = resp.text().await?;
281 let entity: Option<GetNftHistoryTransactionsV1Error> = serde_json::from_str(&content).ok();
282 Err(Error::ResponseError(ResponseContent { status, content, entity }))
283 }
284}
285
286pub async fn get_nft_history_withdraw_v1(configuration: &configuration::Configuration, params: GetNftHistoryWithdrawV1Params) -> Result<models::GetNftHistoryWithdrawV1Resp, Error<GetNftHistoryWithdrawV1Error>> {
288
289 let uri_str = format!("{}/sapi/v1/nft/history/withdraw", configuration.base_path);
290 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
291
292 let mut query_params: Vec<(String, String)> = Vec::new();
294
295 if let Some(ref param_value) = params.start_time {
296 query_params.push(("startTime".to_string(), param_value.to_string()));
297 }
298 if let Some(ref param_value) = params.end_time {
299 query_params.push(("endTime".to_string(), param_value.to_string()));
300 }
301 if let Some(ref param_value) = params.limit {
302 query_params.push(("limit".to_string(), param_value.to_string()));
303 }
304 if let Some(ref param_value) = params.page {
305 query_params.push(("page".to_string(), param_value.to_string()));
306 }
307 if let Some(ref param_value) = params.recv_window {
308 query_params.push(("recvWindow".to_string(), param_value.to_string()));
309 }
310 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
311
312 let mut header_params = std::collections::HashMap::new();
314
315 if let Some(ref binance_auth) = configuration.binance_auth {
317 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
319
320 let body_string: Option<Vec<u8>> = None;
322
323 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
325 Ok(sig) => sig,
326 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
327 };
328
329 query_params.push(("signature".to_string(), signature));
331 }
332
333 if !query_params.is_empty() {
335 req_builder = req_builder.query(&query_params);
336 }
337
338
339 if let Some(ref user_agent) = configuration.user_agent {
341 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
342 }
343
344 for (header_name, header_value) in header_params {
346 req_builder = req_builder.header(&header_name, &header_value);
347 }
348
349
350 let req = req_builder.build()?;
351 let resp = configuration.client.execute(req).await?;
352
353 let status = resp.status();
354 let content_type = resp
355 .headers()
356 .get("content-type")
357 .and_then(|v| v.to_str().ok())
358 .unwrap_or("application/octet-stream");
359 let content_type = super::ContentType::from(content_type);
360
361 if !status.is_client_error() && !status.is_server_error() {
362 let content = resp.text().await?;
363 match content_type {
364 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
365 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetNftHistoryWithdrawV1Resp`"))),
366 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetNftHistoryWithdrawV1Resp`")))),
367 }
368 } else {
369 let content = resp.text().await?;
370 let entity: Option<GetNftHistoryWithdrawV1Error> = serde_json::from_str(&content).ok();
371 Err(Error::ResponseError(ResponseContent { status, content, entity }))
372 }
373}
374
375pub async fn get_nft_user_get_asset_v1(configuration: &configuration::Configuration, params: GetNftUserGetAssetV1Params) -> Result<models::GetNftUserGetAssetV1Resp, Error<GetNftUserGetAssetV1Error>> {
377
378 let uri_str = format!("{}/sapi/v1/nft/user/getAsset", configuration.base_path);
379 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
380
381 let mut query_params: Vec<(String, String)> = Vec::new();
383
384 if let Some(ref param_value) = params.limit {
385 query_params.push(("limit".to_string(), param_value.to_string()));
386 }
387 if let Some(ref param_value) = params.page {
388 query_params.push(("page".to_string(), param_value.to_string()));
389 }
390 if let Some(ref param_value) = params.recv_window {
391 query_params.push(("recvWindow".to_string(), param_value.to_string()));
392 }
393 query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
394
395 let mut header_params = std::collections::HashMap::new();
397
398 if let Some(ref binance_auth) = configuration.binance_auth {
400 header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
402
403 let body_string: Option<Vec<u8>> = None;
405
406 let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
408 Ok(sig) => sig,
409 Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
410 };
411
412 query_params.push(("signature".to_string(), signature));
414 }
415
416 if !query_params.is_empty() {
418 req_builder = req_builder.query(&query_params);
419 }
420
421
422 if let Some(ref user_agent) = configuration.user_agent {
424 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
425 }
426
427 for (header_name, header_value) in header_params {
429 req_builder = req_builder.header(&header_name, &header_value);
430 }
431
432
433 let req = req_builder.build()?;
434 let resp = configuration.client.execute(req).await?;
435
436 let status = resp.status();
437 let content_type = resp
438 .headers()
439 .get("content-type")
440 .and_then(|v| v.to_str().ok())
441 .unwrap_or("application/octet-stream");
442 let content_type = super::ContentType::from(content_type);
443
444 if !status.is_client_error() && !status.is_server_error() {
445 let content = resp.text().await?;
446 match content_type {
447 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
448 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetNftUserGetAssetV1Resp`"))),
449 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetNftUserGetAssetV1Resp`")))),
450 }
451 } else {
452 let content = resp.text().await?;
453 let entity: Option<GetNftUserGetAssetV1Error> = serde_json::from_str(&content).ok();
454 Err(Error::ResponseError(ResponseContent { status, content, entity }))
455 }
456}
457