1mod builder;
20pub(crate) mod http;
21
22pub use builder::IgClientBuilder;
23
24use std::sync::Arc;
25
26use crate::accounts::AccountsApi;
27use crate::client_sentiment::ClientSentimentApi;
28use crate::config::IgConfig;
29use crate::dealing::DealingApi;
30use crate::history::HistoryApi;
31use crate::markets::MarketsApi;
32use crate::operations::OperationsApi;
33use crate::prices::PricesApi;
34use crate::repeat_dealing::RepeatDealingApi;
35use crate::session::{Credentials, SessionApi, SessionHandle, SharedSession};
36#[cfg(feature = "stream")]
37use crate::streaming::client::StreamingApi;
38use crate::watchlists::WatchlistsApi;
39
40use http::Transport;
41
42#[derive(Debug, Clone)]
45pub struct IgClient {
46 pub(crate) transport: Transport,
47 pub(crate) session: SharedSession,
48 pub(crate) credentials: Option<Credentials>,
49 pub(crate) config: Arc<IgConfig>,
50}
51
52impl IgClient {
53 pub fn builder() -> IgClientBuilder {
54 IgClientBuilder::default()
55 }
56
57 pub fn config(&self) -> &IgConfig {
59 &self.config
60 }
61
62 pub fn accounts(&self) -> AccountsApi<'_> {
64 AccountsApi { client: self }
65 }
66
67 pub fn client_sentiment(&self) -> ClientSentimentApi<'_> {
69 ClientSentimentApi { client: self }
70 }
71
72 pub fn dealing(&self) -> DealingApi<'_> {
74 DealingApi::new(self)
75 }
76
77 pub fn history(&self) -> HistoryApi<'_> {
79 HistoryApi { client: self }
80 }
81
82 pub fn markets(&self) -> MarketsApi<'_> {
84 MarketsApi { client: self }
85 }
86
87 pub fn operations(&self) -> OperationsApi<'_> {
89 OperationsApi { client: self }
90 }
91
92 pub fn prices(&self) -> PricesApi<'_> {
94 PricesApi { client: self }
95 }
96
97 pub fn repeat_dealing(&self) -> RepeatDealingApi<'_> {
99 RepeatDealingApi { client: self }
100 }
101
102 pub fn session(&self) -> SessionApi {
104 SessionApi {
105 handle: SessionHandle {
106 transport: self.transport.clone(),
107 session: self.session.clone(),
108 credentials: self.credentials.clone(),
109 },
110 }
111 }
112
113 pub fn watchlists(&self) -> WatchlistsApi<'_> {
115 WatchlistsApi { client: self }
116 }
117
118 #[cfg(feature = "stream")]
123 #[cfg_attr(docsrs, doc(cfg(feature = "stream")))]
124 pub fn streaming(&self) -> StreamingApi<'_> {
125 StreamingApi { client: self }
126 }
127}