pub mod delegated;
pub mod types;
#[allow(unused_imports)]
use types::*;
#[derive(Clone)]
pub struct AddressWatchesClient {
client: crate::client::Client,
}
impl AddressWatchesClient {
pub fn new(client: crate::client::Client) -> Self {
AddressWatchesClient { client }
}
pub async fn list_address_watches(
&self,
query: Option<ListAddressWatchesQuery>,
) -> Result<ListAddressWatchesResponse, crate::error::Error> {
let mut path = String::from("/address-watches");
if let Some(query) = &query {
let mut q: Vec<String> = Vec::new();
if let Some(v) = &query.limit {
q.push(format!("limit={}", urlencoding::encode(&v.to_string())));
}
if let Some(v) = &query.pagination_token {
q.push(format!(
"paginationToken={}",
urlencoding::encode(&v.to_string())
));
}
if !q.is_empty() {
path.push('?');
path.push_str(&q.join("&"));
}
}
self.client
.request::<ListAddressWatchesResponse>(reqwest::Method::GET, &path, None, false)
.await
}
pub async fn create_address_watch(
&self,
body: CreateAddressWatchRequest,
) -> Result<CreateAddressWatchResponse, crate::error::Error> {
let path = String::from("/address-watches");
let body = serde_json::to_value(&body)?;
self.client
.request::<CreateAddressWatchResponse>(reqwest::Method::POST, &path, Some(&body), true)
.await
}
pub async fn get_address_watch(
&self,
address_watch_id: String,
) -> Result<GetAddressWatchResponse, crate::error::Error> {
let path = format!(
"/address-watches/{}",
urlencoding::encode(&address_watch_id)
);
self.client
.request::<GetAddressWatchResponse>(reqwest::Method::GET, &path, None, false)
.await
}
pub async fn get_address_watch_assets(
&self,
address_watch_id: String,
query: Option<GetAddressWatchAssetsQuery>,
) -> Result<GetAddressWatchAssetsResponse, crate::error::Error> {
let mut path = format!(
"/address-watches/{}/assets",
urlencoding::encode(&address_watch_id)
);
if let Some(query) = &query {
let mut q: Vec<String> = Vec::new();
if let Some(v) = &query.net_worth {
q.push(format!("netWorth={}", urlencoding::encode(&v.to_string())));
}
if !q.is_empty() {
path.push('?');
path.push_str(&q.join("&"));
}
}
self.client
.request::<GetAddressWatchAssetsResponse>(reqwest::Method::GET, &path, None, false)
.await
}
pub async fn get_address_watch_blockchain_events(
&self,
address_watch_id: String,
query: Option<GetAddressWatchBlockchainEventsQuery>,
) -> Result<GetAddressWatchBlockchainEventsResponse, crate::error::Error> {
let mut path = format!(
"/address-watches/{}/blockchain-events",
urlencoding::encode(&address_watch_id)
);
if let Some(query) = &query {
let mut q: Vec<String> = Vec::new();
if let Some(v) = &query.limit {
q.push(format!("limit={}", urlencoding::encode(&v.to_string())));
}
if let Some(v) = &query.pagination_token {
q.push(format!(
"paginationToken={}",
urlencoding::encode(&v.to_string())
));
}
if let Some(v) = &query.name {
q.push(format!("name={}", urlencoding::encode(&v.to_string())));
}
if let Some(v) = &query.contract {
q.push(format!("contract={}", urlencoding::encode(&v.to_string())));
}
if let Some(v) = &query.tx_hash {
q.push(format!("txHash={}", urlencoding::encode(&v.to_string())));
}
if !q.is_empty() {
path.push('?');
path.push_str(&q.join("&"));
}
}
self.client
.request::<GetAddressWatchBlockchainEventsResponse>(
reqwest::Method::GET,
&path,
None,
false,
)
.await
}
pub async fn get_address_watch_history(
&self,
address_watch_id: String,
query: Option<GetAddressWatchHistoryQuery>,
) -> Result<GetAddressWatchHistoryResponse, crate::error::Error> {
let mut path = format!(
"/address-watches/{}/history",
urlencoding::encode(&address_watch_id)
);
if let Some(query) = &query {
let mut q: Vec<String> = Vec::new();
if let Some(v) = &query.limit {
q.push(format!("limit={}", urlencoding::encode(&v.to_string())));
}
if let Some(v) = &query.pagination_token {
q.push(format!(
"paginationToken={}",
urlencoding::encode(&v.to_string())
));
}
if let Some(v) = &query.direction {
q.push(format!("direction={}", urlencoding::encode(&v.to_string())));
}
if let Some(v) = &query.kind {
q.push(format!("kind={}", urlencoding::encode(&v.to_string())));
}
if let Some(v) = &query.contract {
q.push(format!("contract={}", urlencoding::encode(&v.to_string())));
}
if !q.is_empty() {
path.push('?');
path.push_str(&q.join("&"));
}
}
self.client
.request::<GetAddressWatchHistoryResponse>(reqwest::Method::GET, &path, None, false)
.await
}
}