use reqwest;
use serde::{Deserialize, Serialize, de::Error as _};
use crate::{apis::ResponseContent, models};
use super::{Error, configuration, ContentType};
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetAccountError {
Status400(models::seller_wallet_2024_03_01::ErrorList),
Status403(models::seller_wallet_2024_03_01::ErrorList),
Status404(models::seller_wallet_2024_03_01::ErrorList),
Status408(models::seller_wallet_2024_03_01::ErrorList),
Status413(models::seller_wallet_2024_03_01::ErrorList),
Status415(models::seller_wallet_2024_03_01::ErrorList),
Status429(models::seller_wallet_2024_03_01::ErrorList),
Status500(models::seller_wallet_2024_03_01::ErrorList),
Status503(models::seller_wallet_2024_03_01::ErrorList),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListAccountBalancesError {
Status400(models::seller_wallet_2024_03_01::ErrorList),
Status403(models::seller_wallet_2024_03_01::ErrorList),
Status404(models::seller_wallet_2024_03_01::ErrorList),
Status408(models::seller_wallet_2024_03_01::ErrorList),
Status413(models::seller_wallet_2024_03_01::ErrorList),
Status415(models::seller_wallet_2024_03_01::ErrorList),
Status429(models::seller_wallet_2024_03_01::ErrorList),
Status500(models::seller_wallet_2024_03_01::ErrorList),
Status503(models::seller_wallet_2024_03_01::ErrorList),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListAccountsError {
Status400(models::seller_wallet_2024_03_01::ErrorList),
Status403(models::seller_wallet_2024_03_01::ErrorList),
Status404(models::seller_wallet_2024_03_01::ErrorList),
Status408(models::seller_wallet_2024_03_01::ErrorList),
Status413(models::seller_wallet_2024_03_01::ErrorList),
Status415(models::seller_wallet_2024_03_01::ErrorList),
Status429(models::seller_wallet_2024_03_01::ErrorList),
Status500(models::seller_wallet_2024_03_01::ErrorList),
Status503(models::seller_wallet_2024_03_01::ErrorList),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateTransactionError {
Status400(models::seller_wallet_2024_03_01::ErrorList),
Status403(models::seller_wallet_2024_03_01::ErrorList),
Status404(models::seller_wallet_2024_03_01::ErrorList),
Status408(models::seller_wallet_2024_03_01::ErrorList),
Status413(models::seller_wallet_2024_03_01::ErrorList),
Status415(models::seller_wallet_2024_03_01::ErrorList),
Status422(models::seller_wallet_2024_03_01::ErrorList),
Status429(models::seller_wallet_2024_03_01::ErrorList),
Status500(models::seller_wallet_2024_03_01::ErrorList),
Status503(models::seller_wallet_2024_03_01::ErrorList),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetTransactionError {
Status400(models::seller_wallet_2024_03_01::ErrorList),
Status403(models::seller_wallet_2024_03_01::ErrorList),
Status404(models::seller_wallet_2024_03_01::ErrorList),
Status408(models::seller_wallet_2024_03_01::ErrorList),
Status413(models::seller_wallet_2024_03_01::ErrorList),
Status415(models::seller_wallet_2024_03_01::ErrorList),
Status429(models::seller_wallet_2024_03_01::ErrorList),
Status500(models::seller_wallet_2024_03_01::ErrorList),
Status503(models::seller_wallet_2024_03_01::ErrorList),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListAccountTransactionsError {
Status400(models::seller_wallet_2024_03_01::ErrorList),
Status403(models::seller_wallet_2024_03_01::ErrorList),
Status404(models::seller_wallet_2024_03_01::ErrorList),
Status408(models::seller_wallet_2024_03_01::ErrorList),
Status413(models::seller_wallet_2024_03_01::ErrorList),
Status415(models::seller_wallet_2024_03_01::ErrorList),
Status429(models::seller_wallet_2024_03_01::ErrorList),
Status500(models::seller_wallet_2024_03_01::ErrorList),
Status503(models::seller_wallet_2024_03_01::ErrorList),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetTransferPreviewError {
Status400(models::seller_wallet_2024_03_01::ErrorList),
Status403(models::seller_wallet_2024_03_01::ErrorList),
Status404(models::seller_wallet_2024_03_01::ErrorList),
Status408(models::seller_wallet_2024_03_01::ErrorList),
Status413(models::seller_wallet_2024_03_01::ErrorList),
Status415(models::seller_wallet_2024_03_01::ErrorList),
Status429(models::seller_wallet_2024_03_01::ErrorList),
Status500(models::seller_wallet_2024_03_01::ErrorList),
Status503(models::seller_wallet_2024_03_01::ErrorList),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateTransferScheduleError {
Status400(models::seller_wallet_2024_03_01::ErrorList),
Status403(models::seller_wallet_2024_03_01::ErrorList),
Status404(models::seller_wallet_2024_03_01::ErrorList),
Status408(models::seller_wallet_2024_03_01::ErrorList),
Status409(models::seller_wallet_2024_03_01::ErrorList),
Status413(models::seller_wallet_2024_03_01::ErrorList),
Status415(models::seller_wallet_2024_03_01::ErrorList),
Status429(models::seller_wallet_2024_03_01::ErrorList),
Status500(models::seller_wallet_2024_03_01::ErrorList),
Status503(models::seller_wallet_2024_03_01::ErrorList),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteScheduleTransactionError {
Status400(models::seller_wallet_2024_03_01::ErrorList),
Status403(models::seller_wallet_2024_03_01::ErrorList),
Status404(models::seller_wallet_2024_03_01::ErrorList),
Status408(models::seller_wallet_2024_03_01::ErrorList),
Status413(models::seller_wallet_2024_03_01::ErrorList),
Status415(models::seller_wallet_2024_03_01::ErrorList),
Status429(models::seller_wallet_2024_03_01::ErrorList),
Status500(models::seller_wallet_2024_03_01::ErrorList),
Status503(models::seller_wallet_2024_03_01::ErrorList),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetTransferScheduleError {
Status400(models::seller_wallet_2024_03_01::ErrorList),
Status403(models::seller_wallet_2024_03_01::ErrorList),
Status404(models::seller_wallet_2024_03_01::ErrorList),
Status408(models::seller_wallet_2024_03_01::ErrorList),
Status413(models::seller_wallet_2024_03_01::ErrorList),
Status415(models::seller_wallet_2024_03_01::ErrorList),
Status429(models::seller_wallet_2024_03_01::ErrorList),
Status500(models::seller_wallet_2024_03_01::ErrorList),
Status503(models::seller_wallet_2024_03_01::ErrorList),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListTransferSchedulesError {
Status400(models::seller_wallet_2024_03_01::ErrorList),
Status403(models::seller_wallet_2024_03_01::ErrorList),
Status404(models::seller_wallet_2024_03_01::ErrorList),
Status408(models::seller_wallet_2024_03_01::ErrorList),
Status413(models::seller_wallet_2024_03_01::ErrorList),
Status415(models::seller_wallet_2024_03_01::ErrorList),
Status429(models::seller_wallet_2024_03_01::ErrorList),
Status500(models::seller_wallet_2024_03_01::ErrorList),
Status503(models::seller_wallet_2024_03_01::ErrorList),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateTransferScheduleError {
Status400(models::seller_wallet_2024_03_01::ErrorList),
Status403(models::seller_wallet_2024_03_01::ErrorList),
Status404(models::seller_wallet_2024_03_01::ErrorList),
Status408(models::seller_wallet_2024_03_01::ErrorList),
Status413(models::seller_wallet_2024_03_01::ErrorList),
Status415(models::seller_wallet_2024_03_01::ErrorList),
Status429(models::seller_wallet_2024_03_01::ErrorList),
Status500(models::seller_wallet_2024_03_01::ErrorList),
Status503(models::seller_wallet_2024_03_01::ErrorList),
UnknownValue(serde_json::Value),
}
pub async fn get_account(configuration: &configuration::Configuration, account_id: &str) -> Result<models::seller_wallet_2024_03_01::BankAccount, Error<GetAccountError>> {
let p_account_id = account_id;
let uri_str = format!("{}/finances/transfers/wallet/2024-03-01/accounts/{accountId}", configuration.base_path, accountId=crate::apis::urlencode(p_account_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
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`"))),
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`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetAccountError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn list_account_balances(configuration: &configuration::Configuration, account_id: &str) -> Result<models::seller_wallet_2024_03_01::BalanceListing, Error<ListAccountBalancesError>> {
let p_account_id = account_id;
let uri_str = format!("{}/finances/transfers/wallet/2024-03-01/accounts/{accountId}/balance", configuration.base_path, accountId=crate::apis::urlencode(p_account_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
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`"))),
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`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListAccountBalancesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn list_accounts(configuration: &configuration::Configuration, marketplace_id: &str) -> Result<models::seller_wallet_2024_03_01::BankAccountListing, Error<ListAccountsError>> {
let p_marketplace_id = marketplace_id;
let uri_str = format!("{}/finances/transfers/wallet/2024-03-01/accounts", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("marketplaceId", &p_marketplace_id.to_string())]);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
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`"))),
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`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListAccountsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub 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>> {
let p_dest_account_digital_signature = dest_account_digital_signature;
let p_amount_digital_signature = amount_digital_signature;
let p_body = body;
let uri_str = format!("{}/finances/transfers/wallet/2024-03-01/transactions", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.header("destAccountDigitalSignature", p_dest_account_digital_signature.to_string());
req_builder = req_builder.header("amountDigitalSignature", p_amount_digital_signature.to_string());
req_builder = req_builder.json(&p_body);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
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`"))),
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`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateTransactionError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_transaction(configuration: &configuration::Configuration, transaction_id: &str) -> Result<models::seller_wallet_2024_03_01::Transaction, Error<GetTransactionError>> {
let p_transaction_id = transaction_id;
let uri_str = format!("{}/finances/transfers/wallet/2024-03-01/transactions/{transactionId}", configuration.base_path, transactionId=crate::apis::urlencode(p_transaction_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
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`"))),
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`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetTransactionError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub 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>> {
let p_account_id = account_id;
let p_next_page_token = next_page_token;
let uri_str = format!("{}/finances/transfers/wallet/2024-03-01/transactions", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("accountId", &p_account_id.to_string())]);
if let Some(ref param_value) = p_next_page_token {
req_builder = req_builder.query(&[("nextPageToken", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
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`"))),
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`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListAccountTransactionsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub 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>> {
let p_source_country_code = source_country_code;
let p_source_currency_code = source_currency_code;
let p_destination_country_code = destination_country_code;
let p_destination_currency_code = destination_currency_code;
let p_base_amount = base_amount;
let uri_str = format!("{}/finances/transfers/wallet/2024-03-01/transferPreview", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("sourceCountryCode", &p_source_country_code.to_string())]);
req_builder = req_builder.query(&[("sourceCurrencyCode", &p_source_currency_code.to_string())]);
req_builder = req_builder.query(&[("destinationCountryCode", &p_destination_country_code.to_string())]);
req_builder = req_builder.query(&[("destinationCurrencyCode", &p_destination_currency_code.to_string())]);
req_builder = req_builder.query(&[("baseAmount", &p_base_amount.to_string())]);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
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`"))),
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`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetTransferPreviewError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub 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>> {
let p_dest_account_digital_signature = dest_account_digital_signature;
let p_amount_digital_signature = amount_digital_signature;
let p_body = body;
let uri_str = format!("{}/finances/transfers/wallet/2024-03-01/transferSchedules", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.header("destAccountDigitalSignature", p_dest_account_digital_signature.to_string());
req_builder = req_builder.header("amountDigitalSignature", p_amount_digital_signature.to_string());
req_builder = req_builder.json(&p_body);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
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`"))),
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`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateTransferScheduleError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn delete_schedule_transaction(configuration: &configuration::Configuration, transfer_schedule_id: &str) -> Result<models::seller_wallet_2024_03_01::DeleteTransferSchedule, Error<DeleteScheduleTransactionError>> {
let p_transfer_schedule_id = transfer_schedule_id;
let uri_str = format!("{}/finances/transfers/wallet/2024-03-01/transferSchedules/{transferScheduleId}", configuration.base_path, transferScheduleId=crate::apis::urlencode(p_transfer_schedule_id));
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
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`"))),
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`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteScheduleTransactionError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_transfer_schedule(configuration: &configuration::Configuration, transfer_schedule_id: &str) -> Result<models::seller_wallet_2024_03_01::TransferSchedule, Error<GetTransferScheduleError>> {
let p_transfer_schedule_id = transfer_schedule_id;
let uri_str = format!("{}/finances/transfers/wallet/2024-03-01/transferSchedules/{transferScheduleId}", configuration.base_path, transferScheduleId=crate::apis::urlencode(p_transfer_schedule_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
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`"))),
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`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetTransferScheduleError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub 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>> {
let p_account_id = account_id;
let p_next_page_token = next_page_token;
let uri_str = format!("{}/finances/transfers/wallet/2024-03-01/transferSchedules", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("accountId", &p_account_id.to_string())]);
if let Some(ref param_value) = p_next_page_token {
req_builder = req_builder.query(&[("nextPageToken", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
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`"))),
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`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListTransferSchedulesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub 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>> {
let p_dest_account_digital_signature = dest_account_digital_signature;
let p_amount_digital_signature = amount_digital_signature;
let p_body = body;
let uri_str = format!("{}/finances/transfers/wallet/2024-03-01/transferSchedules", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.header("destAccountDigitalSignature", p_dest_account_digital_signature.to_string());
req_builder = req_builder.header("amountDigitalSignature", p_amount_digital_signature.to_string());
req_builder = req_builder.json(&p_body);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
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`"))),
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`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateTransferScheduleError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}