amazon_spapi/apis/
seller_wallet_2024_03_01.rs

1/*
2 * The Selling Partner API for Amazon Seller Wallet Open Banking API
3 *
4 * The Selling Partner API for Seller Wallet (Seller Wallet API) provides financial information that is relevant to a seller's Seller Wallet account. You can obtain financial events, balances, and transfer schedules for Seller Wallet accounts. You can also schedule and initiate transactions.
5 *
6 * The version of the OpenAPI document: 2024-03-01
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18/// struct for typed errors of method [`get_account`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum GetAccountError {
22    Status400(models::seller_wallet_2024_03_01::ErrorList),
23    Status403(models::seller_wallet_2024_03_01::ErrorList),
24    Status404(models::seller_wallet_2024_03_01::ErrorList),
25    Status408(models::seller_wallet_2024_03_01::ErrorList),
26    Status413(models::seller_wallet_2024_03_01::ErrorList),
27    Status415(models::seller_wallet_2024_03_01::ErrorList),
28    Status429(models::seller_wallet_2024_03_01::ErrorList),
29    Status500(models::seller_wallet_2024_03_01::ErrorList),
30    Status503(models::seller_wallet_2024_03_01::ErrorList),
31    UnknownValue(serde_json::Value),
32}
33
34/// struct for typed errors of method [`list_account_balances`]
35#[derive(Debug, Clone, Serialize, Deserialize)]
36#[serde(untagged)]
37pub enum ListAccountBalancesError {
38    Status400(models::seller_wallet_2024_03_01::ErrorList),
39    Status403(models::seller_wallet_2024_03_01::ErrorList),
40    Status404(models::seller_wallet_2024_03_01::ErrorList),
41    Status408(models::seller_wallet_2024_03_01::ErrorList),
42    Status413(models::seller_wallet_2024_03_01::ErrorList),
43    Status415(models::seller_wallet_2024_03_01::ErrorList),
44    Status429(models::seller_wallet_2024_03_01::ErrorList),
45    Status500(models::seller_wallet_2024_03_01::ErrorList),
46    Status503(models::seller_wallet_2024_03_01::ErrorList),
47    UnknownValue(serde_json::Value),
48}
49
50/// struct for typed errors of method [`list_accounts`]
51#[derive(Debug, Clone, Serialize, Deserialize)]
52#[serde(untagged)]
53pub enum ListAccountsError {
54    Status400(models::seller_wallet_2024_03_01::ErrorList),
55    Status403(models::seller_wallet_2024_03_01::ErrorList),
56    Status404(models::seller_wallet_2024_03_01::ErrorList),
57    Status408(models::seller_wallet_2024_03_01::ErrorList),
58    Status413(models::seller_wallet_2024_03_01::ErrorList),
59    Status415(models::seller_wallet_2024_03_01::ErrorList),
60    Status429(models::seller_wallet_2024_03_01::ErrorList),
61    Status500(models::seller_wallet_2024_03_01::ErrorList),
62    Status503(models::seller_wallet_2024_03_01::ErrorList),
63    UnknownValue(serde_json::Value),
64}
65
66/// struct for typed errors of method [`create_transaction`]
67#[derive(Debug, Clone, Serialize, Deserialize)]
68#[serde(untagged)]
69pub enum CreateTransactionError {
70    Status400(models::seller_wallet_2024_03_01::ErrorList),
71    Status403(models::seller_wallet_2024_03_01::ErrorList),
72    Status404(models::seller_wallet_2024_03_01::ErrorList),
73    Status408(models::seller_wallet_2024_03_01::ErrorList),
74    Status413(models::seller_wallet_2024_03_01::ErrorList),
75    Status415(models::seller_wallet_2024_03_01::ErrorList),
76    Status422(models::seller_wallet_2024_03_01::ErrorList),
77    Status429(models::seller_wallet_2024_03_01::ErrorList),
78    Status500(models::seller_wallet_2024_03_01::ErrorList),
79    Status503(models::seller_wallet_2024_03_01::ErrorList),
80    UnknownValue(serde_json::Value),
81}
82
83/// struct for typed errors of method [`get_transaction`]
84#[derive(Debug, Clone, Serialize, Deserialize)]
85#[serde(untagged)]
86pub enum GetTransactionError {
87    Status400(models::seller_wallet_2024_03_01::ErrorList),
88    Status403(models::seller_wallet_2024_03_01::ErrorList),
89    Status404(models::seller_wallet_2024_03_01::ErrorList),
90    Status408(models::seller_wallet_2024_03_01::ErrorList),
91    Status413(models::seller_wallet_2024_03_01::ErrorList),
92    Status415(models::seller_wallet_2024_03_01::ErrorList),
93    Status429(models::seller_wallet_2024_03_01::ErrorList),
94    Status500(models::seller_wallet_2024_03_01::ErrorList),
95    Status503(models::seller_wallet_2024_03_01::ErrorList),
96    UnknownValue(serde_json::Value),
97}
98
99/// struct for typed errors of method [`list_account_transactions`]
100#[derive(Debug, Clone, Serialize, Deserialize)]
101#[serde(untagged)]
102pub enum ListAccountTransactionsError {
103    Status400(models::seller_wallet_2024_03_01::ErrorList),
104    Status403(models::seller_wallet_2024_03_01::ErrorList),
105    Status404(models::seller_wallet_2024_03_01::ErrorList),
106    Status408(models::seller_wallet_2024_03_01::ErrorList),
107    Status413(models::seller_wallet_2024_03_01::ErrorList),
108    Status415(models::seller_wallet_2024_03_01::ErrorList),
109    Status429(models::seller_wallet_2024_03_01::ErrorList),
110    Status500(models::seller_wallet_2024_03_01::ErrorList),
111    Status503(models::seller_wallet_2024_03_01::ErrorList),
112    UnknownValue(serde_json::Value),
113}
114
115/// struct for typed errors of method [`get_transfer_preview`]
116#[derive(Debug, Clone, Serialize, Deserialize)]
117#[serde(untagged)]
118pub enum GetTransferPreviewError {
119    Status400(models::seller_wallet_2024_03_01::ErrorList),
120    Status403(models::seller_wallet_2024_03_01::ErrorList),
121    Status404(models::seller_wallet_2024_03_01::ErrorList),
122    Status408(models::seller_wallet_2024_03_01::ErrorList),
123    Status413(models::seller_wallet_2024_03_01::ErrorList),
124    Status415(models::seller_wallet_2024_03_01::ErrorList),
125    Status429(models::seller_wallet_2024_03_01::ErrorList),
126    Status500(models::seller_wallet_2024_03_01::ErrorList),
127    Status503(models::seller_wallet_2024_03_01::ErrorList),
128    UnknownValue(serde_json::Value),
129}
130
131/// struct for typed errors of method [`create_transfer_schedule`]
132#[derive(Debug, Clone, Serialize, Deserialize)]
133#[serde(untagged)]
134pub enum CreateTransferScheduleError {
135    Status400(models::seller_wallet_2024_03_01::ErrorList),
136    Status403(models::seller_wallet_2024_03_01::ErrorList),
137    Status404(models::seller_wallet_2024_03_01::ErrorList),
138    Status408(models::seller_wallet_2024_03_01::ErrorList),
139    Status409(models::seller_wallet_2024_03_01::ErrorList),
140    Status413(models::seller_wallet_2024_03_01::ErrorList),
141    Status415(models::seller_wallet_2024_03_01::ErrorList),
142    Status429(models::seller_wallet_2024_03_01::ErrorList),
143    Status500(models::seller_wallet_2024_03_01::ErrorList),
144    Status503(models::seller_wallet_2024_03_01::ErrorList),
145    UnknownValue(serde_json::Value),
146}
147
148/// struct for typed errors of method [`delete_schedule_transaction`]
149#[derive(Debug, Clone, Serialize, Deserialize)]
150#[serde(untagged)]
151pub enum DeleteScheduleTransactionError {
152    Status400(models::seller_wallet_2024_03_01::ErrorList),
153    Status403(models::seller_wallet_2024_03_01::ErrorList),
154    Status404(models::seller_wallet_2024_03_01::ErrorList),
155    Status408(models::seller_wallet_2024_03_01::ErrorList),
156    Status413(models::seller_wallet_2024_03_01::ErrorList),
157    Status415(models::seller_wallet_2024_03_01::ErrorList),
158    Status429(models::seller_wallet_2024_03_01::ErrorList),
159    Status500(models::seller_wallet_2024_03_01::ErrorList),
160    Status503(models::seller_wallet_2024_03_01::ErrorList),
161    UnknownValue(serde_json::Value),
162}
163
164/// struct for typed errors of method [`get_transfer_schedule`]
165#[derive(Debug, Clone, Serialize, Deserialize)]
166#[serde(untagged)]
167pub enum GetTransferScheduleError {
168    Status400(models::seller_wallet_2024_03_01::ErrorList),
169    Status403(models::seller_wallet_2024_03_01::ErrorList),
170    Status404(models::seller_wallet_2024_03_01::ErrorList),
171    Status408(models::seller_wallet_2024_03_01::ErrorList),
172    Status413(models::seller_wallet_2024_03_01::ErrorList),
173    Status415(models::seller_wallet_2024_03_01::ErrorList),
174    Status429(models::seller_wallet_2024_03_01::ErrorList),
175    Status500(models::seller_wallet_2024_03_01::ErrorList),
176    Status503(models::seller_wallet_2024_03_01::ErrorList),
177    UnknownValue(serde_json::Value),
178}
179
180/// struct for typed errors of method [`list_transfer_schedules`]
181#[derive(Debug, Clone, Serialize, Deserialize)]
182#[serde(untagged)]
183pub enum ListTransferSchedulesError {
184    Status400(models::seller_wallet_2024_03_01::ErrorList),
185    Status403(models::seller_wallet_2024_03_01::ErrorList),
186    Status404(models::seller_wallet_2024_03_01::ErrorList),
187    Status408(models::seller_wallet_2024_03_01::ErrorList),
188    Status413(models::seller_wallet_2024_03_01::ErrorList),
189    Status415(models::seller_wallet_2024_03_01::ErrorList),
190    Status429(models::seller_wallet_2024_03_01::ErrorList),
191    Status500(models::seller_wallet_2024_03_01::ErrorList),
192    Status503(models::seller_wallet_2024_03_01::ErrorList),
193    UnknownValue(serde_json::Value),
194}
195
196/// struct for typed errors of method [`update_transfer_schedule`]
197#[derive(Debug, Clone, Serialize, Deserialize)]
198#[serde(untagged)]
199pub enum UpdateTransferScheduleError {
200    Status400(models::seller_wallet_2024_03_01::ErrorList),
201    Status403(models::seller_wallet_2024_03_01::ErrorList),
202    Status404(models::seller_wallet_2024_03_01::ErrorList),
203    Status408(models::seller_wallet_2024_03_01::ErrorList),
204    Status413(models::seller_wallet_2024_03_01::ErrorList),
205    Status415(models::seller_wallet_2024_03_01::ErrorList),
206    Status429(models::seller_wallet_2024_03_01::ErrorList),
207    Status500(models::seller_wallet_2024_03_01::ErrorList),
208    Status503(models::seller_wallet_2024_03_01::ErrorList),
209    UnknownValue(serde_json::Value),
210}
211
212/// Retrieve a Seller Wallet bank account by Amazon account identifier.
213pub async fn get_account(configuration: &configuration::Configuration, account_id: &str) -> Result<models::seller_wallet_2024_03_01::BankAccount, Error<GetAccountError>> {
214    // add a prefix to parameters to efficiently prevent name collisions
215    let p_account_id = account_id;
216
217    let uri_str = format!("{}/finances/transfers/wallet/2024-03-01/accounts/{accountId}", configuration.base_path, accountId=crate::apis::urlencode(p_account_id));
218    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
219
220    if let Some(ref user_agent) = configuration.user_agent {
221        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
222    }
223
224    let req = req_builder.build()?;
225    let resp = configuration.client.execute(req).await?;
226
227    let status = resp.status();
228    let content_type = resp
229        .headers()
230        .get("content-type")
231        .and_then(|v| v.to_str().ok())
232        .unwrap_or("application/octet-stream");
233    let content_type = super::ContentType::from(content_type);
234
235    if !status.is_client_error() && !status.is_server_error() {
236        let content = resp.text().await?;
237        match content_type {
238            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
239            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::seller_wallet_2024_03_01::BankAccount`"))),
240            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::seller_wallet_2024_03_01::BankAccount`")))),
241        }
242    } else {
243        let content = resp.text().await?;
244        let entity: Option<GetAccountError> = serde_json::from_str(&content).ok();
245        Err(Error::ResponseError(ResponseContent { status, content, entity }))
246    }
247}
248
249/// Retrieve the balance in a given Seller Wallet bank account.
250pub async fn list_account_balances(configuration: &configuration::Configuration, account_id: &str) -> Result<models::seller_wallet_2024_03_01::BalanceListing, Error<ListAccountBalancesError>> {
251    // add a prefix to parameters to efficiently prevent name collisions
252    let p_account_id = account_id;
253
254    let uri_str = format!("{}/finances/transfers/wallet/2024-03-01/accounts/{accountId}/balance", configuration.base_path, accountId=crate::apis::urlencode(p_account_id));
255    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
256
257    if let Some(ref user_agent) = configuration.user_agent {
258        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
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::seller_wallet_2024_03_01::BalanceListing`"))),
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::seller_wallet_2024_03_01::BalanceListing`")))),
278        }
279    } else {
280        let content = resp.text().await?;
281        let entity: Option<ListAccountBalancesError> = serde_json::from_str(&content).ok();
282        Err(Error::ResponseError(ResponseContent { status, content, entity }))
283    }
284}
285
286/// Get Seller Wallet accounts for a seller.
287pub async fn list_accounts(configuration: &configuration::Configuration, marketplace_id: &str) -> Result<models::seller_wallet_2024_03_01::BankAccountListing, Error<ListAccountsError>> {
288    // add a prefix to parameters to efficiently prevent name collisions
289    let p_marketplace_id = marketplace_id;
290
291    let uri_str = format!("{}/finances/transfers/wallet/2024-03-01/accounts", configuration.base_path);
292    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
293
294    req_builder = req_builder.query(&[("marketplaceId", &p_marketplace_id.to_string())]);
295    if let Some(ref user_agent) = configuration.user_agent {
296        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
297    }
298
299    let req = req_builder.build()?;
300    let resp = configuration.client.execute(req).await?;
301
302    let status = resp.status();
303    let content_type = resp
304        .headers()
305        .get("content-type")
306        .and_then(|v| v.to_str().ok())
307        .unwrap_or("application/octet-stream");
308    let content_type = super::ContentType::from(content_type);
309
310    if !status.is_client_error() && !status.is_server_error() {
311        let content = resp.text().await?;
312        match content_type {
313            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
314            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::seller_wallet_2024_03_01::BankAccountListing`"))),
315            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::seller_wallet_2024_03_01::BankAccountListing`")))),
316        }
317    } else {
318        let content = resp.text().await?;
319        let entity: Option<ListAccountsError> = serde_json::from_str(&content).ok();
320        Err(Error::ResponseError(ResponseContent { status, content, entity }))
321    }
322}
323
324/// Create a transaction request from a Seller Wallet account to another customer-provided account.
325pub async fn create_transaction(configuration: &configuration::Configuration, dest_account_digital_signature: &str, amount_digital_signature: &str, body: models::seller_wallet_2024_03_01::TransactionInitiationRequest) -> Result<models::seller_wallet_2024_03_01::Transaction, Error<CreateTransactionError>> {
326    // add a prefix to parameters to efficiently prevent name collisions
327    let p_dest_account_digital_signature = dest_account_digital_signature;
328    let p_amount_digital_signature = amount_digital_signature;
329    let p_body = body;
330
331    let uri_str = format!("{}/finances/transfers/wallet/2024-03-01/transactions", configuration.base_path);
332    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
333
334    if let Some(ref user_agent) = configuration.user_agent {
335        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
336    }
337    req_builder = req_builder.header("destAccountDigitalSignature", p_dest_account_digital_signature.to_string());
338    req_builder = req_builder.header("amountDigitalSignature", p_amount_digital_signature.to_string());
339    req_builder = req_builder.json(&p_body);
340
341    let req = req_builder.build()?;
342    let resp = configuration.client.execute(req).await?;
343
344    let status = resp.status();
345    let content_type = resp
346        .headers()
347        .get("content-type")
348        .and_then(|v| v.to_str().ok())
349        .unwrap_or("application/octet-stream");
350    let content_type = super::ContentType::from(content_type);
351
352    if !status.is_client_error() && !status.is_server_error() {
353        let content = resp.text().await?;
354        match content_type {
355            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
356            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::seller_wallet_2024_03_01::Transaction`"))),
357            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::seller_wallet_2024_03_01::Transaction`")))),
358        }
359    } else {
360        let content = resp.text().await?;
361        let entity: Option<CreateTransactionError> = serde_json::from_str(&content).ok();
362        Err(Error::ResponseError(ResponseContent { status, content, entity }))
363    }
364}
365
366/// Returns a transaction
367pub async fn get_transaction(configuration: &configuration::Configuration, transaction_id: &str) -> Result<models::seller_wallet_2024_03_01::Transaction, Error<GetTransactionError>> {
368    // add a prefix to parameters to efficiently prevent name collisions
369    let p_transaction_id = transaction_id;
370
371    let uri_str = format!("{}/finances/transfers/wallet/2024-03-01/transactions/{transactionId}", configuration.base_path, transactionId=crate::apis::urlencode(p_transaction_id));
372    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
373
374    if let Some(ref user_agent) = configuration.user_agent {
375        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
376    }
377
378    let req = req_builder.build()?;
379    let resp = configuration.client.execute(req).await?;
380
381    let status = resp.status();
382    let content_type = resp
383        .headers()
384        .get("content-type")
385        .and_then(|v| v.to_str().ok())
386        .unwrap_or("application/octet-stream");
387    let content_type = super::ContentType::from(content_type);
388
389    if !status.is_client_error() && !status.is_server_error() {
390        let content = resp.text().await?;
391        match content_type {
392            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
393            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::seller_wallet_2024_03_01::Transaction`"))),
394            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::seller_wallet_2024_03_01::Transaction`")))),
395        }
396    } else {
397        let content = resp.text().await?;
398        let entity: Option<GetTransactionError> = serde_json::from_str(&content).ok();
399        Err(Error::ResponseError(ResponseContent { status, content, entity }))
400    }
401}
402
403/// Retrieve a list of transactions for a given Seller Wallet bank account.
404pub async fn list_account_transactions(configuration: &configuration::Configuration, account_id: &str, next_page_token: Option<&str>) -> Result<models::seller_wallet_2024_03_01::TransactionListing, Error<ListAccountTransactionsError>> {
405    // add a prefix to parameters to efficiently prevent name collisions
406    let p_account_id = account_id;
407    let p_next_page_token = next_page_token;
408
409    let uri_str = format!("{}/finances/transfers/wallet/2024-03-01/transactions", configuration.base_path);
410    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
411
412    req_builder = req_builder.query(&[("accountId", &p_account_id.to_string())]);
413    if let Some(ref param_value) = p_next_page_token {
414        req_builder = req_builder.query(&[("nextPageToken", &param_value.to_string())]);
415    }
416    if let Some(ref user_agent) = configuration.user_agent {
417        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
418    }
419
420    let req = req_builder.build()?;
421    let resp = configuration.client.execute(req).await?;
422
423    let status = resp.status();
424    let content_type = resp
425        .headers()
426        .get("content-type")
427        .and_then(|v| v.to_str().ok())
428        .unwrap_or("application/octet-stream");
429    let content_type = super::ContentType::from(content_type);
430
431    if !status.is_client_error() && !status.is_server_error() {
432        let content = resp.text().await?;
433        match content_type {
434            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
435            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::seller_wallet_2024_03_01::TransactionListing`"))),
436            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::seller_wallet_2024_03_01::TransactionListing`")))),
437        }
438    } else {
439        let content = resp.text().await?;
440        let entity: Option<ListAccountTransactionsError> = serde_json::from_str(&content).ok();
441        Err(Error::ResponseError(ResponseContent { status, content, entity }))
442    }
443}
444
445/// Returns list of potential fees on a transaction based on the source and destination country currency code
446pub async fn get_transfer_preview(configuration: &configuration::Configuration, source_country_code: &str, source_currency_code: &str, destination_country_code: &str, destination_currency_code: &str, base_amount: f64) -> Result<models::seller_wallet_2024_03_01::TransferRatePreview, Error<GetTransferPreviewError>> {
447    // add a prefix to parameters to efficiently prevent name collisions
448    let p_source_country_code = source_country_code;
449    let p_source_currency_code = source_currency_code;
450    let p_destination_country_code = destination_country_code;
451    let p_destination_currency_code = destination_currency_code;
452    let p_base_amount = base_amount;
453
454    let uri_str = format!("{}/finances/transfers/wallet/2024-03-01/transferPreview", configuration.base_path);
455    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
456
457    req_builder = req_builder.query(&[("sourceCountryCode", &p_source_country_code.to_string())]);
458    req_builder = req_builder.query(&[("sourceCurrencyCode", &p_source_currency_code.to_string())]);
459    req_builder = req_builder.query(&[("destinationCountryCode", &p_destination_country_code.to_string())]);
460    req_builder = req_builder.query(&[("destinationCurrencyCode", &p_destination_currency_code.to_string())]);
461    req_builder = req_builder.query(&[("baseAmount", &p_base_amount.to_string())]);
462    if let Some(ref user_agent) = configuration.user_agent {
463        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
464    }
465
466    let req = req_builder.build()?;
467    let resp = configuration.client.execute(req).await?;
468
469    let status = resp.status();
470    let content_type = resp
471        .headers()
472        .get("content-type")
473        .and_then(|v| v.to_str().ok())
474        .unwrap_or("application/octet-stream");
475    let content_type = super::ContentType::from(content_type);
476
477    if !status.is_client_error() && !status.is_server_error() {
478        let content = resp.text().await?;
479        match content_type {
480            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
481            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::seller_wallet_2024_03_01::TransferRatePreview`"))),
482            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::seller_wallet_2024_03_01::TransferRatePreview`")))),
483        }
484    } else {
485        let content = resp.text().await?;
486        let entity: Option<GetTransferPreviewError> = serde_json::from_str(&content).ok();
487        Err(Error::ResponseError(ResponseContent { status, content, entity }))
488    }
489}
490
491/// Create a transfer schedule request from a Seller Wallet account to another customer-provided account.
492pub async fn create_transfer_schedule(configuration: &configuration::Configuration, dest_account_digital_signature: &str, amount_digital_signature: &str, body: models::seller_wallet_2024_03_01::TransferScheduleRequest) -> Result<models::seller_wallet_2024_03_01::TransferSchedule, Error<CreateTransferScheduleError>> {
493    // add a prefix to parameters to efficiently prevent name collisions
494    let p_dest_account_digital_signature = dest_account_digital_signature;
495    let p_amount_digital_signature = amount_digital_signature;
496    let p_body = body;
497
498    let uri_str = format!("{}/finances/transfers/wallet/2024-03-01/transferSchedules", configuration.base_path);
499    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
500
501    if let Some(ref user_agent) = configuration.user_agent {
502        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
503    }
504    req_builder = req_builder.header("destAccountDigitalSignature", p_dest_account_digital_signature.to_string());
505    req_builder = req_builder.header("amountDigitalSignature", p_amount_digital_signature.to_string());
506    req_builder = req_builder.json(&p_body);
507
508    let req = req_builder.build()?;
509    let resp = configuration.client.execute(req).await?;
510
511    let status = resp.status();
512    let content_type = resp
513        .headers()
514        .get("content-type")
515        .and_then(|v| v.to_str().ok())
516        .unwrap_or("application/octet-stream");
517    let content_type = super::ContentType::from(content_type);
518
519    if !status.is_client_error() && !status.is_server_error() {
520        let content = resp.text().await?;
521        match content_type {
522            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
523            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::seller_wallet_2024_03_01::TransferSchedule`"))),
524            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::seller_wallet_2024_03_01::TransferSchedule`")))),
525        }
526    } else {
527        let content = resp.text().await?;
528        let entity: Option<CreateTransferScheduleError> = serde_json::from_str(&content).ok();
529        Err(Error::ResponseError(ResponseContent { status, content, entity }))
530    }
531}
532
533/// Delete a transaction request that is scheduled from a Seller Wallet account to another customer-provided account.
534pub async fn delete_schedule_transaction(configuration: &configuration::Configuration, transfer_schedule_id: &str) -> Result<models::seller_wallet_2024_03_01::DeleteTransferSchedule, Error<DeleteScheduleTransactionError>> {
535    // add a prefix to parameters to efficiently prevent name collisions
536    let p_transfer_schedule_id = transfer_schedule_id;
537
538    let uri_str = format!("{}/finances/transfers/wallet/2024-03-01/transferSchedules/{transferScheduleId}", configuration.base_path, transferScheduleId=crate::apis::urlencode(p_transfer_schedule_id));
539    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
540
541    if let Some(ref user_agent) = configuration.user_agent {
542        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
543    }
544
545    let req = req_builder.build()?;
546    let resp = configuration.client.execute(req).await?;
547
548    let status = resp.status();
549    let content_type = resp
550        .headers()
551        .get("content-type")
552        .and_then(|v| v.to_str().ok())
553        .unwrap_or("application/octet-stream");
554    let content_type = super::ContentType::from(content_type);
555
556    if !status.is_client_error() && !status.is_server_error() {
557        let content = resp.text().await?;
558        match content_type {
559            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
560            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::seller_wallet_2024_03_01::DeleteTransferSchedule`"))),
561            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::seller_wallet_2024_03_01::DeleteTransferSchedule`")))),
562        }
563    } else {
564        let content = resp.text().await?;
565        let entity: Option<DeleteScheduleTransactionError> = serde_json::from_str(&content).ok();
566        Err(Error::ResponseError(ResponseContent { status, content, entity }))
567    }
568}
569
570/// Find a particular Seller Wallet account transfer schedule.
571pub async fn get_transfer_schedule(configuration: &configuration::Configuration, transfer_schedule_id: &str) -> Result<models::seller_wallet_2024_03_01::TransferSchedule, Error<GetTransferScheduleError>> {
572    // add a prefix to parameters to efficiently prevent name collisions
573    let p_transfer_schedule_id = transfer_schedule_id;
574
575    let uri_str = format!("{}/finances/transfers/wallet/2024-03-01/transferSchedules/{transferScheduleId}", configuration.base_path, transferScheduleId=crate::apis::urlencode(p_transfer_schedule_id));
576    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
577
578    if let Some(ref user_agent) = configuration.user_agent {
579        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
580    }
581
582    let req = req_builder.build()?;
583    let resp = configuration.client.execute(req).await?;
584
585    let status = resp.status();
586    let content_type = resp
587        .headers()
588        .get("content-type")
589        .and_then(|v| v.to_str().ok())
590        .unwrap_or("application/octet-stream");
591    let content_type = super::ContentType::from(content_type);
592
593    if !status.is_client_error() && !status.is_server_error() {
594        let content = resp.text().await?;
595        match content_type {
596            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
597            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::seller_wallet_2024_03_01::TransferSchedule`"))),
598            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::seller_wallet_2024_03_01::TransferSchedule`")))),
599        }
600    } else {
601        let content = resp.text().await?;
602        let entity: Option<GetTransferScheduleError> = serde_json::from_str(&content).ok();
603        Err(Error::ResponseError(ResponseContent { status, content, entity }))
604    }
605}
606
607/// Retrieve transfer schedules of a Seller Wallet bank account.
608pub async fn list_transfer_schedules(configuration: &configuration::Configuration, account_id: &str, next_page_token: Option<&str>) -> Result<models::seller_wallet_2024_03_01::TransferScheduleListing, Error<ListTransferSchedulesError>> {
609    // add a prefix to parameters to efficiently prevent name collisions
610    let p_account_id = account_id;
611    let p_next_page_token = next_page_token;
612
613    let uri_str = format!("{}/finances/transfers/wallet/2024-03-01/transferSchedules", configuration.base_path);
614    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
615
616    req_builder = req_builder.query(&[("accountId", &p_account_id.to_string())]);
617    if let Some(ref param_value) = p_next_page_token {
618        req_builder = req_builder.query(&[("nextPageToken", &param_value.to_string())]);
619    }
620    if let Some(ref user_agent) = configuration.user_agent {
621        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
622    }
623
624    let req = req_builder.build()?;
625    let resp = configuration.client.execute(req).await?;
626
627    let status = resp.status();
628    let content_type = resp
629        .headers()
630        .get("content-type")
631        .and_then(|v| v.to_str().ok())
632        .unwrap_or("application/octet-stream");
633    let content_type = super::ContentType::from(content_type);
634
635    if !status.is_client_error() && !status.is_server_error() {
636        let content = resp.text().await?;
637        match content_type {
638            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
639            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::seller_wallet_2024_03_01::TransferScheduleListing`"))),
640            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::seller_wallet_2024_03_01::TransferScheduleListing`")))),
641        }
642    } else {
643        let content = resp.text().await?;
644        let entity: Option<ListTransferSchedulesError> = serde_json::from_str(&content).ok();
645        Err(Error::ResponseError(ResponseContent { status, content, entity }))
646    }
647}
648
649/// Returns a transfer belonging to the updated scheduled transfer request
650pub async fn update_transfer_schedule(configuration: &configuration::Configuration, dest_account_digital_signature: &str, amount_digital_signature: &str, body: models::seller_wallet_2024_03_01::TransferSchedule) -> Result<models::seller_wallet_2024_03_01::TransferSchedule, Error<UpdateTransferScheduleError>> {
651    // add a prefix to parameters to efficiently prevent name collisions
652    let p_dest_account_digital_signature = dest_account_digital_signature;
653    let p_amount_digital_signature = amount_digital_signature;
654    let p_body = body;
655
656    let uri_str = format!("{}/finances/transfers/wallet/2024-03-01/transferSchedules", configuration.base_path);
657    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
658
659    if let Some(ref user_agent) = configuration.user_agent {
660        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
661    }
662    req_builder = req_builder.header("destAccountDigitalSignature", p_dest_account_digital_signature.to_string());
663    req_builder = req_builder.header("amountDigitalSignature", p_amount_digital_signature.to_string());
664    req_builder = req_builder.json(&p_body);
665
666    let req = req_builder.build()?;
667    let resp = configuration.client.execute(req).await?;
668
669    let status = resp.status();
670    let content_type = resp
671        .headers()
672        .get("content-type")
673        .and_then(|v| v.to_str().ok())
674        .unwrap_or("application/octet-stream");
675    let content_type = super::ContentType::from(content_type);
676
677    if !status.is_client_error() && !status.is_server_error() {
678        let content = resp.text().await?;
679        match content_type {
680            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
681            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::seller_wallet_2024_03_01::TransferSchedule`"))),
682            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::seller_wallet_2024_03_01::TransferSchedule`")))),
683        }
684    } else {
685        let content = resp.text().await?;
686        let entity: Option<UpdateTransferScheduleError> = serde_json::from_str(&content).ok();
687        Err(Error::ResponseError(ResponseContent { status, content, entity }))
688    }
689}