binance/spot/apis/
gift_card_api.rs

1/*
2 * Binance Spot API
3 *
4 * OpenAPI specification for Binance exchange - Spot API
5 *
6 * The version of the OpenAPI document: 0.3.0
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::spot::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17/// struct for passing parameters to the method [`create_giftcard_buy_code_v1`]
18#[derive(Clone, Debug, Default)]
19pub struct CreateGiftcardBuyCodeV1Params {
20    pub base_token: String,
21    pub base_token_amount: f64,
22    pub face_token: String,
23    pub timestamp: i64,
24    pub recv_window: Option<i64>
25}
26
27/// struct for passing parameters to the method [`create_giftcard_create_code_v1`]
28#[derive(Clone, Debug, Default)]
29pub struct CreateGiftcardCreateCodeV1Params {
30    pub amount: f64,
31    pub timestamp: i64,
32    pub token: String,
33    pub recv_window: Option<i64>
34}
35
36/// struct for passing parameters to the method [`create_giftcard_redeem_code_v1`]
37#[derive(Clone, Debug, Default)]
38pub struct CreateGiftcardRedeemCodeV1Params {
39    pub code: String,
40    pub timestamp: i64,
41    pub external_uid: Option<String>,
42    pub recv_window: Option<i64>
43}
44
45/// struct for passing parameters to the method [`get_giftcard_buy_code_token_limit_v1`]
46#[derive(Clone, Debug, Default)]
47pub struct GetGiftcardBuyCodeTokenLimitV1Params {
48    /// The token you want to pay, example: BUSD
49    pub base_token: String,
50    pub timestamp: i64,
51    pub recv_window: Option<i64>
52}
53
54/// struct for passing parameters to the method [`get_giftcard_cryptography_rsa_public_key_v1`]
55#[derive(Clone, Debug, Default)]
56pub struct GetGiftcardCryptographyRsaPublicKeyV1Params {
57    pub timestamp: i64,
58    pub recv_window: Option<i64>
59}
60
61/// struct for passing parameters to the method [`get_giftcard_verify_v1`]
62#[derive(Clone, Debug, Default)]
63pub struct GetGiftcardVerifyV1Params {
64    /// Enter the Gift Card Number
65    pub reference_no: String,
66    pub timestamp: i64,
67    pub recv_window: Option<i64>
68}
69
70
71/// struct for typed errors of method [`create_giftcard_buy_code_v1`]
72#[derive(Debug, Clone, Serialize, Deserialize)]
73#[serde(untagged)]
74pub enum CreateGiftcardBuyCodeV1Error {
75    Status4XX(models::ApiError),
76    Status5XX(models::ApiError),
77    UnknownValue(serde_json::Value),
78}
79
80/// struct for typed errors of method [`create_giftcard_create_code_v1`]
81#[derive(Debug, Clone, Serialize, Deserialize)]
82#[serde(untagged)]
83pub enum CreateGiftcardCreateCodeV1Error {
84    Status4XX(models::ApiError),
85    Status5XX(models::ApiError),
86    UnknownValue(serde_json::Value),
87}
88
89/// struct for typed errors of method [`create_giftcard_redeem_code_v1`]
90#[derive(Debug, Clone, Serialize, Deserialize)]
91#[serde(untagged)]
92pub enum CreateGiftcardRedeemCodeV1Error {
93    Status4XX(models::ApiError),
94    Status5XX(models::ApiError),
95    UnknownValue(serde_json::Value),
96}
97
98/// struct for typed errors of method [`get_giftcard_buy_code_token_limit_v1`]
99#[derive(Debug, Clone, Serialize, Deserialize)]
100#[serde(untagged)]
101pub enum GetGiftcardBuyCodeTokenLimitV1Error {
102    Status4XX(models::ApiError),
103    Status5XX(models::ApiError),
104    UnknownValue(serde_json::Value),
105}
106
107/// struct for typed errors of method [`get_giftcard_cryptography_rsa_public_key_v1`]
108#[derive(Debug, Clone, Serialize, Deserialize)]
109#[serde(untagged)]
110pub enum GetGiftcardCryptographyRsaPublicKeyV1Error {
111    Status4XX(models::ApiError),
112    Status5XX(models::ApiError),
113    UnknownValue(serde_json::Value),
114}
115
116/// struct for typed errors of method [`get_giftcard_verify_v1`]
117#[derive(Debug, Clone, Serialize, Deserialize)]
118#[serde(untagged)]
119pub enum GetGiftcardVerifyV1Error {
120    Status4XX(models::ApiError),
121    Status5XX(models::ApiError),
122    UnknownValue(serde_json::Value),
123}
124
125
126/// This API is for creating a dual-token ( stablecoin-denominated) Binance Gift Card. You may create a gift card using USDT as baseToken, that is redeemable to another designated token (faceToken). For example, you can create a fixed-value BTC gift card and pay with 100 USDT plus 1 USDT fee. This gift card can keep the value fixed at 100 USDT before redemption, and will be redeemable to BTC equivalent to 100 USDT upon redemption.   Once successfully created, the amount of baseToken (e.g. USDT) in the fixed-value gift card along with the fee would be deducted from your funding wallet.   To get started with, please make sure:  You have a Binance account You have passed KYB You have a sufficient balance(Gift Card amount and fee amount) in your Binance funding wallet You need Enable Withdrawals for the API Key which requests this endpoint.
127pub async fn create_giftcard_buy_code_v1(configuration: &configuration::Configuration, params: CreateGiftcardBuyCodeV1Params) -> Result<models::CreateGiftcardBuyCodeV1Resp, Error<CreateGiftcardBuyCodeV1Error>> {
128
129    let uri_str = format!("{}/sapi/v1/giftcard/buyCode", configuration.base_path);
130    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
131
132    // Create a mutable vector for query parameters
133    let mut query_params: Vec<(String, String)> = Vec::new();
134
135
136    // Create header parameters collection
137    let mut header_params = std::collections::HashMap::new();
138
139    // Handle Binance Auth first if configured
140    if let Some(ref binance_auth) = configuration.binance_auth {
141        // Add API key to headers
142        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
143        
144        // Generate request body for signing (if any)
145        let body_string: Option<Vec<u8>> = None;
146        
147        // Sign the request
148        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
149            Ok(sig) => sig,
150            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
151        };
152        
153        // Add signature to query params
154        query_params.push(("signature".to_string(), signature));
155    }
156
157    // Apply all query parameters
158    if !query_params.is_empty() {
159        req_builder = req_builder.query(&query_params);
160    }
161
162
163    // Add user agent if configured
164    if let Some(ref user_agent) = configuration.user_agent {
165        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
166    }
167
168    // Apply all header parameters
169    for (header_name, header_value) in header_params {
170        req_builder = req_builder.header(&header_name, &header_value);
171    }
172
173    let mut multipart_form_params = std::collections::HashMap::new();
174    multipart_form_params.insert("baseToken", params.base_token.to_string());
175    multipart_form_params.insert("baseTokenAmount", params.base_token_amount.to_string());
176    multipart_form_params.insert("faceToken", params.face_token.to_string());
177    if let Some(param_value) = params.recv_window {
178        multipart_form_params.insert("recvWindow", param_value.to_string());
179    }
180    multipart_form_params.insert("timestamp", params.timestamp.to_string());
181    req_builder = req_builder.form(&multipart_form_params);
182
183    let req = req_builder.build()?;
184    let resp = configuration.client.execute(req).await?;
185
186    let status = resp.status();
187    let content_type = resp
188        .headers()
189        .get("content-type")
190        .and_then(|v| v.to_str().ok())
191        .unwrap_or("application/octet-stream");
192    let content_type = super::ContentType::from(content_type);
193
194    if !status.is_client_error() && !status.is_server_error() {
195        let content = resp.text().await?;
196        match content_type {
197            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
198            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateGiftcardBuyCodeV1Resp`"))),
199            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::CreateGiftcardBuyCodeV1Resp`")))),
200        }
201    } else {
202        let content = resp.text().await?;
203        let entity: Option<CreateGiftcardBuyCodeV1Error> = serde_json::from_str(&content).ok();
204        Err(Error::ResponseError(ResponseContent { status, content, entity }))
205    }
206}
207
208/// This API is for creating a Binance Gift Card.
209pub async fn create_giftcard_create_code_v1(configuration: &configuration::Configuration, params: CreateGiftcardCreateCodeV1Params) -> Result<models::CreateGiftcardCreateCodeV1Resp, Error<CreateGiftcardCreateCodeV1Error>> {
210
211    let uri_str = format!("{}/sapi/v1/giftcard/createCode", configuration.base_path);
212    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
213
214    // Create a mutable vector for query parameters
215    let mut query_params: Vec<(String, String)> = Vec::new();
216
217
218    // Create header parameters collection
219    let mut header_params = std::collections::HashMap::new();
220
221    // Handle Binance Auth first if configured
222    if let Some(ref binance_auth) = configuration.binance_auth {
223        // Add API key to headers
224        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
225        
226        // Generate request body for signing (if any)
227        let body_string: Option<Vec<u8>> = None;
228        
229        // Sign the request
230        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
231            Ok(sig) => sig,
232            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
233        };
234        
235        // Add signature to query params
236        query_params.push(("signature".to_string(), signature));
237    }
238
239    // Apply all query parameters
240    if !query_params.is_empty() {
241        req_builder = req_builder.query(&query_params);
242    }
243
244
245    // Add user agent if configured
246    if let Some(ref user_agent) = configuration.user_agent {
247        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
248    }
249
250    // Apply all header parameters
251    for (header_name, header_value) in header_params {
252        req_builder = req_builder.header(&header_name, &header_value);
253    }
254
255    let mut multipart_form_params = std::collections::HashMap::new();
256    multipart_form_params.insert("amount", params.amount.to_string());
257    if let Some(param_value) = params.recv_window {
258        multipart_form_params.insert("recvWindow", param_value.to_string());
259    }
260    multipart_form_params.insert("timestamp", params.timestamp.to_string());
261    multipart_form_params.insert("token", params.token.to_string());
262    req_builder = req_builder.form(&multipart_form_params);
263
264    let req = req_builder.build()?;
265    let resp = configuration.client.execute(req).await?;
266
267    let status = resp.status();
268    let content_type = resp
269        .headers()
270        .get("content-type")
271        .and_then(|v| v.to_str().ok())
272        .unwrap_or("application/octet-stream");
273    let content_type = super::ContentType::from(content_type);
274
275    if !status.is_client_error() && !status.is_server_error() {
276        let content = resp.text().await?;
277        match content_type {
278            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
279            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateGiftcardCreateCodeV1Resp`"))),
280            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::CreateGiftcardCreateCodeV1Resp`")))),
281        }
282    } else {
283        let content = resp.text().await?;
284        let entity: Option<CreateGiftcardCreateCodeV1Error> = serde_json::from_str(&content).ok();
285        Err(Error::ResponseError(ResponseContent { status, content, entity }))
286    }
287}
288
289/// This API is for redeeming a Binance Gift Card Once redeemed, the coins will be deposited in your funding wallet.
290pub async fn create_giftcard_redeem_code_v1(configuration: &configuration::Configuration, params: CreateGiftcardRedeemCodeV1Params) -> Result<models::CreateGiftcardRedeemCodeV1Resp, Error<CreateGiftcardRedeemCodeV1Error>> {
291
292    let uri_str = format!("{}/sapi/v1/giftcard/redeemCode", configuration.base_path);
293    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
294
295    // Create a mutable vector for query parameters
296    let mut query_params: Vec<(String, String)> = Vec::new();
297
298
299    // Create header parameters collection
300    let mut header_params = std::collections::HashMap::new();
301
302    // Handle Binance Auth first if configured
303    if let Some(ref binance_auth) = configuration.binance_auth {
304        // Add API key to headers
305        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
306        
307        // Generate request body for signing (if any)
308        let body_string: Option<Vec<u8>> = None;
309        
310        // Sign the request
311        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
312            Ok(sig) => sig,
313            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
314        };
315        
316        // Add signature to query params
317        query_params.push(("signature".to_string(), signature));
318    }
319
320    // Apply all query parameters
321    if !query_params.is_empty() {
322        req_builder = req_builder.query(&query_params);
323    }
324
325
326    // Add user agent if configured
327    if let Some(ref user_agent) = configuration.user_agent {
328        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
329    }
330
331    // Apply all header parameters
332    for (header_name, header_value) in header_params {
333        req_builder = req_builder.header(&header_name, &header_value);
334    }
335
336    let mut multipart_form_params = std::collections::HashMap::new();
337    multipart_form_params.insert("code", params.code.to_string());
338    if let Some(param_value) = params.external_uid {
339        multipart_form_params.insert("externalUid", param_value.to_string());
340    }
341    if let Some(param_value) = params.recv_window {
342        multipart_form_params.insert("recvWindow", param_value.to_string());
343    }
344    multipart_form_params.insert("timestamp", params.timestamp.to_string());
345    req_builder = req_builder.form(&multipart_form_params);
346
347    let req = req_builder.build()?;
348    let resp = configuration.client.execute(req).await?;
349
350    let status = resp.status();
351    let content_type = resp
352        .headers()
353        .get("content-type")
354        .and_then(|v| v.to_str().ok())
355        .unwrap_or("application/octet-stream");
356    let content_type = super::ContentType::from(content_type);
357
358    if !status.is_client_error() && !status.is_server_error() {
359        let content = resp.text().await?;
360        match content_type {
361            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
362            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateGiftcardRedeemCodeV1Resp`"))),
363            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::CreateGiftcardRedeemCodeV1Resp`")))),
364        }
365    } else {
366        let content = resp.text().await?;
367        let entity: Option<CreateGiftcardRedeemCodeV1Error> = serde_json::from_str(&content).ok();
368        Err(Error::ResponseError(ResponseContent { status, content, entity }))
369    }
370}
371
372/// This API is to help you verify which tokens are available for you to create Stablecoin-Denominated gift cards as mentioned in section 2 and its’ limitation.
373pub async fn get_giftcard_buy_code_token_limit_v1(configuration: &configuration::Configuration, params: GetGiftcardBuyCodeTokenLimitV1Params) -> Result<models::GetGiftcardBuyCodeTokenLimitV1Resp, Error<GetGiftcardBuyCodeTokenLimitV1Error>> {
374
375    let uri_str = format!("{}/sapi/v1/giftcard/buyCode/token-limit", configuration.base_path);
376    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
377
378    // Create a mutable vector for query parameters
379    let mut query_params: Vec<(String, String)> = Vec::new();
380
381    query_params.push(("baseToken".to_string(), params.base_token.to_string()));
382    if let Some(ref param_value) = params.recv_window {
383        query_params.push(("recvWindow".to_string(), param_value.to_string()));
384    }
385    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
386
387    // Create header parameters collection
388    let mut header_params = std::collections::HashMap::new();
389
390    // Handle Binance Auth first if configured
391    if let Some(ref binance_auth) = configuration.binance_auth {
392        // Add API key to headers
393        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
394        
395        // Generate request body for signing (if any)
396        let body_string: Option<Vec<u8>> = None;
397        
398        // Sign the request
399        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
400            Ok(sig) => sig,
401            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
402        };
403        
404        // Add signature to query params
405        query_params.push(("signature".to_string(), signature));
406    }
407
408    // Apply all query parameters
409    if !query_params.is_empty() {
410        req_builder = req_builder.query(&query_params);
411    }
412
413
414    // Add user agent if configured
415    if let Some(ref user_agent) = configuration.user_agent {
416        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
417    }
418
419    // Apply all header parameters
420    for (header_name, header_value) in header_params {
421        req_builder = req_builder.header(&header_name, &header_value);
422    }
423
424
425    let req = req_builder.build()?;
426    let resp = configuration.client.execute(req).await?;
427
428    let status = resp.status();
429    let content_type = resp
430        .headers()
431        .get("content-type")
432        .and_then(|v| v.to_str().ok())
433        .unwrap_or("application/octet-stream");
434    let content_type = super::ContentType::from(content_type);
435
436    if !status.is_client_error() && !status.is_server_error() {
437        let content = resp.text().await?;
438        match content_type {
439            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
440            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetGiftcardBuyCodeTokenLimitV1Resp`"))),
441            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::GetGiftcardBuyCodeTokenLimitV1Resp`")))),
442        }
443    } else {
444        let content = resp.text().await?;
445        let entity: Option<GetGiftcardBuyCodeTokenLimitV1Error> = serde_json::from_str(&content).ok();
446        Err(Error::ResponseError(ResponseContent { status, content, entity }))
447    }
448}
449
450/// This API is for fetching the RSA Public Key. This RSA Public key will be used to encrypt the card code.
451pub async fn get_giftcard_cryptography_rsa_public_key_v1(configuration: &configuration::Configuration, params: GetGiftcardCryptographyRsaPublicKeyV1Params) -> Result<models::GetGiftcardCryptographyRsaPublicKeyV1Resp, Error<GetGiftcardCryptographyRsaPublicKeyV1Error>> {
452
453    let uri_str = format!("{}/sapi/v1/giftcard/cryptography/rsa-public-key", configuration.base_path);
454    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
455
456    // Create a mutable vector for query parameters
457    let mut query_params: Vec<(String, String)> = Vec::new();
458
459    if let Some(ref param_value) = params.recv_window {
460        query_params.push(("recvWindow".to_string(), param_value.to_string()));
461    }
462    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
463
464    // Create header parameters collection
465    let mut header_params = std::collections::HashMap::new();
466
467    // Handle Binance Auth first if configured
468    if let Some(ref binance_auth) = configuration.binance_auth {
469        // Add API key to headers
470        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
471        
472        // Generate request body for signing (if any)
473        let body_string: Option<Vec<u8>> = None;
474        
475        // Sign the request
476        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
477            Ok(sig) => sig,
478            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
479        };
480        
481        // Add signature to query params
482        query_params.push(("signature".to_string(), signature));
483    }
484
485    // Apply all query parameters
486    if !query_params.is_empty() {
487        req_builder = req_builder.query(&query_params);
488    }
489
490
491    // Add user agent if configured
492    if let Some(ref user_agent) = configuration.user_agent {
493        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
494    }
495
496    // Apply all header parameters
497    for (header_name, header_value) in header_params {
498        req_builder = req_builder.header(&header_name, &header_value);
499    }
500
501
502    let req = req_builder.build()?;
503    let resp = configuration.client.execute(req).await?;
504
505    let status = resp.status();
506    let content_type = resp
507        .headers()
508        .get("content-type")
509        .and_then(|v| v.to_str().ok())
510        .unwrap_or("application/octet-stream");
511    let content_type = super::ContentType::from(content_type);
512
513    if !status.is_client_error() && !status.is_server_error() {
514        let content = resp.text().await?;
515        match content_type {
516            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
517            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetGiftcardCryptographyRsaPublicKeyV1Resp`"))),
518            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::GetGiftcardCryptographyRsaPublicKeyV1Resp`")))),
519        }
520    } else {
521        let content = resp.text().await?;
522        let entity: Option<GetGiftcardCryptographyRsaPublicKeyV1Error> = serde_json::from_str(&content).ok();
523        Err(Error::ResponseError(ResponseContent { status, content, entity }))
524    }
525}
526
527/// This API is for verifying whether the Binance Gift Card is valid or not by entering Gift Card Number.
528pub async fn get_giftcard_verify_v1(configuration: &configuration::Configuration, params: GetGiftcardVerifyV1Params) -> Result<models::GetGiftcardVerifyV1Resp, Error<GetGiftcardVerifyV1Error>> {
529
530    let uri_str = format!("{}/sapi/v1/giftcard/verify", configuration.base_path);
531    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
532
533    // Create a mutable vector for query parameters
534    let mut query_params: Vec<(String, String)> = Vec::new();
535
536    query_params.push(("referenceNo".to_string(), params.reference_no.to_string()));
537    if let Some(ref param_value) = params.recv_window {
538        query_params.push(("recvWindow".to_string(), param_value.to_string()));
539    }
540    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
541
542    // Create header parameters collection
543    let mut header_params = std::collections::HashMap::new();
544
545    // Handle Binance Auth first if configured
546    if let Some(ref binance_auth) = configuration.binance_auth {
547        // Add API key to headers
548        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
549        
550        // Generate request body for signing (if any)
551        let body_string: Option<Vec<u8>> = None;
552        
553        // Sign the request
554        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
555            Ok(sig) => sig,
556            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
557        };
558        
559        // Add signature to query params
560        query_params.push(("signature".to_string(), signature));
561    }
562
563    // Apply all query parameters
564    if !query_params.is_empty() {
565        req_builder = req_builder.query(&query_params);
566    }
567
568
569    // Add user agent if configured
570    if let Some(ref user_agent) = configuration.user_agent {
571        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
572    }
573
574    // Apply all header parameters
575    for (header_name, header_value) in header_params {
576        req_builder = req_builder.header(&header_name, &header_value);
577    }
578
579
580    let req = req_builder.build()?;
581    let resp = configuration.client.execute(req).await?;
582
583    let status = resp.status();
584    let content_type = resp
585        .headers()
586        .get("content-type")
587        .and_then(|v| v.to_str().ok())
588        .unwrap_or("application/octet-stream");
589    let content_type = super::ContentType::from(content_type);
590
591    if !status.is_client_error() && !status.is_server_error() {
592        let content = resp.text().await?;
593        match content_type {
594            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
595            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetGiftcardVerifyV1Resp`"))),
596            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::GetGiftcardVerifyV1Resp`")))),
597        }
598    } else {
599        let content = resp.text().await?;
600        let entity: Option<GetGiftcardVerifyV1Error> = serde_json::from_str(&content).ok();
601        Err(Error::ResponseError(ResponseContent { status, content, entity }))
602    }
603}
604