use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct TokenPrice {
pub symbol: Option<String>,
pub network: Option<String>,
pub address: Option<String>,
pub prices: Vec<PriceEntry>,
pub error: Option<String>,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct PriceEntry {
pub currency: String,
pub value: String,
pub last_updated_at: Option<String>,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct TokenPricesBySymbolResponse {
pub data: Vec<TokenPrice>,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct TokenPricesByAddressResponse {
pub data: Vec<TokenPrice>,
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct TokenAddress {
pub network: String,
pub address: String,
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct TokenPricesByAddressRequest {
pub addresses: Vec<TokenAddress>,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct HistoricalPricePoint {
pub timestamp: String,
pub value: String,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct HistoricalPriceResponse {
pub symbol: Option<String>,
pub network: Option<String>,
pub address: Option<String>,
pub currency: String,
pub data: Vec<HistoricalPricePoint>,
pub error: Option<String>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum HistoricalInterval {
FiveMinutes,
OneHour,
OneDay,
}
impl HistoricalInterval {
pub fn as_str(&self) -> &'static str {
match self {
HistoricalInterval::FiveMinutes => "5m",
HistoricalInterval::OneHour => "1h",
HistoricalInterval::OneDay => "1d",
}
}
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct HistoricalPriceRequest {
#[serde(skip_serializing_if = "Option::is_none")]
pub symbol: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub network: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub address: Option<String>,
pub start_time: String,
pub end_time: String,
pub interval: String,
}