dceapi_rs/services/
common.rs1use crate::error::Result;
4use crate::http::{BaseClient, RequestOptions};
5use crate::models::{TradeDate, Variety, VarietyMonthYearStat, VarietyMonthYearStatRequest};
6
7const PATH_GET_CURR_TRADE_DATE: &str = "/dceapi/forward/publicweb/maxTradeDate";
9
10const PATH_GET_VARIETY_LIST: &str = "/dceapi/forward/publicweb/variety";
12
13const PATH_GET_VARIETY_MONTH_YEAR_STAT: &str =
15 "/dceapi/forward/publicweb/phasestat/varietyMonthYearStat";
16
17#[derive(Debug, Clone)]
19pub struct CommonService {
20 client: BaseClient,
21}
22
23impl CommonService {
24 pub fn new(client: BaseClient) -> Self {
26 CommonService { client }
27 }
28
29 pub async fn get_curr_trade_date(&self, opts: Option<RequestOptions>) -> Result<TradeDate> {
34 self.client.do_get(PATH_GET_CURR_TRADE_DATE, opts).await
35 }
36
37 pub async fn get_variety_list(&self, opts: Option<RequestOptions>) -> Result<Vec<Variety>> {
42 self.client.do_get(PATH_GET_VARIETY_LIST, opts).await
43 }
44
45 pub async fn get_variety_month_year_stat(
51 &self,
52 req: &VarietyMonthYearStatRequest,
53 opts: Option<RequestOptions>,
54 ) -> Result<Vec<VarietyMonthYearStat>> {
55 self.client
56 .do_post(PATH_GET_VARIETY_MONTH_YEAR_STAT, req, opts)
57 .await
58 }
59}