ig_client/application/services/interfaces/
account.rs

1use crate::application::models::account::{
2    AccountActivity, AccountInfo, Positions, TransactionHistory, WorkingOrders,
3};
4use crate::error::AppError;
5use crate::session::interface::IgSession;
6use async_trait::async_trait;
7
8/// Interface for the account service
9#[async_trait]
10pub trait AccountService: Send + Sync {
11    /// Gets information about all user accounts
12    async fn get_accounts(&self, session: &IgSession) -> Result<AccountInfo, AppError>;
13
14    /// Gets open positions
15    async fn get_positions(&self, session: &IgSession) -> Result<Positions, AppError>;
16
17    /// Gets open positions base in filter
18    async fn get_positions_w_filter(
19        &self,
20        filter: &str,
21        session: &IgSession,
22    ) -> Result<Positions, AppError>;
23
24    /// Gets working orders
25    async fn get_working_orders(&self, session: &IgSession) -> Result<WorkingOrders, AppError>;
26
27    /// Gets account activity
28    ///
29    /// # Arguments
30    /// * `session` - The current session
31    /// * `from` - Start date in ISO format (e.g. "2023-01-01T00:00:00Z")
32    /// * `to` - End date in ISO format (e.g. "2023-02-01T00:00:00Z")
33    ///
34    /// # Returns
35    /// * Account activity for the specified period
36    async fn get_activity(
37        &self,
38        session: &IgSession,
39        from: &str,
40        to: &str,
41    ) -> Result<AccountActivity, AppError>;
42
43    /// Gets detailed account activity
44    ///
45    /// This method includes additional details for each activity item by using
46    /// the detailed=true parameter in the API request.
47    ///
48    /// # Arguments
49    /// * `session` - The current session
50    /// * `from` - Start date in ISO format (e.g. "2023-01-01T00:00:00Z")
51    /// * `to` - End date in ISO format (e.g. "2023-02-01T00:00:00Z")
52    ///
53    /// # Returns
54    /// * Detailed account activity for the specified period
55    async fn get_activity_with_details(
56        &self,
57        session: &IgSession,
58        from: &str,
59        to: &str,
60    ) -> Result<AccountActivity, AppError>;
61
62    /// Gets transaction history for a given period, handling pagination automatically.
63    async fn get_transactions(
64        &self,
65        session: &IgSession,
66        from: &str,
67        to: &str,
68    ) -> Result<TransactionHistory, AppError>;
69}