use crate::{
Client, Result,
endpoints::{EndpointSpec, QueryEncoder, QueryParameters},
responses::quote::QuoteShort,
types::Ticker,
};
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct QuoteShortQuery {
symbol: Ticker,
}
impl QuoteShortQuery {
pub fn new(symbol: Ticker) -> Self {
Self { symbol }
}
pub fn symbol(&self) -> &Ticker {
&self.symbol
}
}
impl From<Ticker> for QuoteShortQuery {
fn from(symbol: Ticker) -> Self {
Self::new(symbol)
}
}
impl From<&Ticker> for QuoteShortQuery {
fn from(symbol: &Ticker) -> Self {
Self::new(symbol.clone())
}
}
impl QueryParameters for QuoteShortQuery {
fn encode(&self, encoder: &mut QueryEncoder<'_>) {
encoder.required("symbol", &self.symbol);
}
}
pub fn quote_short(query: QuoteShortQuery) -> EndpointSpec<QuoteShortQuery, Vec<QuoteShort>> {
EndpointSpec::get("quote-short", "quote-short", query)
}
impl Client {
pub async fn quote_short(&self, symbol: impl Into<QuoteShortQuery>) -> Result<Vec<QuoteShort>> {
self.execute("e_short(symbol.into())).await
}
}