use super::types::{
EntityListItem, HoldingChart, PublicTreasuryByCoin, PublicTreasuryByEntity, TransactionHistory,
};
use crate::client::Client;
use crate::error::Result;
pub struct TreasuryApi<'a> {
client: &'a Client,
}
impl<'a> TreasuryApi<'a> {
#[must_use]
pub fn new(client: &'a Client) -> Self {
Self { client }
}
pub async fn entities(&self) -> Result<Vec<EntityListItem>> {
self.client.get("/entities/list").await
}
pub async fn by_coin(&self, entity: &str, coin_id: &str) -> Result<PublicTreasuryByCoin> {
let path = format!("/{entity}/public_treasury/{coin_id}");
self.client.get(&path).await
}
pub async fn by_entity(&self, entity_id: &str) -> Result<PublicTreasuryByEntity> {
let path = format!("/public_treasury/{entity_id}");
self.client.get(&path).await
}
pub async fn holding_chart(&self, entity_id: &str, coin_id: &str) -> Result<HoldingChart> {
let path = format!("/public_treasury/{entity_id}/{coin_id}/holding_chart");
self.client.get(&path).await
}
pub async fn transaction_history(&self, entity_id: &str) -> Result<TransactionHistory> {
let path = format!("/public_treasury/{entity_id}/transaction_history");
self.client.get(&path).await
}
}