dceapi_rs/services/
member.rs

1//! Member service for member ranking APIs.
2
3use crate::error::Result;
4use crate::http::{BaseClient, RequestOptions};
5use crate::models::{DailyRankingRequest, DailyRankingResponse, PhaseRanking, PhaseRankingRequest};
6
7/// API endpoint for daily ranking.
8const PATH_GET_DAILY_RANKING: &str = "/dceapi/forward/publicweb/dailystat/memberDealPosi";
9
10/// API endpoint for phase ranking.
11const PATH_GET_PHASE_RANKING: &str = "/dceapi/forward/publicweb/phasestat/memberDealCh";
12
13/// Member service for accessing member ranking data.
14#[derive(Debug, Clone)]
15pub struct MemberService {
16    client: BaseClient,
17}
18
19impl MemberService {
20    /// Create a new member service.
21    pub fn new(client: BaseClient) -> Self {
22        MemberService { client }
23    }
24
25    /// Get daily trading ranking.
26    ///
27    /// Returns volume, buy position, and sell position rankings for a contract on a specific date.
28    ///
29    /// # Arguments
30    /// * `req` - Request with variety_id, contract_id, trade_date, and trade_type
31    /// * `opts` - Optional request options
32    pub async fn get_daily_ranking(
33        &self,
34        req: &DailyRankingRequest,
35        opts: Option<RequestOptions>,
36    ) -> Result<DailyRankingResponse> {
37        self.client.do_post(PATH_GET_DAILY_RANKING, req, opts).await
38    }
39
40    /// Get phase (period) trading ranking.
41    ///
42    /// Returns member rankings for a date range.
43    ///
44    /// # Arguments
45    /// * `req` - Request with variety, start_month, end_month, and trade_type
46    /// * `opts` - Optional request options
47    pub async fn get_phase_ranking(
48        &self,
49        req: &PhaseRankingRequest,
50        opts: Option<RequestOptions>,
51    ) -> Result<Vec<PhaseRanking>> {
52        self.client.do_post(PATH_GET_PHASE_RANKING, req, opts).await
53    }
54}