use reqwest;
use crate::apis::ResponseContent;
use super::{Error, configuration};
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetLatestMinedXrpRippleBlockError {
Status400(crate::models::InvalidPagination),
Status401(crate::models::InvalidApiKey),
Status402(crate::models::InsufficientCredits),
Status403(crate::models::FeatureMainnetsNotAllowedForPlan),
Status404(crate::models::ResourceNotFound),
Status409(crate::models::InvalidData),
Status415(crate::models::UnsupportedMediaType),
Status422(crate::models::InvalidRequestBodyStructure),
Status429(crate::models::RequestLimitReached),
Status500(crate::models::UnexpectedServerError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetXrpRippleAddressDetailsError {
Status400(crate::models::InvalidPagination),
Status401(crate::models::InvalidApiKey),
Status402(crate::models::InsufficientCredits),
Status403(crate::models::FeatureMainnetsNotAllowedForPlan),
Status409(crate::models::InvalidData),
Status415(crate::models::UnsupportedMediaType),
Status422(crate::models::InvalidRequestBodyStructure),
Status429(crate::models::RequestLimitReached),
Status500(crate::models::UnexpectedServerError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetXrpRippleBlockDetailsByBlockHashError {
Status400(crate::models::InvalidPagination),
Status401(crate::models::InvalidApiKey),
Status402(crate::models::InsufficientCredits),
Status403(crate::models::FeatureMainnetsNotAllowedForPlan),
Status404(crate::models::ResourceNotFound),
Status409(crate::models::InvalidData),
Status415(crate::models::UnsupportedMediaType),
Status422(crate::models::InvalidRequestBodyStructure),
Status429(crate::models::RequestLimitReached),
Status500(crate::models::UnexpectedServerError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetXrpRippleBlockDetailsByBlockHeightError {
Status400(crate::models::InvalidPagination),
Status401(crate::models::InvalidApiKey),
Status402(crate::models::InsufficientCredits),
Status403(crate::models::FeatureMainnetsNotAllowedForPlan),
Status404(crate::models::ResourceNotFound),
Status409(crate::models::InvalidData),
Status415(crate::models::UnsupportedMediaType),
Status422(crate::models::InvalidRequestBodyStructure),
Status429(crate::models::RequestLimitReached),
Status500(crate::models::UnexpectedServerError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetXrpRippleTransactionDetailsByTransactionIdError {
Status400(crate::models::InvalidPagination),
Status401(crate::models::InvalidApiKey),
Status402(crate::models::InsufficientCredits),
Status403(crate::models::FeatureMainnetsNotAllowedForPlan),
Status404(crate::models::ResourceNotFound),
Status409(crate::models::InvalidData),
Status415(crate::models::UnsupportedMediaType),
Status422(crate::models::InvalidRequestBodyStructure),
Status429(crate::models::RequestLimitReached),
Status500(crate::models::UnexpectedServerError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListXrpRippleTransactionsByAddressError {
Status400(crate::models::InvalidPagination),
Status401(crate::models::InvalidApiKey),
Status402(crate::models::InsufficientCredits),
Status403(crate::models::FeatureMainnetsNotAllowedForPlan),
Status409(crate::models::InvalidData),
Status415(crate::models::UnsupportedMediaType),
Status422(crate::models::InvalidRequestBodyStructure),
Status429(crate::models::RequestLimitReached),
Status500(crate::models::UnexpectedServerError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListXrpRippleTransactionsByBlockHashError {
Status400(crate::models::InvalidPagination),
Status401(crate::models::InvalidApiKey),
Status402(crate::models::InsufficientCredits),
Status403(crate::models::FeatureMainnetsNotAllowedForPlan),
Status409(crate::models::InvalidData),
Status415(crate::models::UnsupportedMediaType),
Status422(crate::models::InvalidRequestBodyStructure),
Status429(crate::models::RequestLimitReached),
Status500(crate::models::UnexpectedServerError),
UnknownValue(serde_json::Value),
}
pub async fn get_latest_mined_xrp__ripple_block(configuration: &configuration::Configuration, network: &str, context: Option<&str>) -> Result<crate::models::GetLatestMinedXrpRippleBlockResponse, Error<GetLatestMinedXrpRippleBlockError>> {
let local_var_client = &configuration.client;
let local_var_uri_str = format!("{}/blockchain-data/xrp/{network}/blocks/last", configuration.base_path, network=crate::apis::urlencode(network));
let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
if let Some(ref local_var_str) = context {
local_var_req_builder = local_var_req_builder.query(&[("context", &local_var_str.to_string())]);
}
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_apikey) = configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value);
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<GetLatestMinedXrpRippleBlockError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
pub async fn get_xrp__ripple_address_details(configuration: &configuration::Configuration, network: &str, address: &str, context: Option<&str>) -> Result<crate::models::GetXrpRippleAddressDetailsResponse, Error<GetXrpRippleAddressDetailsError>> {
let local_var_client = &configuration.client;
let local_var_uri_str = format!("{}/blockchain-data/xrp/{network}/addresses/{address}", configuration.base_path, network=crate::apis::urlencode(network), address=crate::apis::urlencode(address));
let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
if let Some(ref local_var_str) = context {
local_var_req_builder = local_var_req_builder.query(&[("context", &local_var_str.to_string())]);
}
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_apikey) = configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value);
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<GetXrpRippleAddressDetailsError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
pub async fn get_xrp__ripple_block_details_by_block_hash(configuration: &configuration::Configuration, network: &str, block_hash: &str, context: Option<&str>) -> Result<crate::models::GetXrpRippleBlockDetailsByBlockHashResponse, Error<GetXrpRippleBlockDetailsByBlockHashError>> {
let local_var_client = &configuration.client;
let local_var_uri_str = format!("{}/blockchain-data/xrp/{network}/blocks/hash/{blockHash}", configuration.base_path, network=crate::apis::urlencode(network), blockHash=crate::apis::urlencode(block_hash));
let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
if let Some(ref local_var_str) = context {
local_var_req_builder = local_var_req_builder.query(&[("context", &local_var_str.to_string())]);
}
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_apikey) = configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value);
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<GetXrpRippleBlockDetailsByBlockHashError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
pub async fn get_xrp__ripple_block_details_by_block_height(configuration: &configuration::Configuration, network: &str, height: &str, context: Option<&str>) -> Result<crate::models::GetXrpRippleBlockDetailsByBlockHeightResponse, Error<GetXrpRippleBlockDetailsByBlockHeightError>> {
let local_var_client = &configuration.client;
let local_var_uri_str = format!("{}/blockchain-data/xrp/{network}/blocks/height/{height}", configuration.base_path, network=crate::apis::urlencode(network), height=crate::apis::urlencode(height));
let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
if let Some(ref local_var_str) = context {
local_var_req_builder = local_var_req_builder.query(&[("context", &local_var_str.to_string())]);
}
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_apikey) = configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value);
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<GetXrpRippleBlockDetailsByBlockHeightError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
pub async fn get_xrp__ripple_transaction_details_by_transaction_id(configuration: &configuration::Configuration, network: &str, transaction_hash: &str, context: Option<&str>) -> Result<crate::models::GetXrpRippleTransactionDetailsByTransactionIdResponse, Error<GetXrpRippleTransactionDetailsByTransactionIdError>> {
let local_var_client = &configuration.client;
let local_var_uri_str = format!("{}/blockchain-data/xrp/{network}/transactions/{transactionHash}", configuration.base_path, network=crate::apis::urlencode(network), transactionHash=crate::apis::urlencode(transaction_hash));
let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
if let Some(ref local_var_str) = context {
local_var_req_builder = local_var_req_builder.query(&[("context", &local_var_str.to_string())]);
}
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_apikey) = configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value);
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<GetXrpRippleTransactionDetailsByTransactionIdError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
pub async fn list_xrp__ripple_transactions_by_address(configuration: &configuration::Configuration, network: &str, address: &str, context: Option<&str>, limit: Option<i32>, offset: Option<i32>) -> Result<crate::models::ListXrpRippleTransactionsByAddressResponse, Error<ListXrpRippleTransactionsByAddressError>> {
let local_var_client = &configuration.client;
let local_var_uri_str = format!("{}/blockchain-data/xrp/{network}/addresses/{address}/transactions", configuration.base_path, network=crate::apis::urlencode(network), address=crate::apis::urlencode(address));
let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
if let Some(ref local_var_str) = context {
local_var_req_builder = local_var_req_builder.query(&[("context", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = limit {
local_var_req_builder = local_var_req_builder.query(&[("limit", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = offset {
local_var_req_builder = local_var_req_builder.query(&[("offset", &local_var_str.to_string())]);
}
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_apikey) = configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value);
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<ListXrpRippleTransactionsByAddressError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
pub async fn list_xrp__ripple_transactions_by_block_hash(configuration: &configuration::Configuration, network: &str, block_hash: &str, context: Option<&str>, limit: Option<i32>, offset: Option<i32>) -> Result<crate::models::ListXrpRippleTransactionsByBlockHashResponse, Error<ListXrpRippleTransactionsByBlockHashError>> {
let local_var_client = &configuration.client;
let local_var_uri_str = format!("{}/blockchain-data/xrp/{network}/blocks/hash/{blockHash}/transactions", configuration.base_path, network=crate::apis::urlencode(network), blockHash=crate::apis::urlencode(block_hash));
let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
if let Some(ref local_var_str) = context {
local_var_req_builder = local_var_req_builder.query(&[("context", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = limit {
local_var_req_builder = local_var_req_builder.query(&[("limit", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = offset {
local_var_req_builder = local_var_req_builder.query(&[("offset", &local_var_str.to_string())]);
}
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_apikey) = configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value);
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<ListXrpRippleTransactionsByBlockHashError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}