use super::types::*;
use crate::client::Client;
use crate::error::Result;
pub struct NftsApi<'a> {
client: &'a Client,
}
impl<'a> NftsApi<'a> {
pub fn new(client: &'a Client) -> Self {
Self { client }
}
pub async fn list(&self) -> Result<Vec<NftListItem>> {
self.client.get("/nfts/list").await
}
pub async fn list_with_options(&self, options: &NftListOptions) -> Result<Vec<NftListItem>> {
let path = format!("/nfts/list{}", options.to_query_string());
self.client.get(&path).await
}
pub async fn get(&self, id: &str) -> Result<NftCollection> {
let path = format!("/nfts/{}", id);
self.client.get(&path).await
}
pub async fn by_contract(
&self,
asset_platform_id: &str,
contract_address: &str,
) -> Result<NftCollection> {
let path = format!("/nfts/{}/contract/{}", asset_platform_id, contract_address);
self.client.get(&path).await
}
pub async fn markets(&self) -> Result<Vec<NftMarketItem>> {
self.client.get("/nfts/markets").await
}
pub async fn markets_with_options(
&self,
options: &NftListOptions,
) -> Result<Vec<NftMarketItem>> {
let path = format!("/nfts/markets{}", options.to_query_string());
self.client.get(&path).await
}
pub async fn tickers(&self, id: &str) -> Result<NftTickersResponse> {
let path = format!("/nfts/{}/tickers", id);
self.client.get(&path).await
}
pub async fn market_chart(&self, id: &str, days: &str) -> Result<NftMarketChart> {
let path = format!("/nfts/{}/market_chart?days={}", id, days);
self.client.get(&path).await
}
pub async fn contract_market_chart(
&self,
asset_platform_id: &str,
contract_address: &str,
days: &str,
) -> Result<NftMarketChart> {
let path = format!(
"/nfts/{}/contract/{}/market_chart?days={}",
asset_platform_id, contract_address, days
);
self.client.get(&path).await
}
}