ib_client/apis/
account_api.rs1use reqwest;
13
14use crate::apis::ResponseContent;
15use super::{Error, configuration};
16
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum IserverAccountPnlPartitionedGetError {
22 UnknownValue(serde_json::Value),
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum IserverAccountPostError {
29 UnknownValue(serde_json::Value),
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum IserverAccountsGetError {
36 UnknownValue(serde_json::Value),
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum PortfolioAccountIdLedgerGetError {
43 UnknownValue(serde_json::Value),
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum PortfolioAccountIdMetaGetError {
50 UnknownValue(serde_json::Value),
51}
52
53#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum PortfolioAccountIdSummaryGetError {
57 UnknownValue(serde_json::Value),
58}
59
60#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum PortfolioAccountsGetError {
64 UnknownValue(serde_json::Value),
65}
66
67#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum PortfolioSubaccountsGetError {
71 UnknownValue(serde_json::Value),
72}
73
74
75pub async fn iserver_account_pnl_partitioned_get(configuration: &configuration::Configuration, ) -> Result<crate::models::InlineResponse20025, Error<IserverAccountPnlPartitionedGetError>> {
77
78 let local_var_client = &configuration.client;
79
80 let local_var_uri_str = format!("{}/iserver/account/pnl/partitioned", configuration.base_path);
81 let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
82
83 if let Some(ref local_var_user_agent) = configuration.user_agent {
84 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
85 }
86
87 let local_var_req = local_var_req_builder.build()?;
88 let local_var_resp = local_var_client.execute(local_var_req).await?;
89
90 let local_var_status = local_var_resp.status();
91 let local_var_content = local_var_resp.text().await?;
92
93 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
94 serde_json::from_str(&local_var_content).map_err(Error::from)
95 } else {
96 let local_var_entity: Option<IserverAccountPnlPartitionedGetError> = serde_json::from_str(&local_var_content).ok();
97 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
98 Err(Error::ResponseError(local_var_error))
99 }
100}
101
102pub async fn iserver_account_post(configuration: &configuration::Configuration, body: crate::models::SetAccount) -> Result<crate::models::InlineResponse2007, Error<IserverAccountPostError>> {
104
105 let local_var_client = &configuration.client;
106
107 let local_var_uri_str = format!("{}/iserver/account", configuration.base_path);
108 let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str());
109
110 if let Some(ref local_var_user_agent) = configuration.user_agent {
111 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
112 }
113 local_var_req_builder = local_var_req_builder.json(&body);
114
115 let local_var_req = local_var_req_builder.build()?;
116 let local_var_resp = local_var_client.execute(local_var_req).await?;
117
118 let local_var_status = local_var_resp.status();
119 let local_var_content = local_var_resp.text().await?;
120
121 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
122 serde_json::from_str(&local_var_content).map_err(Error::from)
123 } else {
124 let local_var_entity: Option<IserverAccountPostError> = serde_json::from_str(&local_var_content).ok();
125 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
126 Err(Error::ResponseError(local_var_error))
127 }
128}
129
130pub async fn iserver_accounts_get(configuration: &configuration::Configuration, ) -> Result<crate::models::InlineResponse2006, Error<IserverAccountsGetError>> {
132
133 let local_var_client = &configuration.client;
134
135 let local_var_uri_str = format!("{}/iserver/accounts", configuration.base_path);
136 let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
137
138 if let Some(ref local_var_user_agent) = configuration.user_agent {
139 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
140 }
141
142 let local_var_req = local_var_req_builder.build()?;
143 let local_var_resp = local_var_client.execute(local_var_req).await?;
144
145 let local_var_status = local_var_resp.status();
146 let local_var_content = local_var_resp.text().await?;
147
148 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
149 serde_json::from_str(&local_var_content).map_err(Error::from)
150 } else {
151 let local_var_entity: Option<IserverAccountsGetError> = serde_json::from_str(&local_var_content).ok();
152 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
153 Err(Error::ResponseError(local_var_error))
154 }
155}
156
157pub async fn portfolio_account_id_ledger_get(configuration: &configuration::Configuration, account_id: &str) -> Result<crate::models::InlineResponse20030, Error<PortfolioAccountIdLedgerGetError>> {
159
160 let local_var_client = &configuration.client;
161
162 let local_var_uri_str = format!("{}/portfolio/{accountId}/ledger", configuration.base_path, accountId=crate::apis::urlencode(account_id));
163 let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
164
165 if let Some(ref local_var_user_agent) = configuration.user_agent {
166 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
167 }
168
169 let local_var_req = local_var_req_builder.build()?;
170 let local_var_resp = local_var_client.execute(local_var_req).await?;
171
172 let local_var_status = local_var_resp.status();
173 let local_var_content = local_var_resp.text().await?;
174
175 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
176 serde_json::from_str(&local_var_content).map_err(Error::from)
177 } else {
178 let local_var_entity: Option<PortfolioAccountIdLedgerGetError> = serde_json::from_str(&local_var_content).ok();
179 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
180 Err(Error::ResponseError(local_var_error))
181 }
182}
183
184pub async fn portfolio_account_id_meta_get(configuration: &configuration::Configuration, account_id: &str) -> Result<Vec<crate::models::Account>, Error<PortfolioAccountIdMetaGetError>> {
186
187 let local_var_client = &configuration.client;
188
189 let local_var_uri_str = format!("{}/portfolio/{accountId}/meta", configuration.base_path, accountId=crate::apis::urlencode(account_id));
190 let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
191
192 if let Some(ref local_var_user_agent) = configuration.user_agent {
193 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
194 }
195
196 let local_var_req = local_var_req_builder.build()?;
197 let local_var_resp = local_var_client.execute(local_var_req).await?;
198
199 let local_var_status = local_var_resp.status();
200 let local_var_content = local_var_resp.text().await?;
201
202 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
203 serde_json::from_str(&local_var_content).map_err(Error::from)
204 } else {
205 let local_var_entity: Option<PortfolioAccountIdMetaGetError> = serde_json::from_str(&local_var_content).ok();
206 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
207 Err(Error::ResponseError(local_var_error))
208 }
209}
210
211pub async fn portfolio_account_id_summary_get(configuration: &configuration::Configuration, account_id: &str) -> Result<crate::models::InlineResponse20029, Error<PortfolioAccountIdSummaryGetError>> {
213
214 let local_var_client = &configuration.client;
215
216 let local_var_uri_str = format!("{}/portfolio/{accountId}/summary", configuration.base_path, accountId=crate::apis::urlencode(account_id));
217 let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
218
219 if let Some(ref local_var_user_agent) = configuration.user_agent {
220 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
221 }
222
223 let local_var_req = local_var_req_builder.build()?;
224 let local_var_resp = local_var_client.execute(local_var_req).await?;
225
226 let local_var_status = local_var_resp.status();
227 let local_var_content = local_var_resp.text().await?;
228
229 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
230 serde_json::from_str(&local_var_content).map_err(Error::from)
231 } else {
232 let local_var_entity: Option<PortfolioAccountIdSummaryGetError> = serde_json::from_str(&local_var_content).ok();
233 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
234 Err(Error::ResponseError(local_var_error))
235 }
236}
237
238pub async fn portfolio_accounts_get(configuration: &configuration::Configuration, ) -> Result<Vec<crate::models::Account>, Error<PortfolioAccountsGetError>> {
240
241 let local_var_client = &configuration.client;
242
243 let local_var_uri_str = format!("{}/portfolio/accounts", configuration.base_path);
244 let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
245
246 if let Some(ref local_var_user_agent) = configuration.user_agent {
247 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
248 }
249
250 let local_var_req = local_var_req_builder.build()?;
251 let local_var_resp = local_var_client.execute(local_var_req).await?;
252
253 let local_var_status = local_var_resp.status();
254 let local_var_content = local_var_resp.text().await?;
255
256 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
257 serde_json::from_str(&local_var_content).map_err(Error::from)
258 } else {
259 let local_var_entity: Option<PortfolioAccountsGetError> = serde_json::from_str(&local_var_content).ok();
260 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
261 Err(Error::ResponseError(local_var_error))
262 }
263}
264
265pub async fn portfolio_subaccounts_get(configuration: &configuration::Configuration, ) -> Result<crate::models::Account, Error<PortfolioSubaccountsGetError>> {
267
268 let local_var_client = &configuration.client;
269
270 let local_var_uri_str = format!("{}/portfolio/subaccounts", configuration.base_path);
271 let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
272
273 if let Some(ref local_var_user_agent) = configuration.user_agent {
274 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
275 }
276
277 let local_var_req = local_var_req_builder.build()?;
278 let local_var_resp = local_var_client.execute(local_var_req).await?;
279
280 let local_var_status = local_var_resp.status();
281 let local_var_content = local_var_resp.text().await?;
282
283 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
284 serde_json::from_str(&local_var_content).map_err(Error::from)
285 } else {
286 let local_var_entity: Option<PortfolioSubaccountsGetError> = serde_json::from_str(&local_var_content).ok();
287 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
288 Err(Error::ResponseError(local_var_error))
289 }
290}
291