/*
* CryptoAPIs
*
* Crypto APIs is a complex and innovative infrastructure layer that radically simplifies the development of any Blockchain and Crypto related applications. Organized around REST, Crypto APIs can assist both novice Bitcoin/Ethereum enthusiasts and crypto experts with the development of their blockchain applications. Crypto APIs provides unified endpoints and data, raw data, automatic tokens and coins forwardings, callback functionalities, and much more.
*
* The version of the OpenAPI document: 2021-03-20
* Contact: developers@cryptoapis.io
* Generated by: https://openapi-generator.tech
*/
use reqwest;
use crate::apis::ResponseContent;
use super::{Error, configuration};
/// struct for typed errors of method `create_coins_transaction_from_address_for_whole_amount`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateCoinsTransactionFromAddressForWholeAmountError {
Status400(crate::models::InlineResponse40023),
Status401(crate::models::InlineResponse40123),
Status402(crate::models::InlineResponse402),
Status403(crate::models::InlineResponse40323),
Status409(crate::models::InlineResponse4093),
Status415(crate::models::InlineResponse415),
Status422(crate::models::InlineResponse422),
Status429(crate::models::InlineResponse429),
Status500(crate::models::InlineResponse500),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method `create_coins_transaction_request_from_address`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateCoinsTransactionRequestFromAddressError {
Status400(crate::models::InlineResponse40018),
Status401(crate::models::InlineResponse40118),
Status402(crate::models::InlineResponse402),
Status403(crate::models::InlineResponse40318),
Status409(crate::models::InlineResponse4092),
Status415(crate::models::InlineResponse415),
Status422(crate::models::InlineResponse422),
Status429(crate::models::InlineResponse429),
Status500(crate::models::InlineResponse500),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method `create_coins_transaction_request_from_wallet`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateCoinsTransactionRequestFromWalletError {
Status400(crate::models::InlineResponse40012),
Status401(crate::models::InlineResponse40112),
Status402(crate::models::InlineResponse402),
Status403(crate::models::InlineResponse40312),
Status409(crate::models::InlineResponse4091),
Status415(crate::models::InlineResponse415),
Status422(crate::models::InlineResponse422),
Status429(crate::models::InlineResponse429),
Status500(crate::models::InlineResponse500),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method `create_fungible_token_transaction_request_from_address_without_fee_priority`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateFungibleTokenTransactionRequestFromAddressWithoutFeePriorityError {
Status400(crate::models::InlineResponse40043),
Status401(crate::models::InlineResponse40143),
Status402(crate::models::InlineResponse402),
Status403(crate::models::InlineResponse40343),
Status409(crate::models::InlineResponse4097),
Status415(crate::models::InlineResponse415),
Status422(crate::models::InlineResponse422),
Status429(crate::models::InlineResponse429),
Status500(crate::models::InlineResponse500),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method `create_fungible_tokens_transaction_request_from_address`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateFungibleTokensTransactionRequestFromAddressError {
Status400(crate::models::InlineResponse40032),
Status401(crate::models::InlineResponse40132),
Status402(crate::models::InlineResponse402),
Status403(crate::models::InlineResponse40332),
Status409(crate::models::InlineResponse4094),
Status415(crate::models::InlineResponse415),
Status422(crate::models::InlineResponse422),
Status429(crate::models::InlineResponse429),
Status500(crate::models::InlineResponse500),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method `create_single_transaction_request_from_address_without_fee_priority`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateSingleTransactionRequestFromAddressWithoutFeePriorityError {
Status400(crate::models::InlineResponse40039),
Status401(crate::models::InlineResponse40139),
Status402(crate::models::InlineResponse402),
Status403(crate::models::InlineResponse40339),
Status409(crate::models::InlineResponse4095),
Status415(crate::models::InlineResponse415),
Status422(crate::models::InlineResponse422),
Status429(crate::models::InlineResponse429),
Status500(crate::models::InlineResponse500),
UnknownValue(serde_json::Value),
}
/// Through this endpoint customers can create a new transaction from address for **coins** specifically, which will transfer over the entire available amount.
pub async fn create_coins_transaction_from_address_for_whole_amount(configuration: &configuration::Configuration, address: &str, blockchain: &str, network: &str, wallet_id: &str, context: Option<&str>, create_coins_transaction_from_address_for_whole_amount_rb: Option<crate::models::CreateCoinsTransactionFromAddressForWholeAmountRb>) -> Result<crate::models::CreateCoinsTransactionFromAddressForWholeAmountR, Error<CreateCoinsTransactionFromAddressForWholeAmountError>> {
let local_var_client = &configuration.client;
let local_var_uri_str = format!("{}/wallet-as-a-service/wallets/{walletId}/{blockchain}/{network}/addresses/{address}/all-transaction-requests", configuration.base_path, address=crate::apis::urlencode(address), blockchain=crate::apis::urlencode(blockchain), network=crate::apis::urlencode(network), walletId=crate::apis::urlencode(wallet_id));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, 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);
};
local_var_req_builder = local_var_req_builder.json(&create_coins_transaction_from_address_for_whole_amount_rb);
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<CreateCoinsTransactionFromAddressForWholeAmountError> = 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))
}
}
/// Through this endpoint users can create a new single transaction request from one address to another.
pub async fn create_coins_transaction_request_from_address(configuration: &configuration::Configuration, address: &str, blockchain: &str, network: &str, wallet_id: &str, context: Option<&str>, create_coins_transaction_request_from_address_rb: Option<crate::models::CreateCoinsTransactionRequestFromAddressRb>) -> Result<crate::models::CreateCoinsTransactionRequestFromAddressR, Error<CreateCoinsTransactionRequestFromAddressError>> {
let local_var_client = &configuration.client;
let local_var_uri_str = format!("{}/wallet-as-a-service/wallets/{walletId}/{blockchain}/{network}/addresses/{address}/transaction-requests", configuration.base_path, address=crate::apis::urlencode(address), blockchain=crate::apis::urlencode(blockchain), network=crate::apis::urlencode(network), walletId=crate::apis::urlencode(wallet_id));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, 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);
};
local_var_req_builder = local_var_req_builder.json(&create_coins_transaction_request_from_address_rb);
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<CreateCoinsTransactionRequestFromAddressError> = 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))
}
}
/// Through this endpoint users can create a new transaction request from the entire Wallet instead from just a specific address. This endpoint can generate transactions from multiple to multiple addresses. {warning}This is available **only** for UTXO-based protocols such as Bitcoin, Bitcoin Cash, Litecoin, etc. It **is not** available for Account-based protocols like Ethereum.{/warning}
pub async fn create_coins_transaction_request_from_wallet(configuration: &configuration::Configuration, blockchain: &str, network: &str, wallet_id: &str, context: Option<&str>, create_coins_transaction_request_from_wallet_rb: Option<crate::models::CreateCoinsTransactionRequestFromWalletRb>) -> Result<crate::models::CreateCoinsTransactionRequestFromWalletR, Error<CreateCoinsTransactionRequestFromWalletError>> {
let local_var_client = &configuration.client;
let local_var_uri_str = format!("{}/wallet-as-a-service/wallets/{walletId}/{blockchain}/{network}/transaction-requests", configuration.base_path, blockchain=crate::apis::urlencode(blockchain), network=crate::apis::urlencode(network), walletId=crate::apis::urlencode(wallet_id));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, 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);
};
local_var_req_builder = local_var_req_builder.json(&create_coins_transaction_request_from_wallet_rb);
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<CreateCoinsTransactionRequestFromWalletError> = 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))
}
}
/// Through this endpoint customers can make a single feeless token transaction on the Tron blockchain protocol. TRX transactions burn certain resources called Bandwidth and Energy. Each account has 1500 bandwidth free for use every 24 hours and more can be obtained by staking TRX. The unit price of Energy is 280 SUN and of bandwidth - 1000 SUN. If the resources are insufficient, TRX will be burned to pay for them.
pub async fn create_fungible_token_transaction_request_from_address_without_fee_priority(configuration: &configuration::Configuration, blockchain: &str, network: &str, sender_address: &str, wallet_id: &str, context: Option<&str>, create_fungible_token_transaction_request_from_address_without_fee_priority_rb: Option<crate::models::CreateFungibleTokenTransactionRequestFromAddressWithoutFeePriorityRb>) -> Result<crate::models::CreateFungibleTokenTransactionRequestFromAddressWithoutFeePriorityR, Error<CreateFungibleTokenTransactionRequestFromAddressWithoutFeePriorityError>> {
let local_var_client = &configuration.client;
let local_var_uri_str = format!("{}/wallet-as-a-service/wallets/{walletId}/{blockchain}/{network}/addresses/{senderAddress}/feeless-token-transaction-requests", configuration.base_path, blockchain=crate::apis::urlencode(blockchain), network=crate::apis::urlencode(network), senderAddress=crate::apis::urlencode(sender_address), walletId=crate::apis::urlencode(wallet_id));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, 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);
};
local_var_req_builder = local_var_req_builder.json(&create_fungible_token_transaction_request_from_address_without_fee_priority_rb);
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<CreateFungibleTokenTransactionRequestFromAddressWithoutFeePriorityError> = 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))
}
}
/// Through this endpoint users can make a single token transaction. {note}To have an operational callback subscription, you need to first verify a domain for the Callback URL. Please see more information on Callbacks [here](https://developers.cryptoapis.io/technical-documentation/general-information/callbacks#callback-url).{/note} {warning}Crypto APIs will notify the user **only when** the event occurs. There are cases when the specific event doesn't happen at all, or takes a long time to do so. A callback notification **will not** be sent if the event does not or cannot occur, or will take long time to occur.{/warning}
pub async fn create_fungible_tokens_transaction_request_from_address(configuration: &configuration::Configuration, blockchain: &str, network: &str, sender_address: &str, wallet_id: &str, context: Option<&str>, create_fungible_tokens_transaction_request_from_address_rb: Option<crate::models::CreateFungibleTokensTransactionRequestFromAddressRb>) -> Result<crate::models::CreateFungibleTokensTransactionRequestFromAddressR, Error<CreateFungibleTokensTransactionRequestFromAddressError>> {
let local_var_client = &configuration.client;
let local_var_uri_str = format!("{}/wallet-as-a-service/wallets/{walletId}/{blockchain}/{network}/addresses/{senderAddress}/token-transaction-requests", configuration.base_path, blockchain=crate::apis::urlencode(blockchain), network=crate::apis::urlencode(network), senderAddress=crate::apis::urlencode(sender_address), walletId=crate::apis::urlencode(wallet_id));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, 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);
};
local_var_req_builder = local_var_req_builder.json(&create_fungible_tokens_transaction_request_from_address_rb);
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<CreateFungibleTokensTransactionRequestFromAddressError> = 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))
}
}
/// Through this endpoint users can create a new single transaction request from one address to another. The difference between this endpoint and \"Create Coins Transaction Request from Address\" is that for Tron blockchain there is no Fee Priority that defines how fast a transaction can be mined.
pub async fn create_single_transaction_request_from_address_without_fee_priority(configuration: &configuration::Configuration, address: &str, blockchain: &str, network: &str, wallet_id: &str, context: Option<&str>, create_single_transaction_request_from_address_without_fee_priority_rb: Option<crate::models::CreateSingleTransactionRequestFromAddressWithoutFeePriorityRb>) -> Result<crate::models::CreateSingleTransactionRequestFromAddressWithoutFeePriorityR, Error<CreateSingleTransactionRequestFromAddressWithoutFeePriorityError>> {
let local_var_client = &configuration.client;
let local_var_uri_str = format!("{}/wallet-as-a-service/wallets/{walletId}/{blockchain}/{network}/addresses/{address}/feeless-transaction-requests", configuration.base_path, address=crate::apis::urlencode(address), blockchain=crate::apis::urlencode(blockchain), network=crate::apis::urlencode(network), walletId=crate::apis::urlencode(wallet_id));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, 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);
};
local_var_req_builder = local_var_req_builder.json(&create_single_transaction_request_from_address_without_fee_priority_rb);
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<CreateSingleTransactionRequestFromAddressWithoutFeePriorityError> = 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))
}
}