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 working orders
18 async fn get_working_orders(&self, session: &IgSession) -> Result<WorkingOrders, AppError>;
19
20 /// Gets account activity
21 ///
22 /// # Arguments
23 /// * `session` - The current session
24 /// * `from` - Start date in ISO format (e.g. "2023-01-01T00:00:00Z")
25 /// * `to` - End date in ISO format (e.g. "2023-02-01T00:00:00Z")
26 ///
27 /// # Returns
28 /// * Account activity for the specified period
29 async fn get_activity(
30 &self,
31 session: &IgSession,
32 from: &str,
33 to: &str,
34 ) -> Result<AccountActivity, AppError>;
35
36 /// Gets detailed account activity
37 ///
38 /// This method includes additional details for each activity item by using
39 /// the detailed=true parameter in the API request.
40 ///
41 /// # Arguments
42 /// * `session` - The current session
43 /// * `from` - Start date in ISO format (e.g. "2023-01-01T00:00:00Z")
44 /// * `to` - End date in ISO format (e.g. "2023-02-01T00:00:00Z")
45 ///
46 /// # Returns
47 /// * Detailed account activity for the specified period
48 async fn get_activity_with_details(
49 &self,
50 session: &IgSession,
51 from: &str,
52 to: &str,
53 ) -> Result<AccountActivity, AppError>;
54
55 /// Gets transaction history
56 async fn get_transactions(
57 &self,
58 session: &IgSession,
59 from: &str,
60 to: &str,
61 page_size: u32,
62 page_number: u32,
63 ) -> Result<TransactionHistory, AppError>;
64}