use async_trait::async_trait;
use chrono::{DateTime, Local};
use std::sync::Arc;
use super::AssetHandler;
use super::DataError;
use super::{Currency, CurrencyISOCode, Quote, Ticker};
#[async_trait]
pub trait QuoteHandler: AssetHandler {
fn into_arc_dispatch(self: Arc<Self>) -> Arc<dyn AssetHandler + Send + Sync>;
async fn insert_ticker(&self, ticker: &Ticker) -> Result<i32, DataError>;
async fn get_ticker_id(&self, ticker: &str) -> Option<i32>;
async fn insert_if_new_ticker(&self, ticker: &Ticker) -> Result<i32, DataError>;
async fn get_ticker_by_id(&self, id: i32) -> Result<Ticker, DataError>;
async fn get_all_ticker(&self) -> Result<Vec<Ticker>, DataError>;
async fn get_all_ticker_for_source(&self, source: &str) -> Result<Vec<Ticker>, DataError>;
async fn get_all_ticker_for_asset(&self, asset_id: i32) -> Result<Vec<Ticker>, DataError>;
async fn update_ticker(&self, ticker: &Ticker) -> Result<(), DataError>;
async fn delete_ticker(&self, id: i32) -> Result<(), DataError>;
async fn insert_quote(&self, quote: &Quote) -> Result<i32, DataError>;
async fn get_last_fx_quote_before(
&self,
curr: &CurrencyISOCode,
time: DateTime<Local>,
) -> Result<(Quote, Currency), DataError>;
async fn get_last_quote_before_by_id(
&self,
asset_id: i32,
time: DateTime<Local>,
) -> Result<(Quote, Currency), DataError>;
async fn get_quotes_in_range_by_id(
&self,
asset_id: i32,
start: DateTime<Local>,
end: DateTime<Local>,
) -> Result<Vec<(Quote, i32)>, DataError>;
async fn get_all_quotes_for_ticker(&self, ticker_id: i32) -> Result<Vec<Quote>, DataError>;
async fn update_quote(&self, quote: &Quote) -> Result<(), DataError>;
async fn delete_quote(&self, id: i32) -> Result<(), DataError>;
async fn remove_duplicates(&self) -> Result<(), DataError>;
}