/*
* CryptoAPIs
*
* Crypto APIs 2.0 is a complex and innovative infrastructure layer that radically simplifies the development of any Blockchain and Crypto related applications. Organized around REST, Crypto APIs 2.0 can assist both novice Bitcoin/Ethereum enthusiasts and crypto experts with the development of their blockchain applications. Crypto APIs 2.0 provides unified endpoints and data, raw data, automatic tokens and coins forwardings, callback functionalities, and much more.
*
* The version of the OpenAPI document: 2.0.0
* 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 `mined_transaction`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum MinedTransactionError {
Status400(crate::models::InvalidPagination),
Status401(crate::models::InvalidApiKey),
Status402(crate::models::InsufficientCredits),
Status403(crate::models::BlockchainEventsCallbacksLimitReached),
Status409(crate::models::AlreadyExists),
Status415(crate::models::UnsupportedMediaType),
Status422(crate::models::InvalidRequestBodyStructure),
Status429(crate::models::RequestLimitReached),
Status500(crate::models::UnexpectedServerError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method `new_block`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum NewBlockError {
Status400(crate::models::InvalidPagination),
Status401(crate::models::InvalidApiKey),
Status402(crate::models::InsufficientCredits),
Status403(crate::models::BlockchainEventsCallbacksLimitReached),
Status409(crate::models::AlreadyExists),
Status415(crate::models::UnsupportedMediaType),
Status422(crate::models::InvalidRequestBodyStructure),
Status429(crate::models::RequestLimitReached),
Status500(crate::models::UnexpectedServerError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method `new_confirmed_coins_transactions`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum NewConfirmedCoinsTransactionsError {
Status400(crate::models::InvalidPagination),
Status401(crate::models::InvalidApiKey),
Status402(crate::models::InsufficientCredits),
Status403(crate::models::BlockchainEventsCallbacksLimitReached),
Status409(crate::models::AlreadyExists),
Status415(crate::models::UnsupportedMediaType),
Status422(crate::models::InvalidRequestBodyStructure),
Status429(crate::models::RequestLimitReached),
Status500(crate::models::UnexpectedServerError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method `new_confirmed_coins_transactions_and_each_confirmation`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum NewConfirmedCoinsTransactionsAndEachConfirmationError {
Status400(crate::models::InvalidPagination),
Status401(crate::models::InvalidApiKey),
Status402(crate::models::InsufficientCredits),
Status403(crate::models::BlockchainEventsCallbacksLimitReached),
Status409(crate::models::AlreadyExists),
Status415(crate::models::UnsupportedMediaType),
Status422(crate::models::InvalidRequestBodyStructure),
Status429(crate::models::RequestLimitReached),
Status500(crate::models::UnexpectedServerError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method `new_confirmed_tokens_transactions`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum NewConfirmedTokensTransactionsError {
Status400(crate::models::InvalidPagination),
Status401(crate::models::InvalidApiKey),
Status402(crate::models::InsufficientCredits),
Status403(crate::models::BlockchainEventsCallbacksLimitReached),
Status409(crate::models::AlreadyExists),
Status415(crate::models::UnsupportedMediaType),
Status422(crate::models::InvalidRequestBodyStructure),
Status429(crate::models::RequestLimitReached),
Status500(crate::models::UnexpectedServerError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method `new_confirmed_tokens_transactions_and_each_confirmation`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum NewConfirmedTokensTransactionsAndEachConfirmationError {
Status400(crate::models::InvalidPagination),
Status401(crate::models::InvalidApiKey),
Status402(crate::models::InsufficientCredits),
Status403(crate::models::BlockchainEventsCallbacksLimitReached),
Status409(crate::models::AlreadyExists),
Status415(crate::models::UnsupportedMediaType),
Status422(crate::models::InvalidRequestBodyStructure),
Status429(crate::models::RequestLimitReached),
Status500(crate::models::UnexpectedServerError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method `new_unconfirmed_coins_transactions`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum NewUnconfirmedCoinsTransactionsError {
Status400(crate::models::InvalidPagination),
Status401(crate::models::InvalidApiKey),
Status402(crate::models::InsufficientCredits),
Status403(crate::models::BlockchainEventsCallbacksLimitReached),
Status409(crate::models::AlreadyExists),
Status415(crate::models::UnsupportedMediaType),
Status422(crate::models::InvalidRequestBodyStructure),
Status429(crate::models::RequestLimitReached),
Status500(crate::models::UnexpectedServerError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method `new_unconfirmed_tokens_transactions`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum NewUnconfirmedTokensTransactionsError {
Status400(crate::models::InvalidPagination),
Status401(crate::models::InvalidApiKey),
Status402(crate::models::InsufficientCredits),
Status403(crate::models::BlockchainEventsCallbacksLimitReached),
Status409(crate::models::AlreadyExists),
Status415(crate::models::UnsupportedMediaType),
Status422(crate::models::InvalidRequestBodyStructure),
Status429(crate::models::RequestLimitReached),
Status500(crate::models::UnexpectedServerError),
UnknownValue(serde_json::Value),
}
/// Through this endpoint customers can create callback subscriptions for a specific event. In this case the event is when a specific transaction is mined. By creating this subscription the user will be notified by Crypto APIs 2.0 when that event occurs. The information is returned per specified `transactionId`. A transaction is mined when it is included in a new block in the blockchain. {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 mined_transaction(configuration: &configuration::Configuration, blockchain: &str, network: &str, context: Option<&str>, mined_transaction_request_body: Option<crate::models::MinedTransactionRequestBody>) -> Result<crate::models::MinedTransactionResponse, Error<MinedTransactionError>> {
let local_var_client = &configuration.client;
let local_var_uri_str = format!("{}/blockchain-events/{blockchain}/{network}/subscriptions/transaction-mined", configuration.base_path, blockchain=crate::apis::urlencode(blockchain), network=crate::apis::urlencode(network));
let mut local_var_req_builder = local_var_client.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(&mined_transaction_request_body);
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<MinedTransactionError> = 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 create callback subscriptions for a specific event. In this case the event is when a new block is mined in the specific blockchain. By creating this subscription the user will be notified by Crypto APIs 2.0 when that event occurs. The information is returned per specified address. A new block is mined when it is added to the chain once a consensus is reached by the majority of the miners, which is when the block gets validated and added to the blockchain. {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 new_block(configuration: &configuration::Configuration, blockchain: &str, network: &str, context: Option<&str>, new_block_request_body: Option<crate::models::NewBlockRequestBody>) -> Result<crate::models::NewBlockResponse, Error<NewBlockError>> {
let local_var_client = &configuration.client;
let local_var_uri_str = format!("{}/blockchain-events/{blockchain}/{network}/subscriptions/block-mined", configuration.base_path, blockchain=crate::apis::urlencode(blockchain), network=crate::apis::urlencode(network));
let mut local_var_req_builder = local_var_client.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(&new_block_request_body);
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<NewBlockError> = 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 create callback subscriptions for a specific event. In this case the event is when there are new incoming or outgoing confirmed transactions for coins from/to the customer's address. By creating this subscription the user will be notified by Crypto APIs 2.0 when that event occurs. The information is returned per specified address. Being confirmed means that the transactions are verified by miners and added to the next block. {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 new_confirmed_coins_transactions(configuration: &configuration::Configuration, blockchain: &str, network: &str, context: Option<&str>, new_confirmed_coins_transactions_request_body: Option<crate::models::NewConfirmedCoinsTransactionsRequestBody>) -> Result<crate::models::NewConfirmedCoinsTransactionsResponse, Error<NewConfirmedCoinsTransactionsError>> {
let local_var_client = &configuration.client;
let local_var_uri_str = format!("{}/blockchain-events/{blockchain}/{network}/subscriptions/address-coins-transactions-confirmed", configuration.base_path, blockchain=crate::apis::urlencode(blockchain), network=crate::apis::urlencode(network));
let mut local_var_req_builder = local_var_client.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(&new_confirmed_coins_transactions_request_body);
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<NewConfirmedCoinsTransactionsError> = 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 create callback subscriptions for a specific event. In this case the event is when there are new incoming or outgoing confirmed transactions for coins from/to the customer's address with also a response at each confirmation the transaction has received until the specified confirmations limit is reached. By creating this subscription the user will be notified by Crypto APIs 2.0 when that event occurs. The information is returned per specified address. Being confirmed means that the transactions are verified by miners and added to the next block. This endpoint refers to **coins transactions only, not tokens**. {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 new_confirmed_coins_transactions_and_each_confirmation(configuration: &configuration::Configuration, blockchain: &str, network: &str, context: Option<&str>, new_confirmed_coins_transactions_and_each_confirmation_request_body: Option<crate::models::NewConfirmedCoinsTransactionsAndEachConfirmationRequestBody>) -> Result<crate::models::NewConfirmedCoinsTransactionsAndEachConfirmationResponse, Error<NewConfirmedCoinsTransactionsAndEachConfirmationError>> {
let local_var_client = &configuration.client;
let local_var_uri_str = format!("{}/blockchain-events/{blockchain}/{network}/subscriptions/address-coins-transactions-confirmed-each-confirmation", configuration.base_path, blockchain=crate::apis::urlencode(blockchain), network=crate::apis::urlencode(network));
let mut local_var_req_builder = local_var_client.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(&new_confirmed_coins_transactions_and_each_confirmation_request_body);
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<NewConfirmedCoinsTransactionsAndEachConfirmationError> = 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 create callback subscriptions for a specific event. In this case the event is when there are new incoming or outgoing confirmed transactions for tokens from/to the customer's address. By creating this subscription the user will be notified by Crypto APIs 2.0 when that event occurs. The information is returned per specified address. Being confirmed means that the transactions are verified by miners and added to the next block. This endpoint refers to **tokens transactions only, not coins**. {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 new_confirmed_tokens_transactions(configuration: &configuration::Configuration, blockchain: &str, network: &str, context: Option<&str>, new_confirmed_tokens_transactions_request_body: Option<crate::models::NewConfirmedTokensTransactionsRequestBody>) -> Result<crate::models::NewConfirmedTokensTransactionsResponse, Error<NewConfirmedTokensTransactionsError>> {
let local_var_client = &configuration.client;
let local_var_uri_str = format!("{}/blockchain-events/{blockchain}/{network}/subscriptions/address-tokens-transactions-confirmed", configuration.base_path, blockchain=crate::apis::urlencode(blockchain), network=crate::apis::urlencode(network));
let mut local_var_req_builder = local_var_client.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(&new_confirmed_tokens_transactions_request_body);
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<NewConfirmedTokensTransactionsError> = 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 create callback subscriptions for a specific event. In this case the event is when there are new incoming or outgoing confirmed transactions for tokens from/to the customer's address with also a response at each confirmation the transaction has received until the specified confirmations limit is reached. By creating this subscription the user will be notified by Crypto APIs 2.0 when that event occurs. The information is returned per specified address. Being confirmed means that the transactions are verified by miners and added to the next block. This endpoint refers to **tokens transactions only, not coins**. {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 new_confirmed_tokens_transactions_and_each_confirmation(configuration: &configuration::Configuration, blockchain: &str, network: &str, context: Option<&str>, new_confirmed_tokens_transactions_and_each_confirmation_request_body: Option<crate::models::NewConfirmedTokensTransactionsAndEachConfirmationRequestBody>) -> Result<crate::models::NewConfirmedTokensTransactionsAndEachConfirmationResponse, Error<NewConfirmedTokensTransactionsAndEachConfirmationError>> {
let local_var_client = &configuration.client;
let local_var_uri_str = format!("{}/blockchain-events/{blockchain}/{network}/subscriptions/address-tokens-transactions-confirmed-each-confirmation", configuration.base_path, blockchain=crate::apis::urlencode(blockchain), network=crate::apis::urlencode(network));
let mut local_var_req_builder = local_var_client.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(&new_confirmed_tokens_transactions_and_each_confirmation_request_body);
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<NewConfirmedTokensTransactionsAndEachConfirmationError> = 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 create callback subscriptions for a specific event. In this case the event is when there are new unconfirmed coins transactions for the user. By creating this subscription the user will be notified by Crypto APIs 2.0 when that event occurs. The information is returned per specified address. Unconfirmed coins transactions remain in the mempool (memory pool) until they are confirmed by miners and added to the next block. Sometimes spikes in transaction activity can cause delays in confirmations. {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} {note}It is also **important to note** that just because pending unconfirmed transactions are in the mempool, **doesn't necessarily** mean they will get confirmed.{/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 new_unconfirmed_coins_transactions(configuration: &configuration::Configuration, blockchain: &str, network: &str, context: Option<&str>, new_unconfirmed_coins_transactions_request_body: Option<crate::models::NewUnconfirmedCoinsTransactionsRequestBody>) -> Result<crate::models::NewUnconfirmedCoinsTransactionsResponse, Error<NewUnconfirmedCoinsTransactionsError>> {
let local_var_client = &configuration.client;
let local_var_uri_str = format!("{}/blockchain-events/{blockchain}/{network}/subscriptions/address-coins-transactions-unconfirmed", configuration.base_path, blockchain=crate::apis::urlencode(blockchain), network=crate::apis::urlencode(network));
let mut local_var_req_builder = local_var_client.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(&new_unconfirmed_coins_transactions_request_body);
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<NewUnconfirmedCoinsTransactionsError> = 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 create callback subscriptions for a specific event. In this case the event is when there are new unconfirmed tokens transactions for the user. By creating this subscription the user will be notified by Crypto APIs 2.0 when that event occurs. The information is returned per specified address. Unconfirmed tokens transactions remain in the mempool (memory pool) until they are confirmed by miners and added to the next block. Sometimes spikes in transaction activity can cause delays in confirmations. {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} {note}It is also **important to note** that just because pending unconfirmed transactions are in the mempool, **doesn't necessarily** mean they will get confirmed.{/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 new_unconfirmed_tokens_transactions(configuration: &configuration::Configuration, blockchain: &str, network: &str, context: Option<&str>, new_unconfirmed_tokens_transactions_request_body: Option<crate::models::NewUnconfirmedTokensTransactionsRequestBody>) -> Result<crate::models::NewUnconfirmedTokensTransactionsResponse, Error<NewUnconfirmedTokensTransactionsError>> {
let local_var_client = &configuration.client;
let local_var_uri_str = format!("{}/blockchain-events/{blockchain}/{network}/subscriptions/address-tokens-transactions-unconfirmed", configuration.base_path, blockchain=crate::apis::urlencode(blockchain), network=crate::apis::urlencode(network));
let mut local_var_req_builder = local_var_client.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(&new_unconfirmed_tokens_transactions_request_body);
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<NewUnconfirmedTokensTransactionsError> = 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))
}
}