Skip to main content

bezant_api/generated/
client.rs

1//!
2//! AUTO-GENERATED CODE - DO NOT EDIT!
3//!
4//! IB REST API
5//! Source: crates/bezant-spec/ibkr-openapi-3.1.json
6//! Version: 2.29.0
7//! Generated by `oas3-gen v0.25.3`
8//!
9//! The IB REST API reference documentation
10
11use super::types::*;
12use anyhow::Context;
13use reqwest::{Client, Url};
14use validator::Validate;
15pub const BASE_URL: &str = "https://api.ibkr.com";
16#[derive(Debug, Clone)]
17pub struct IbRestApiClient {
18    pub client: Client,
19    pub base_url: Url,
20}
21impl Default for IbRestApiClient {
22    fn default() -> Self {
23        Self::new()
24    }
25}
26impl IbRestApiClient {
27    /// Create a client using the OpenAPI `servers[0]` URL.
28    #[must_use]
29    #[track_caller]
30    pub fn new() -> Self {
31        Self {
32            client: Client::builder().build().expect("client"),
33            base_url: Url::parse(BASE_URL).expect("valid base url"),
34        }
35    }
36    /// Create a client with a custom base URL.
37    pub fn with_base_url(base_url: impl AsRef<str>) -> anyhow::Result<Self> {
38        Ok(Self {
39            client: Client::builder()
40                .build()
41                .context("building reqwest client")?,
42            base_url: Url::parse(base_url.as_ref()).context("parsing base url")?,
43        })
44    }
45    /// Create a client from an existing `reqwest::Client`.
46    pub fn with_client(base_url: impl AsRef<str>, client: Client) -> anyhow::Result<Self> {
47        let url = Url::parse(base_url.as_ref()).context("parsing base url")?;
48        Ok(Self {
49            client,
50            base_url: url,
51        })
52    }
53    /// List Account Signatures And Owners
54    ///
55    /// Receive a list of all applicant names on the account and for which account and entity is represented.
56    ///
57    /// * Path: `GET /acesws/{accountId}/signatures-and-owners`
58    pub async fn get_account_owners(
59        &self,
60        request: GetAccountOwnersRequest,
61    ) -> anyhow::Result<GetAccountOwnersResponse> {
62        request.validate().context("parameter validation")?;
63        let mut url = self.base_url.clone();
64        url.path_segments_mut()
65            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
66            .push("acesws")
67            .push(&request.path.account_id.to_string())
68            .push("signatures-and-owners");
69        let response = self.client.get(url).send().await?;
70        Ok(GetAccountOwnersRequest::parse_response(response).await?)
71    }
72    /// Trading Schedule (NEW)
73    ///
74    /// Returns the trading schedule for the 6 total days surrounding the current trading day. Non-Trading days, such as holidays, will not be returned.
75    ///
76    /// * Path: `GET /contract/trading-schedule`
77    pub async fn get_trading_schedule(
78        &self,
79        request: GetTradingScheduleRequest,
80    ) -> anyhow::Result<GetTradingScheduleResponse> {
81        request.validate().context("parameter validation")?;
82        let mut url = self.base_url.clone();
83        url.path_segments_mut()
84            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
85            .push("contract")
86            .push("trading-schedule");
87        let response = self.client.get(url).query(&request.query).send().await?;
88        Ok(GetTradingScheduleRequest::parse_response(response).await?)
89    }
90    /// Get Model Preset
91    ///
92    /// Get the preset behavior for model rebalancing.
93    ///
94    /// * Path: `POST /fa/fa-preset/get`
95    pub async fn get_model_presets(
96        &self,
97        request: GetModelPresetsRequest,
98    ) -> anyhow::Result<GetModelPresetsResponse> {
99        request.validate().context("parameter validation")?;
100        let mut url = self.base_url.clone();
101        url.path_segments_mut()
102            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
103            .push("fa")
104            .push("fa-preset")
105            .push("get");
106        let response = self.client.post(url).json(&request.body).send().await?;
107        Ok(GetModelPresetsRequest::parse_response(response).await?)
108    }
109    /// Set Model Preset
110    ///
111    /// Set the preset behavior for models.
112    ///
113    /// * Path: `POST /fa/fa-preset/save`
114    pub async fn set_model_presets(
115        &self,
116        request: SetModelPresetsRequest,
117    ) -> anyhow::Result<SetModelPresetsResponse> {
118        request.validate().context("parameter validation")?;
119        let mut url = self.base_url.clone();
120        url.path_segments_mut()
121            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
122            .push("fa")
123            .push("fa-preset")
124            .push("save");
125        let response = self.client.post(url).json(&request.body).send().await?;
126        Ok(SetModelPresetsRequest::parse_response(response).await?)
127    }
128    /// Get Models Accounts
129    ///
130    /// Request all accounts held within a model.
131    ///
132    /// * Path: `POST /fa/model/accounts-details`
133    pub async fn get_accounts_in_model(
134        &self,
135        request: GetAccountsInModelRequest,
136    ) -> anyhow::Result<GetAccountsInModelResponse> {
137        request.validate().context("parameter validation")?;
138        let mut url = self.base_url.clone();
139        url.path_segments_mut()
140            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
141            .push("fa")
142            .push("model")
143            .push("accounts-details");
144        let response = self.client.post(url).json(&request.body).send().await?;
145        Ok(GetAccountsInModelRequest::parse_response(response).await?)
146    }
147    /// Invest Account Into Model
148    ///
149    /// Assign an account and the amount of cash to allocate into a model.
150    ///
151    /// * Path: `POST /fa/model/invest-divest`
152    pub async fn set_accountinvestment_in_model(
153        &self,
154        request: SetAccountinvestmentInModelRequest,
155    ) -> anyhow::Result<SetAccountinvestmentInModelResponse> {
156        request.validate().context("parameter validation")?;
157        let mut url = self.base_url.clone();
158        url.path_segments_mut()
159            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
160            .push("fa")
161            .push("model")
162            .push("invest-divest");
163        let response = self.client.post(url).json(&request.body).send().await?;
164        Ok(SetAccountinvestmentInModelRequest::parse_response(response).await?)
165    }
166    /// Summary Of Accounts Invested In The Model
167    ///
168    /// Request the list of all accounts already invested in the provided model and a summary of their investment.
169    ///
170    /// * Path: `POST /fa/model/invest-divest-positions`
171    pub async fn get_invested_accounts_in_model(
172        &self,
173        request: GetInvestedAccountsInModelRequest,
174    ) -> anyhow::Result<GetInvestedAccountsInModelResponse> {
175        request.validate().context("parameter validation")?;
176        let mut url = self.base_url.clone();
177        url.path_segments_mut()
178            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
179            .push("fa")
180            .push("model")
181            .push("invest-divest-positions");
182        let response = self.client.post(url).json(&request.body).send().await?;
183        Ok(GetInvestedAccountsInModelRequest::parse_response(response).await?)
184    }
185    /// Request All Models
186    ///
187    /// Retrieve summaries for all models under the advisor account.
188    ///
189    /// * Path: `POST /fa/model/list`
190    pub async fn get_allmodels(
191        &self,
192        request: GetAllmodelsRequest,
193    ) -> anyhow::Result<GetAllmodelsResponse> {
194        request.validate().context("parameter validation")?;
195        let mut url = self.base_url.clone();
196        url.path_segments_mut()
197            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
198            .push("fa")
199            .push("model")
200            .push("list");
201        let response = self.client.post(url).json(&request.body).send().await?;
202        Ok(GetAllmodelsRequest::parse_response(response).await?)
203    }
204    /// Request Model Positions
205    ///
206    /// Request all positions held within the model.
207    ///
208    /// * Path: `POST /fa/model/positions`
209    pub async fn get_all_model_positions(
210        &self,
211        request: GetAllModelPositionsRequest,
212    ) -> anyhow::Result<GetAllModelPositionsResponse> {
213        request.validate().context("parameter validation")?;
214        let mut url = self.base_url.clone();
215        url.path_segments_mut()
216            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
217            .push("fa")
218            .push("model")
219            .push("positions");
220        let response = self.client.post(url).json(&request.body).send().await?;
221        Ok(GetAllModelPositionsRequest::parse_response(response).await?)
222    }
223    /// Set Model Allocations
224    ///
225    /// Create or Modify a model's target positions.
226    ///
227    /// * Path: `POST /fa/model/save`
228    pub async fn set_model_target_positions(
229        &self,
230        request: SetModelTargetPositionsRequest,
231    ) -> anyhow::Result<SetModelTargetPositionsResponse> {
232        request.validate().context("parameter validation")?;
233        let mut url = self.base_url.clone();
234        url.path_segments_mut()
235            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
236            .push("fa")
237            .push("model")
238            .push("save");
239        let response = self.client.post(url).json(&request.body).send().await?;
240        Ok(SetModelTargetPositionsRequest::parse_response(response).await?)
241    }
242    /// Submit Transfers
243    ///
244    /// Submit all pending orders to the models. This is similar to the Model page's Submit All Orders selection.
245    ///
246    /// * Path: `POST /fa/model/submit-transfers`
247    pub async fn submit_model_orders(
248        &self,
249        request: SubmitModelOrdersRequest,
250    ) -> anyhow::Result<SubmitModelOrdersResponse> {
251        request.validate().context("parameter validation")?;
252        let mut url = self.base_url.clone();
253        url.path_segments_mut()
254            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
255            .push("fa")
256            .push("model")
257            .push("submit-transfers");
258        let response = self.client.post(url).json(&request.body).send().await?;
259        Ok(SubmitModelOrdersRequest::parse_response(response).await?)
260    }
261    /// Request Model Summary
262    ///
263    /// Request a summary for a single model.
264    ///
265    /// * Path: `POST /fa/model/summary`
266    pub async fn get_model_summary_single(
267        &self,
268        request: GetModelSummarySingleRequest,
269    ) -> anyhow::Result<GetModelSummarySingleResponse> {
270        request.validate().context("parameter validation")?;
271        let mut url = self.base_url.clone();
272        url.path_segments_mut()
273            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
274            .push("fa")
275            .push("model")
276            .push("summary");
277        let response = self.client.post(url).json(&request.body).send().await?;
278        Ok(GetModelSummarySingleRequest::parse_response(response).await?)
279    }
280    /// Event Contract Categories
281    ///
282    /// Returns the category names, parent ids, and markets for Event Contracts.
283    ///
284    /// * Path: `GET /forecast/category/tree`
285    pub async fn get_forecast_categories(
286        &self,
287        request: GetForecastCategoriesRequest,
288    ) -> anyhow::Result<GetForecastCategoriesResponse> {
289        request.validate().context("parameter validation")?;
290        let mut url = self.base_url.clone();
291        url.path_segments_mut()
292            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
293            .push("forecast")
294            .push("category")
295            .push("tree");
296        let response = self.client.get(url).send().await?;
297        Ok(GetForecastCategoriesRequest::parse_response(response).await?)
298    }
299    /// Event Contract Details
300    ///
301    /// Provides instrument details for the specific forecast contract.
302    ///
303    /// * Path: `GET /forecast/contract/details`
304    pub async fn get_forecast_contract(
305        &self,
306        request: GetForecastContractRequest,
307    ) -> anyhow::Result<GetForecastContractResponse> {
308        request.validate().context("parameter validation")?;
309        let mut url = self.base_url.clone();
310        url.path_segments_mut()
311            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
312            .push("forecast")
313            .push("contract")
314            .push("details");
315        let response = self.client.get(url).query(&request.query).send().await?;
316        Ok(GetForecastContractRequest::parse_response(response).await?)
317    }
318    /// Provides All Contracts For Given Underlying Market.
319    ///
320    /// Returns all high level contract details affiliated with the underlying market conid provided.
321    ///
322    /// * Path: `GET /forecast/contract/market`
323    pub async fn get_forecast_markets(
324        &self,
325        request: GetForecastMarketsRequest,
326    ) -> anyhow::Result<GetForecastMarketsResponse> {
327        request.validate().context("parameter validation")?;
328        let mut url = self.base_url.clone();
329        url.path_segments_mut()
330            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
331            .push("forecast")
332            .push("contract")
333            .push("market");
334        let response = self.client.get(url).query(&request.query).send().await?;
335        Ok(GetForecastMarketsRequest::parse_response(response).await?)
336    }
337    /// Event Contract Rules
338    ///
339    /// Provides trading rules for specific event contracts.
340    ///
341    /// * Path: `GET /forecast/contract/rules`
342    pub async fn get_forecast_rules(
343        &self,
344        request: GetForecastRulesRequest,
345    ) -> anyhow::Result<GetForecastRulesResponse> {
346        request.validate().context("parameter validation")?;
347        let mut url = self.base_url.clone();
348        url.path_segments_mut()
349            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
350            .push("forecast")
351            .push("contract")
352            .push("rules");
353        let response = self.client.get(url).query(&request.query).send().await?;
354        Ok(GetForecastRulesRequest::parse_response(response).await?)
355    }
356    /// Event Contract Schedules
357    ///
358    /// Provides forecast trading schedules.
359    ///
360    /// * Path: `GET /forecast/contract/schedules`
361    pub async fn get_forecast_schedule(
362        &self,
363        request: GetForecastScheduleRequest,
364    ) -> anyhow::Result<GetForecastScheduleResponse> {
365        request.validate().context("parameter validation")?;
366        let mut url = self.base_url.clone();
367        url.path_segments_mut()
368            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
369            .push("forecast")
370            .push("contract")
371            .push("schedules");
372        let response = self.client.get(url).query(&request.query).send().await?;
373        Ok(GetForecastScheduleRequest::parse_response(response).await?)
374    }
375    /// Get Delivery Options
376    ///
377    /// Options for sending fyis to email and other devices.
378    ///
379    /// * Path: `GET /fyi/deliveryoptions`
380    pub async fn get_fyi_delivery(
381        &self,
382        request: GetFyiDeliveryRequest,
383    ) -> anyhow::Result<GetFyiDeliveryResponse> {
384        request.validate().context("parameter validation")?;
385        let mut url = self.base_url.clone();
386        url.path_segments_mut()
387            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
388            .push("fyi")
389            .push("deliveryoptions");
390        let response = self.client.get(url).send().await?;
391        Ok(GetFyiDeliveryRequest::parse_response(response).await?)
392    }
393    /// Toggle Delivery To A Device
394    ///
395    /// Choose whether a particular device is enabled or disabled.
396    ///
397    /// * Path: `POST /fyi/deliveryoptions/device`
398    pub async fn modify_fyi_delivery(
399        &self,
400        request: ModifyFyiDeliveryRequest,
401    ) -> anyhow::Result<ModifyFyiDeliveryResponse> {
402        request.validate().context("parameter validation")?;
403        let mut url = self.base_url.clone();
404        url.path_segments_mut()
405            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
406            .push("fyi")
407            .push("deliveryoptions")
408            .push("device");
409        let response = self.client.post(url).json(&request.body).send().await?;
410        Ok(ModifyFyiDeliveryRequest::parse_response(response).await?)
411    }
412    /// Toggle Email Delivery
413    ///
414    /// Enable or disable your account's primary email to receive notifications.
415    ///
416    /// * Path: `PUT /fyi/deliveryoptions/email`
417    pub async fn modify_fyi_emails(
418        &self,
419        request: ModifyFyiEmailsRequest,
420    ) -> anyhow::Result<ModifyFyiEmailsResponse> {
421        request.validate().context("parameter validation")?;
422        let mut url = self.base_url.clone();
423        url.path_segments_mut()
424            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
425            .push("fyi")
426            .push("deliveryoptions")
427            .push("email");
428        let response = self.client.put(url).query(&request.query).send().await?;
429        Ok(ModifyFyiEmailsRequest::parse_response(response).await?)
430    }
431    /// Delete A Device
432    ///
433    /// Delete a specific device from our saved list of notification devices.
434    ///
435    /// * Path: `DELETE /fyi/deliveryoptions/{deviceId}`
436    pub async fn delete_fyi_device(
437        &self,
438        request: DeleteFyiDeviceRequest,
439    ) -> anyhow::Result<DeleteFyiDeviceResponse> {
440        request.validate().context("parameter validation")?;
441        let mut url = self.base_url.clone();
442        url.path_segments_mut()
443            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
444            .push("fyi")
445            .push("deliveryoptions")
446            .push(&request.path.device_id.to_string());
447        let response = self.client.delete(url).send().await?;
448        Ok(DeleteFyiDeviceRequest::parse_response(response).await?)
449    }
450    /// Get Disclaimers By FYI Type
451    ///
452    /// Receive additional disclaimers based on the specified typecode.
453    ///
454    /// * Path: `GET /fyi/disclaimer/{typecode}`
455    pub async fn get_fyi_disclaimerss(
456        &self,
457        request: GetFyiDisclaimerssRequest,
458    ) -> anyhow::Result<GetFyiDisclaimerssResponse> {
459        request.validate().context("parameter validation")?;
460        let mut url = self.base_url.clone();
461        url.path_segments_mut()
462            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
463            .push("fyi")
464            .push("disclaimer")
465            .push(&request.path.typecode.to_string());
466        let response = self.client.get(url).send().await?;
467        Ok(GetFyiDisclaimerssRequest::parse_response(response).await?)
468    }
469    /// Mark FYI Disclaimer Read
470    ///
471    /// Mark a specific disclaimer message as read.
472    ///
473    /// * Path: `PUT /fyi/disclaimer/{typecode}`
474    pub async fn read_fyi_disclaimer(
475        &self,
476        request: ReadFyiDisclaimerRequest,
477    ) -> anyhow::Result<ModifyFyiDeliveryResponse> {
478        request.validate().context("parameter validation")?;
479        let mut url = self.base_url.clone();
480        url.path_segments_mut()
481            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
482            .push("fyi")
483            .push("disclaimer")
484            .push(&request.path.typecode.to_string());
485        let response = self.client.put(url).send().await?;
486        Ok(ReadFyiDisclaimerRequest::parse_response(response).await?)
487    }
488    /// List All Notifications
489    ///
490    /// Get a list of available notifications.
491    ///
492    /// * Path: `GET /fyi/notifications`
493    pub async fn get_all_fyis(
494        &self,
495        request: GetAllFyisRequest,
496    ) -> anyhow::Result<GetAllFyisResponse> {
497        request.validate().context("parameter validation")?;
498        let mut url = self.base_url.clone();
499        url.path_segments_mut()
500            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
501            .push("fyi")
502            .push("notifications");
503        let response = self.client.get(url).query(&request.query).send().await?;
504        Ok(GetAllFyisRequest::parse_response(response).await?)
505    }
506    /// Mark Notification Read
507    ///
508    /// Mark a particular notification message as read or unread.
509    ///
510    /// * Path: `PUT /fyi/notifications/{notificationID}`
511    pub async fn read_fyi_notification(
512        &self,
513        request: ReadFyiNotificationRequest,
514    ) -> anyhow::Result<ReadFyiNotificationResponse> {
515        request.validate().context("parameter validation")?;
516        let mut url = self.base_url.clone();
517        url.path_segments_mut()
518            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
519            .push("fyi")
520            .push("notifications")
521            .push(&request.path.notification_id.to_string());
522        let response = self.client.put(url).send().await?;
523        Ok(ReadFyiNotificationRequest::parse_response(response).await?)
524    }
525    /// Get Notification Settings
526    ///
527    /// Return the current choices of subscriptions for notifications.
528    ///
529    /// * Path: `GET /fyi/settings`
530    pub async fn get_fyi_settings(
531        &self,
532        request: GetFyiSettingsRequest,
533    ) -> anyhow::Result<GetFyiSettingsResponse> {
534        request.validate().context("parameter validation")?;
535        let mut url = self.base_url.clone();
536        url.path_segments_mut()
537            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
538            .push("fyi")
539            .push("settings");
540        let response = self.client.get(url).send().await?;
541        Ok(GetFyiSettingsRequest::parse_response(response).await?)
542    }
543    /// Modify FYI Notifications
544    ///
545    /// Enable or disable group of notifications by the specific typecode.
546    ///
547    /// * Path: `POST /fyi/settings/{typecode}`
548    pub async fn modify_fyi_notification(
549        &self,
550        request: ModifyFyiNotificationRequest,
551    ) -> anyhow::Result<ModifyFyiEmailsResponse> {
552        request.validate().context("parameter validation")?;
553        let mut url = self.base_url.clone();
554        url.path_segments_mut()
555            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
556            .push("fyi")
557            .push("settings")
558            .push(&request.path.typecode.to_string());
559        let response = self.client.post(url).json(&request.body).send().await?;
560        Ok(ModifyFyiNotificationRequest::parse_response(response).await?)
561    }
562    /// Get Number Of Unread Notifications
563    ///
564    /// Returns the total number of unread notifications
565    ///
566    /// * Path: `GET /fyi/unreadnumber`
567    pub async fn get_unread_fyis(
568        &self,
569        request: GetUnreadFyisRequest,
570    ) -> anyhow::Result<GetUnreadFyisResponse> {
571        request.validate().context("parameter validation")?;
572        let mut url = self.base_url.clone();
573        url.path_segments_mut()
574            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
575            .push("fyi")
576            .push("unreadnumber");
577        let response = self.client.get(url).send().await?;
578        Ok(GetUnreadFyisRequest::parse_response(response).await?)
579    }
580    /// Retrieve Processed Application
581    ///
582    /// Retrieve the application request and IBKR response data based on IBKR accountId or externalId. Only available for accounts that originate via API<br><br>**Scope**: `accounts.read`<br>**Security Policy**: `HTTPS`
583    ///
584    /// * Path: `GET /gw/api/v1/accounts`
585    pub async fn get_gw_api_v1_accounts(
586        &self,
587        request: GetGwApiV1AccountsRequest,
588    ) -> anyhow::Result<GetGwApiV1AccountsResponse> {
589        request.validate().context("parameter validation")?;
590        let mut url = self.base_url.clone();
591        url.path_segments_mut()
592            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
593            .push("gw")
594            .push("api")
595            .push("v1")
596            .push("accounts");
597        let response = self.client.get(url).query(&request.query).send().await?;
598        Ok(GetGwApiV1AccountsRequest::parse_response(response).await?)
599    }
600    /// Create Account
601    ///
602    /// Submit account application. This will create brokerage account for the end user.<br><br>**Scope**: `accounts.write`<br>**Security Policy**: `Signed JWT`
603    ///
604    /// * Path: `POST /gw/api/v1/accounts`
605    pub async fn post_gw_api_v1_accounts(
606        &self,
607        request: PostGwApiV1AccountsRequest,
608    ) -> anyhow::Result<PostGwApiV1AccountsResponse> {
609        request.validate().context("parameter validation")?;
610        let mut url = self.base_url.clone();
611        url.path_segments_mut()
612            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
613            .push("gw")
614            .push("api")
615            .push("v1")
616            .push("accounts");
617        let response = self
618            .client
619            .post(url)
620            .body((&request.body).to_string())
621            .send()
622            .await?;
623        Ok(PostGwApiV1AccountsRequest::parse_response(response).await?)
624    }
625    /// Update Account
626    ///
627    /// Update information for an existing accountId<br><br>**Scope**: `accounts.write`<br>**Security Policy**: `Signed JWT`
628    ///
629    /// * Path: `PATCH /gw/api/v1/accounts`
630    pub async fn patch_gw_api_v1_accounts(
631        &self,
632        request: PatchGwApiV1AccountsRequest,
633    ) -> anyhow::Result<PostGwApiV1AccountsResponse> {
634        request.validate().context("parameter validation")?;
635        let mut url = self.base_url.clone();
636        url.path_segments_mut()
637            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
638            .push("gw")
639            .push("api")
640            .push("v1")
641            .push("accounts");
642        let response = self
643            .client
644            .patch(url)
645            .body((&request.body).to_string())
646            .send()
647            .await?;
648        Ok(PatchGwApiV1AccountsRequest::parse_response(response).await?)
649    }
650    /// Submit General Agreements And Disclosures
651    ///
652    /// Provides mechanism to submit Agreements and Disclosures to IBKR once a day instead of with each application. We store these documents on the servers and will use them for new application requests submitted that day.<ul><li>Documents will need to be submitted once a day (before the Applications are submitted). PDFs will be displayed and submitted as is- no changes/edits will be made to the actual PDF files.</li><li>This end-point will not process any Tax Form Documents. Tax Form document should be submitted with every application</li><li>If submitted in the morning, you only need to include the Tax Form attachment for each applicant. Otherwise, you will need to include PDFs with each application (Create Account).</li></ul><br><br>**Scope**: `accounts.write`<br>**Security Policy**: `Signed JWT`
653    ///
654    /// * Path: `POST /gw/api/v1/accounts/documents`
655    pub async fn post_gw_api_v1_accounts_documents(
656        &self,
657        request: PostGwApiV1AccountsDocumentsRequest,
658    ) -> anyhow::Result<PostGwApiV1AccountsResponse> {
659        request.validate().context("parameter validation")?;
660        let mut url = self.base_url.clone();
661        url.path_segments_mut()
662            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
663            .push("gw")
664            .push("api")
665            .push("v1")
666            .push("accounts")
667            .push("documents");
668        let response = self
669            .client
670            .post(url)
671            .body((&request.body).to_string())
672            .send()
673            .await?;
674        Ok(PostGwApiV1AccountsDocumentsRequest::parse_response(response).await?)
675    }
676    /// Get Login Messages
677    ///
678    /// Query all accounts associated with ‘Client ID’ that have incomplete login message<br><br>**Scope**: `accounts.read`<br>**Security Policy**: `HTTPS`
679    ///
680    /// * Path: `GET /gw/api/v1/accounts/login-messages`
681    pub async fn get_gw_api_v1_accounts_login_messages(
682        &self,
683        request: GetGwApiV1AccountsLoginMessagesRequest,
684    ) -> anyhow::Result<GetGwApiV1AccountsLoginMessagesResponse> {
685        request.validate().context("parameter validation")?;
686        let mut url = self.base_url.clone();
687        url.path_segments_mut()
688            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
689            .push("gw")
690            .push("api")
691            .push("v1")
692            .push("accounts")
693            .push("login-messages");
694        let response = self.client.get(url).query(&request.query).send().await?;
695        Ok(GetGwApiV1AccountsLoginMessagesRequest::parse_response(response).await?)
696    }
697    /// Get Status Of Accounts
698    ///
699    /// Query status of all accounts associated with ‘Client ID'<br><br>**Scope**: `accounts.read`<br>**Security Policy**: `HTTPS`
700    ///
701    /// * Path: `GET /gw/api/v1/accounts/status`
702    pub async fn get_gw_api_v1_accounts_status(
703        &self,
704        request: GetGwApiV1AccountsStatusRequest,
705    ) -> anyhow::Result<GetGwApiV1AccountsStatusResponse> {
706        request.validate().context("parameter validation")?;
707        let mut url = self.base_url.clone();
708        url.path_segments_mut()
709            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
710            .push("gw")
711            .push("api")
712            .push("v1")
713            .push("accounts")
714            .push("status");
715        let response = self.client.get(url).query(&request.query).send().await?;
716        Ok(GetGwApiV1AccountsStatusRequest::parse_response(response).await?)
717    }
718    /// Get Account Information
719    ///
720    /// <br>**Scope**: `accounts.read`<br>**Security Policy**: `HTTPS`
721    ///
722    /// * Path: `GET /gw/api/v1/accounts/{accountId}/details`
723    pub async fn get_gw_api_v1_accounts_accountid_details(
724        &self,
725        request: GetGwApiV1AccountsAccountidDetailsRequest,
726    ) -> anyhow::Result<GetGwApiV1AccountsAccountidDetailsResponse> {
727        request.validate().context("parameter validation")?;
728        let mut url = self.base_url.clone();
729        url.path_segments_mut()
730            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
731            .push("gw")
732            .push("api")
733            .push("v1")
734            .push("accounts")
735            .push(&request.path.account_id.to_string())
736            .push("details");
737        let response = self.client.get(url).send().await?;
738        Ok(GetGwApiV1AccountsAccountidDetailsRequest::parse_response(response).await?)
739    }
740    /// Retrieve Au10Tix URL
741    ///
742    /// Generate URL address to complete real-time KYC verification using Au10Tix<br><br>**Scope**: `accounts.read`<br>**Security Policy**: `HTTPS`
743    ///
744    /// * Path: `GET /gw/api/v1/accounts/{accountId}/kyc`
745    pub async fn get_gw_api_v1_accounts_accountid_kyc(
746        &self,
747        request: GetGwApiV1AccountsAccountidKycRequest,
748    ) -> anyhow::Result<GetGwApiV1AccountsAccountidKycResponse> {
749        request.validate().context("parameter validation")?;
750        let mut url = self.base_url.clone();
751        url.path_segments_mut()
752            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
753            .push("gw")
754            .push("api")
755            .push("v1")
756            .push("accounts")
757            .push(&request.path.account_id.to_string())
758            .push("kyc");
759        let response = self.client.get(url).send().await?;
760        Ok(GetGwApiV1AccountsAccountidKycRequest::parse_response(response).await?)
761    }
762    /// Get Login Message By Account
763    ///
764    /// Query login messages assigned by accountId<br><br>**Scope**: `accounts.read`<br>**Security Policy**: `HTTPS`
765    ///
766    /// * Path: `GET /gw/api/v1/accounts/{accountId}/login-messages`
767    pub async fn get_gw_api_v1_accounts_accountid_login_messages(
768        &self,
769        request: GetGwApiV1AccountsAccountidLoginMessagesRequest,
770    ) -> anyhow::Result<GetGwApiV1AccountsLoginMessagesResponse> {
771        request.validate().context("parameter validation")?;
772        let mut url = self.base_url.clone();
773        url.path_segments_mut()
774            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
775            .push("gw")
776            .push("api")
777            .push("v1")
778            .push("accounts")
779            .push(&request.path.account_id.to_string())
780            .push("login-messages");
781        let response = self.client.get(url).query(&request.query).send().await?;
782        Ok(GetGwApiV1AccountsAccountidLoginMessagesRequest::parse_response(response).await?)
783    }
784    /// Get Status By Account
785    ///
786    /// Query status of account by accountId<br><br>**Scope**: `accounts.read`<br>**Security Policy**: `HTTPS`
787    ///
788    /// * Path: `GET /gw/api/v1/accounts/{accountId}/status`
789    pub async fn get_gw_api_v1_accounts_accountid_status(
790        &self,
791        request: GetGwApiV1AccountsAccountidStatusRequest,
792    ) -> anyhow::Result<GetGwApiV1AccountsAccountidStatusResponse> {
793        request.validate().context("parameter validation")?;
794        let mut url = self.base_url.clone();
795        url.path_segments_mut()
796            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
797            .push("gw")
798            .push("api")
799            .push("v1")
800            .push("accounts")
801            .push(&request.path.account_id.to_string())
802            .push("status");
803        let response = self.client.get(url).send().await?;
804        Ok(GetGwApiV1AccountsAccountidStatusRequest::parse_response(response).await?)
805    }
806    /// Update Status By Account
807    ///
808    /// Query status of account by accountId<br><br>**Scope**: `accounts.write`<br>**Security Policy**: `Signed JWT`
809    ///
810    /// * Path: `PATCH /gw/api/v1/accounts/{accountId}/status`
811    pub async fn patch_gw_api_v1_accounts_accountid_status(
812        &self,
813        request: PatchGwApiV1AccountsAccountidStatusRequest,
814    ) -> anyhow::Result<GetGwApiV1AccountsAccountidStatusResponse> {
815        request.validate().context("parameter validation")?;
816        let mut url = self.base_url.clone();
817        url.path_segments_mut()
818            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
819            .push("gw")
820            .push("api")
821            .push("v1")
822            .push("accounts")
823            .push(&request.path.account_id.to_string())
824            .push("status");
825        let response = self
826            .client
827            .patch(url)
828            .body((&request.body).to_string())
829            .send()
830            .await?;
831        Ok(PatchGwApiV1AccountsAccountidStatusRequest::parse_response(response).await?)
832    }
833    /// Get Registration Tasks
834    ///
835    /// Query registration tasks assigned to account and pending tasks that are required for account approval<br><br>**Scope**: `accounts.read`<br>**Security Policy**: `HTTPS`
836    ///
837    /// * Path: `GET /gw/api/v1/accounts/{accountId}/tasks`
838    pub async fn get_gw_api_v1_accounts_accountid_tasks(
839        &self,
840        request: GetGwApiV1AccountsAccountidTasksRequest,
841    ) -> anyhow::Result<GetGwApiV1AccountsAccountidTasksResponse> {
842        request.validate().context("parameter validation")?;
843        let mut url = self.base_url.clone();
844        url.path_segments_mut()
845            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
846            .push("gw")
847            .push("api")
848            .push("v1")
849            .push("accounts")
850            .push(&request.path.account_id.to_string())
851            .push("tasks");
852        let response = self.client.get(url).query(&request.query).send().await?;
853        Ok(GetGwApiV1AccountsAccountidTasksRequest::parse_response(response).await?)
854    }
855    /// Assign Tasks
856    ///
857    /// Task can be assigned from this api<br><br>**Scope**: `accounts.write`<br>**Security Policy**: `Signed JWT`
858    ///
859    /// * Path: `POST /gw/api/v1/accounts/{accountId}/tasks`
860    pub async fn post_gw_api_v1_accounts_accountid_tasks(
861        &self,
862        request: PostGwApiV1AccountsAccountidTasksRequest,
863    ) -> anyhow::Result<PostGwApiV1AccountsAccountidTasksResponse> {
864        request.validate().context("parameter validation")?;
865        let mut url = self.base_url.clone();
866        url.path_segments_mut()
867            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
868            .push("gw")
869            .push("api")
870            .push("v1")
871            .push("accounts")
872            .push(&request.path.account_id.to_string())
873            .push("tasks");
874        let response = self
875            .client
876            .post(url)
877            .body((&request.body).to_string())
878            .send()
879            .await?;
880        Ok(PostGwApiV1AccountsAccountidTasksRequest::parse_response(response).await?)
881    }
882    /// Update Tasks Status
883    ///
884    /// Task status can be updated from this api<br><br>**Scope**: `accounts.write`<br>**Security Policy**: `Signed JWT`
885    ///
886    /// * Path: `PATCH /gw/api/v1/accounts/{accountId}/tasks`
887    pub async fn patch_gw_api_v1_accounts_accountid_tasks(
888        &self,
889        request: PatchGwApiV1AccountsAccountidTasksRequest,
890    ) -> anyhow::Result<PostGwApiV1AccountsAccountidTasksResponse> {
891        request.validate().context("parameter validation")?;
892        let mut url = self.base_url.clone();
893        url.path_segments_mut()
894            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
895            .push("gw")
896            .push("api")
897            .push("v1")
898            .push("accounts")
899            .push(&request.path.account_id.to_string())
900            .push("tasks");
901        let response = self
902            .client
903            .patch(url)
904            .body((&request.body).to_string())
905            .send()
906            .await?;
907        Ok(PatchGwApiV1AccountsAccountidTasksRequest::parse_response(response).await?)
908    }
909    /// View Cash Balances
910    ///
911    /// View available cash for withdrawal and account equity value by accountId<br><br>**Scope**: `balances.read`<br>**Security Policy**: `Signed JWT`
912    ///
913    /// * Path: `POST /gw/api/v1/balances/query`
914    pub async fn post_gw_api_v1_balances_query(
915        &self,
916        request: PostGwApiV1BalancesQueryRequest,
917    ) -> anyhow::Result<PostGwApiV1BalancesQueryResponse> {
918        request.validate().context("parameter validation")?;
919        let mut url = self.base_url.clone();
920        url.path_segments_mut()
921            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
922            .push("gw")
923            .push("api")
924            .push("v1")
925            .push("balances")
926            .push("query");
927        let response = self
928            .client
929            .post(url)
930            .query(&request.query)
931            .json(&request.body)
932            .send()
933            .await?;
934        Ok(PostGwApiV1BalancesQueryRequest::parse_response(response).await?)
935    }
936    /// Manage Bank Instructions
937    ///
938    /// Create or delete bank instructions by accountId. Only ACH and EDDA are supported for 'Create'.<br><br>**Scope**: `bank-instructions.write`<br>**Security Policy**: `Signed JWT`
939    ///
940    /// * Path: `POST /gw/api/v1/bank-instructions`
941    pub async fn post_gw_api_v1_bank_instructions(
942        &self,
943        request: PostGwApiV1BankInstructionsRequest,
944    ) -> anyhow::Result<PostGwApiV1BankInstructionsResponse> {
945        request.validate().context("parameter validation")?;
946        let mut url = self.base_url.clone();
947        url.path_segments_mut()
948            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
949            .push("gw")
950            .push("api")
951            .push("v1")
952            .push("bank-instructions");
953        let response = self
954            .client
955            .post(url)
956            .query(&request.query)
957            .json(&request.body)
958            .send()
959            .await?;
960        Ok(PostGwApiV1BankInstructionsRequest::parse_response(response).await?)
961    }
962    /// View Bank Instructions
963    ///
964    /// View active bank instructions for an accountId.<br><br>**Scope**: `bank-instructions.read`<br>**Security Policy**: `Signed JWT`
965    ///
966    /// * Path: `POST /gw/api/v1/bank-instructions/query`
967    pub async fn post_gw_api_v1_bank_instructions_query(
968        &self,
969        request: PostGwApiV1BankInstructionsQueryRequest,
970    ) -> anyhow::Result<PostGwApiV1BankInstructionsQueryResponse> {
971        request.validate().context("parameter validation")?;
972        let mut url = self.base_url.clone();
973        url.path_segments_mut()
974            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
975            .push("gw")
976            .push("api")
977            .push("v1")
978            .push("bank-instructions")
979            .push("query");
980        let response = self
981            .client
982            .post(url)
983            .query(&request.query)
984            .json(&request.body)
985            .send()
986            .await?;
987        Ok(PostGwApiV1BankInstructionsQueryRequest::parse_response(response).await?)
988    }
989    /// Creates Multiple Banking Instructions(ach, Delete, Micro-amount, Predefined-destination-instruction)
990    ///
991    /// <br>**Scope**: `bank-instructions.write`<br>**Security Policy**: `Signed JWT`
992    ///
993    /// * Path: `POST /gw/api/v1/bank-instructions:bulk`
994    pub async fn post_gw_api_v1_bank_instructions_bulk(
995        &self,
996        request: PostGwApiV1BankInstructionsBulkRequest,
997    ) -> anyhow::Result<PostGwApiV1BankInstructionsBulkResponse> {
998        request.validate().context("parameter validation")?;
999        let mut url = self.base_url.clone();
1000        url.path_segments_mut()
1001            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
1002            .push("gw")
1003            .push("api")
1004            .push("v1")
1005            .push("bank-instructions:bulk");
1006        let response = self
1007            .client
1008            .post(url)
1009            .query(&request.query)
1010            .json(&request.body)
1011            .send()
1012            .await?;
1013        Ok(PostGwApiV1BankInstructionsBulkRequest::parse_response(response).await?)
1014    }
1015    /// Get Status For ClientInstructionId
1016    ///
1017    /// Retrieve status of request by clientInstructionId.<br><br>**Scope**: `instructions.read`<br>**Security Policy**: `HTTPS`
1018    ///
1019    /// * Path: `GET /gw/api/v1/client-instructions/{clientInstructionId}`
1020    pub async fn get_gw_api_v1_client_instructions_clientinstructionid(
1021        &self,
1022        request: GetGwApiV1ClientInstructionsClientinstructionidRequest,
1023    ) -> anyhow::Result<GetGwApiV1InstructionsInstructionidResponse> {
1024        request.validate().context("parameter validation")?;
1025        let mut url = self.base_url.clone();
1026        url.path_segments_mut()
1027            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
1028            .push("gw")
1029            .push("api")
1030            .push("v1")
1031            .push("client-instructions")
1032            .push(&request.path.client_instruction_id.to_string());
1033        let response = self.client.get(url).query(&request.query).send().await?;
1034        Ok(
1035            GetGwApiV1ClientInstructionsClientinstructionidRequest::parse_response(response)
1036                .await?,
1037        )
1038    }
1039    /// Echo A Request With HTTPS Security Policy Back After Validation.
1040    ///
1041    /// <br>**Scope**: `echo.read`<br>**Security Policy**: `HTTPS`
1042    ///
1043    /// * Path: `GET /gw/api/v1/echo/https`
1044    pub async fn get_gw_api_v1_echo_https(
1045        &self,
1046        request: GetGwApiV1EchoHttpsRequest,
1047    ) -> anyhow::Result<GetGwApiV1EchoHttpsResponse> {
1048        request.validate().context("parameter validation")?;
1049        let mut url = self.base_url.clone();
1050        url.path_segments_mut()
1051            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
1052            .push("gw")
1053            .push("api")
1054            .push("v1")
1055            .push("echo")
1056            .push("https");
1057        let response = self.client.get(url).send().await?;
1058        Ok(GetGwApiV1EchoHttpsRequest::parse_response(response).await?)
1059    }
1060    /// Echo A Request With Signed JWT Security Policy Back After Validation.
1061    ///
1062    /// <br>**Scope**: `echo.write`<br>**Security Policy**: `Signed JWT`
1063    ///
1064    /// * Path: `POST /gw/api/v1/echo/signed-jwt`
1065    pub async fn post_gw_api_v1_echo_signed_jwt(
1066        &self,
1067        request: PostGwApiV1EchoSignedJwtRequest,
1068    ) -> anyhow::Result<GetGwApiV1EchoHttpsResponse> {
1069        request.validate().context("parameter validation")?;
1070        let mut url = self.base_url.clone();
1071        url.path_segments_mut()
1072            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
1073            .push("gw")
1074            .push("api")
1075            .push("v1")
1076            .push("echo")
1077            .push("signed-jwt");
1078        let response = self
1079            .client
1080            .post(url)
1081            .body((&request.body).to_string())
1082            .send()
1083            .await?;
1084        Ok(PostGwApiV1EchoSignedJwtRequest::parse_response(response).await?)
1085    }
1086    /// Get A List Of Participating Brokers For The Given Asset Type
1087    ///
1088    /// Get list of brokers supported for given asset transfer type<br><br>**Scope**: `enumerations.read`<br>**Security Policy**: `HTTPS`
1089    ///
1090    /// * Path: `GET /gw/api/v1/enumerations/complex-asset-transfer`
1091    pub async fn get_gw_api_v1_enumerations_complex_asset_transfer(
1092        &self,
1093        request: GetGwApiV1EnumerationsComplexAssetTransferRequest,
1094    ) -> anyhow::Result<GetGwApiV1EnumerationsComplexAssetTransferResponse> {
1095        request.validate().context("parameter validation")?;
1096        let mut url = self.base_url.clone();
1097        url.path_segments_mut()
1098            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
1099            .push("gw")
1100            .push("api")
1101            .push("v1")
1102            .push("enumerations")
1103            .push("complex-asset-transfer");
1104        let response = self.client.get(url).query(&request.query).send().await?;
1105        Ok(GetGwApiV1EnumerationsComplexAssetTransferRequest::parse_response(response).await?)
1106    }
1107    /// Get Enumerations
1108    ///
1109    /// Used to query list of enumerations for attributes included within extPositionsTransfers, occupation, employerBusiness, financialInformation, affiliationDetails, tradingPermissions, etc.<br><br>**Scope**: `accounts.read` OR `enumerations.read`<br>**Security Policy**: `HTTPS`
1110    ///
1111    /// * Path: `GET /gw/api/v1/enumerations/{enumerationType}`
1112    pub async fn get_gw_api_v1_enumerations_enumerationtype(
1113        &self,
1114        request: GetGwApiV1EnumerationsEnumerationtypeRequest,
1115    ) -> anyhow::Result<GetGwApiV1EnumerationsEnumerationtypeResponse> {
1116        request.validate().context("parameter validation")?;
1117        let mut url = self.base_url.clone();
1118        url.path_segments_mut()
1119            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
1120            .push("gw")
1121            .push("api")
1122            .push("v1")
1123            .push("enumerations")
1124            .push(&request.path.enumeration_type.to_string());
1125        let response = self.client.get(url).query(&request.query).send().await?;
1126        Ok(GetGwApiV1EnumerationsEnumerationtypeRequest::parse_response(response).await?)
1127    }
1128    /// Transfer Positions Externally (ACATS, ATON, FOP, DWAC, Complex Asset Transfer)
1129    ///
1130    /// Initiate request to submit external position transfer. Methods- ACATS, ATON, Basic FOP, FOP, DWAC. More information on transfer methods can be found here - https://www.interactivebrokers.com/campus/trading-lessons/cash-and-position-transfers/<br><br>**Scope**: `transfers.write`<br>**Security Policy**: `Signed JWT`
1131    ///
1132    /// * Path: `POST /gw/api/v1/external-asset-transfers`
1133    pub async fn post_gw_api_v1_external_asset_transfers(
1134        &self,
1135        request: PostGwApiV1ExternalAssetTransfersRequest,
1136    ) -> anyhow::Result<PostGwApiV1BankInstructionsResponse> {
1137        request.validate().context("parameter validation")?;
1138        let mut url = self.base_url.clone();
1139        url.path_segments_mut()
1140            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
1141            .push("gw")
1142            .push("api")
1143            .push("v1")
1144            .push("external-asset-transfers");
1145        let response = self
1146            .client
1147            .post(url)
1148            .query(&request.query)
1149            .json(&request.body)
1150            .send()
1151            .await?;
1152        Ok(PostGwApiV1ExternalAssetTransfersRequest::parse_response(response).await?)
1153    }
1154    /// Creates Multiple External Asset Transfers (Fop, DWAC And Complex Asset Transfer)
1155    ///
1156    /// <br>**Scope**: `transfers.write`<br>**Security Policy**: `Signed JWT`
1157    ///
1158    /// * Path: `POST /gw/api/v1/external-asset-transfers:bulk`
1159    pub async fn post_gw_api_v1_external_asset_transfers_bulk(
1160        &self,
1161        request: PostGwApiV1ExternalAssetTransfersBulkRequest,
1162    ) -> anyhow::Result<PostGwApiV1BankInstructionsBulkResponse> {
1163        request.validate().context("parameter validation")?;
1164        let mut url = self.base_url.clone();
1165        url.path_segments_mut()
1166            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
1167            .push("gw")
1168            .push("api")
1169            .push("v1")
1170            .push("external-asset-transfers:bulk");
1171        let response = self
1172            .client
1173            .post(url)
1174            .query(&request.query)
1175            .json(&request.body)
1176            .send()
1177            .await?;
1178        Ok(PostGwApiV1ExternalAssetTransfersBulkRequest::parse_response(response).await?)
1179    }
1180    /// Transfer Cash Externally
1181    ///
1182    /// Initiate request to deposit or withdrawal between IBKR account and bank account. More information on transfer methods can be found here - https://www.interactivebrokers.com/campus/trading-lessons/cash-and-position-transfers<br><br>**Scope**: `transfers.write`<br>**Security Policy**: `Signed JWT`
1183    ///
1184    /// * Path: `POST /gw/api/v1/external-cash-transfers`
1185    pub async fn post_gw_api_v1_external_cash_transfers(
1186        &self,
1187        request: PostGwApiV1ExternalCashTransfersRequest,
1188    ) -> anyhow::Result<PostGwApiV1BankInstructionsResponse> {
1189        request.validate().context("parameter validation")?;
1190        let mut url = self.base_url.clone();
1191        url.path_segments_mut()
1192            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
1193            .push("gw")
1194            .push("api")
1195            .push("v1")
1196            .push("external-cash-transfers");
1197        let response = self
1198            .client
1199            .post(url)
1200            .query(&request.query)
1201            .json(&request.body)
1202            .send()
1203            .await?;
1204        Ok(PostGwApiV1ExternalCashTransfersRequest::parse_response(response).await?)
1205    }
1206    /// View Cash Balances
1207    ///
1208    /// View available cash for withdrawal with and without margin loan by accountId<br><br>**Scope**: `transfers.read`<br>**Security Policy**: `Signed JWT`
1209    ///
1210    /// * Path: `POST /gw/api/v1/external-cash-transfers/query`
1211    pub async fn post_gw_api_v1_external_cash_transfers_query(
1212        &self,
1213        request: PostGwApiV1ExternalCashTransfersQueryRequest,
1214    ) -> anyhow::Result<PostGwApiV1ExternalCashTransfersQueryResponse> {
1215        request.validate().context("parameter validation")?;
1216        let mut url = self.base_url.clone();
1217        url.path_segments_mut()
1218            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
1219            .push("gw")
1220            .push("api")
1221            .push("v1")
1222            .push("external-cash-transfers")
1223            .push("query");
1224        let response = self
1225            .client
1226            .post(url)
1227            .query(&request.query)
1228            .json(&request.body)
1229            .send()
1230            .await?;
1231        Ok(PostGwApiV1ExternalCashTransfersQueryRequest::parse_response(response).await?)
1232    }
1233    /// Creates Multiple External Cash Transfers (Deposit And Withdraw Fund)
1234    ///
1235    /// <br>**Scope**: `transfers.write`<br>**Security Policy**: `Signed JWT`
1236    ///
1237    /// * Path: `POST /gw/api/v1/external-cash-transfers:bulk`
1238    pub async fn post_gw_api_v1_external_cash_transfers_bulk(
1239        &self,
1240        request: PostGwApiV1ExternalCashTransfersBulkRequest,
1241    ) -> anyhow::Result<PostGwApiV1BankInstructionsBulkResponse> {
1242        request.validate().context("parameter validation")?;
1243        let mut url = self.base_url.clone();
1244        url.path_segments_mut()
1245            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
1246            .push("gw")
1247            .push("api")
1248            .push("v1")
1249            .push("external-cash-transfers:bulk");
1250        let response = self
1251            .client
1252            .post(url)
1253            .query(&request.query)
1254            .json(&request.body)
1255            .send()
1256            .await?;
1257        Ok(PostGwApiV1ExternalCashTransfersBulkRequest::parse_response(response).await?)
1258    }
1259    /// Get Forms
1260    ///
1261    /// Get forms<br><br>**Scope**: `accounts.read` OR `forms.read`<br>**Security Policy**: `HTTPS`
1262    ///
1263    /// * Path: `GET /gw/api/v1/forms`
1264    pub async fn get_gw_api_v1_forms(
1265        &self,
1266        request: GetGwApiV1FormsRequest,
1267    ) -> anyhow::Result<GetGwApiV1FormsResponse> {
1268        request.validate().context("parameter validation")?;
1269        let mut url = self.base_url.clone();
1270        url.path_segments_mut()
1271            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
1272            .push("gw")
1273            .push("api")
1274            .push("v1")
1275            .push("forms");
1276        let response = self.client.get(url).query(&request.query).send().await?;
1277        Ok(GetGwApiV1FormsRequest::parse_response(response).await?)
1278    }
1279    /// Get Required Forms
1280    ///
1281    /// Get required forms<br><br>**Scope**: `accounts.read`<br>**Security Policy**: `HTTPS`
1282    ///
1283    /// * Path: `GET /gw/api/v1/forms/required-forms`
1284    pub async fn get_gw_api_v1_forms_required_forms(
1285        &self,
1286        request: GetGwApiV1FormsRequiredFormsRequest,
1287    ) -> anyhow::Result<GetGwApiV1FormsRequiredFormsResponse> {
1288        request.validate().context("parameter validation")?;
1289        let mut url = self.base_url.clone();
1290        url.path_segments_mut()
1291            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
1292            .push("gw")
1293            .push("api")
1294            .push("v1")
1295            .push("forms")
1296            .push("required-forms");
1297        let response = self.client.get(url).query(&request.query).send().await?;
1298        Ok(GetGwApiV1FormsRequiredFormsRequest::parse_response(response).await?)
1299    }
1300    /// Get Status For InstructionSetId
1301    ///
1302    /// Retrieve status of all requests associated with instructionSetId.<br><br>**Scope**: `instructions.read`<br>**Security Policy**: `HTTPS`
1303    ///
1304    /// * Path: `GET /gw/api/v1/instruction-sets/{instructionSetId}`
1305    pub async fn get_gw_api_v1_instruction_sets_instructionsetid(
1306        &self,
1307        request: GetGwApiV1InstructionSetsInstructionsetidRequest,
1308    ) -> anyhow::Result<GetGwApiV1InstructionSetsInstructionsetidResponse> {
1309        request.validate().context("parameter validation")?;
1310        let mut url = self.base_url.clone();
1311        url.path_segments_mut()
1312            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
1313            .push("gw")
1314            .push("api")
1315            .push("v1")
1316            .push("instruction-sets")
1317            .push(&request.path.instruction_set_id.to_string());
1318        let response = self.client.get(url).query(&request.query).send().await?;
1319        Ok(GetGwApiV1InstructionSetsInstructionsetidRequest::parse_response(response).await?)
1320    }
1321    /// Cancel Request
1322    ///
1323    /// Cancel request by instructionId.<br><br>**Scope**: `instructions.write`<br>**Security Policy**: `Signed JWT`
1324    ///
1325    /// * Path: `POST /gw/api/v1/instructions/cancel`
1326    pub async fn post_gw_api_v1_instructions_cancel(
1327        &self,
1328        request: PostGwApiV1InstructionsCancelRequest,
1329    ) -> anyhow::Result<PostGwApiV1InstructionsCancelResponse> {
1330        request.validate().context("parameter validation")?;
1331        let mut url = self.base_url.clone();
1332        url.path_segments_mut()
1333            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
1334            .push("gw")
1335            .push("api")
1336            .push("v1")
1337            .push("instructions")
1338            .push("cancel");
1339        let response = self
1340            .client
1341            .post(url)
1342            .query(&request.query)
1343            .json(&request.body)
1344            .send()
1345            .await?;
1346        Ok(PostGwApiV1InstructionsCancelRequest::parse_response(response).await?)
1347    }
1348    /// Creates Multiple Cancel Instructions
1349    ///
1350    /// <br>**Scope**: `instructions.write`<br>**Security Policy**: `Signed JWT`
1351    ///
1352    /// * Path: `POST /gw/api/v1/instructions/cancel:bulk`
1353    pub async fn post_gw_api_v1_instructions_cancel_bulk(
1354        &self,
1355        request: PostGwApiV1InstructionsCancelBulkRequest,
1356    ) -> anyhow::Result<PostGwApiV1BankInstructionsBulkResponse> {
1357        request.validate().context("parameter validation")?;
1358        let mut url = self.base_url.clone();
1359        url.path_segments_mut()
1360            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
1361            .push("gw")
1362            .push("api")
1363            .push("v1")
1364            .push("instructions")
1365            .push("cancel:bulk");
1366        let response = self
1367            .client
1368            .post(url)
1369            .query(&request.query)
1370            .json(&request.body)
1371            .send()
1372            .await?;
1373        Ok(PostGwApiV1InstructionsCancelBulkRequest::parse_response(response).await?)
1374    }
1375    /// Get Transaction History
1376    ///
1377    /// Query list of recent transactions (up to 30 days) based on accountId.<br><br>**Scope**: `instructions.read`<br>**Security Policy**: `Signed JWT`
1378    ///
1379    /// * Path: `POST /gw/api/v1/instructions/query`
1380    pub async fn post_gw_api_v1_instructions_query(
1381        &self,
1382        request: PostGwApiV1InstructionsQueryRequest,
1383    ) -> anyhow::Result<PostGwApiV1BankInstructionsResponse> {
1384        request.validate().context("parameter validation")?;
1385        let mut url = self.base_url.clone();
1386        url.path_segments_mut()
1387            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
1388            .push("gw")
1389            .push("api")
1390            .push("v1")
1391            .push("instructions")
1392            .push("query");
1393        let response = self
1394            .client
1395            .post(url)
1396            .query(&request.query)
1397            .json(&request.body)
1398            .send()
1399            .await?;
1400        Ok(PostGwApiV1InstructionsQueryRequest::parse_response(response).await?)
1401    }
1402    /// Get Status For InstructionId
1403    ///
1404    /// Retrieve status of request by instructionId<br><br>**Scope**: `instructions.read`<br>**Security Policy**: `HTTPS`
1405    ///
1406    /// * Path: `GET /gw/api/v1/instructions/{instructionId}`
1407    pub async fn get_gw_api_v1_instructions_instructionid(
1408        &self,
1409        request: GetGwApiV1InstructionsInstructionidRequest,
1410    ) -> anyhow::Result<GetGwApiV1InstructionsInstructionidResponse> {
1411        request.validate().context("parameter validation")?;
1412        let mut url = self.base_url.clone();
1413        url.path_segments_mut()
1414            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
1415            .push("gw")
1416            .push("api")
1417            .push("v1")
1418            .push("instructions")
1419            .push(&request.path.instruction_id.to_string());
1420        let response = self.client.get(url).query(&request.query).send().await?;
1421        Ok(GetGwApiV1InstructionsInstructionidRequest::parse_response(response).await?)
1422    }
1423    /// Transfer Positions Internally
1424    ///
1425    /// Transfer positions internally between two accounts with Interactive Brokers<br><br>**Scope**: `transfers.write`<br>**Security Policy**: `Signed JWT`
1426    ///
1427    /// * Path: `POST /gw/api/v1/internal-asset-transfers`
1428    pub async fn post_gw_api_v1_internal_asset_transfers(
1429        &self,
1430        request: PostGwApiV1InternalAssetTransfersRequest,
1431    ) -> anyhow::Result<PostGwApiV1BankInstructionsResponse> {
1432        request.validate().context("parameter validation")?;
1433        let mut url = self.base_url.clone();
1434        url.path_segments_mut()
1435            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
1436            .push("gw")
1437            .push("api")
1438            .push("v1")
1439            .push("internal-asset-transfers");
1440        let response = self
1441            .client
1442            .post(url)
1443            .query(&request.query)
1444            .json(&request.body)
1445            .send()
1446            .await?;
1447        Ok(PostGwApiV1InternalAssetTransfersRequest::parse_response(response).await?)
1448    }
1449    /// Creates Multiple Internal Asset Transfers Between The Provided Account Id Pairs
1450    ///
1451    /// <br>**Scope**: `transfers.write`<br>**Security Policy**: `Signed JWT`
1452    ///
1453    /// * Path: `POST /gw/api/v1/internal-asset-transfers:bulk`
1454    pub async fn post_gw_api_v1_internal_asset_transfers_bulk(
1455        &self,
1456        request: PostGwApiV1InternalAssetTransfersBulkRequest,
1457    ) -> anyhow::Result<PostGwApiV1BankInstructionsBulkResponse> {
1458        request.validate().context("parameter validation")?;
1459        let mut url = self.base_url.clone();
1460        url.path_segments_mut()
1461            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
1462            .push("gw")
1463            .push("api")
1464            .push("v1")
1465            .push("internal-asset-transfers:bulk");
1466        let response = self
1467            .client
1468            .post(url)
1469            .query(&request.query)
1470            .json(&request.body)
1471            .send()
1472            .await?;
1473        Ok(PostGwApiV1InternalAssetTransfersBulkRequest::parse_response(response).await?)
1474    }
1475    /// Transfer Cash Internally
1476    ///
1477    /// Transfer cash internally between two accounts with Interactive Brokers.<br><br>**Scope**: `transfers.write`<br>**Security Policy**: `Signed JWT`
1478    ///
1479    /// * Path: `POST /gw/api/v1/internal-cash-transfers`
1480    pub async fn post_gw_api_v1_internal_cash_transfers(
1481        &self,
1482        request: PostGwApiV1InternalCashTransfersRequest,
1483    ) -> anyhow::Result<PostGwApiV1InstructionsCancelResponse> {
1484        request.validate().context("parameter validation")?;
1485        let mut url = self.base_url.clone();
1486        url.path_segments_mut()
1487            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
1488            .push("gw")
1489            .push("api")
1490            .push("v1")
1491            .push("internal-cash-transfers");
1492        let response = self
1493            .client
1494            .post(url)
1495            .query(&request.query)
1496            .json(&request.body)
1497            .send()
1498            .await?;
1499        Ok(PostGwApiV1InternalCashTransfersRequest::parse_response(response).await?)
1500    }
1501    /// Creates Multiple Internal Cash Transfers Between The Provided Account Id Pairs
1502    ///
1503    /// <br>**Scope**: `transfers.write`<br>**Security Policy**: `Signed JWT`
1504    ///
1505    /// * Path: `POST /gw/api/v1/internal-cash-transfers:bulk`
1506    pub async fn post_gw_api_v1_internal_cash_transfers_bulk(
1507        &self,
1508        request: PostGwApiV1InternalCashTransfersBulkRequest,
1509    ) -> anyhow::Result<PostGwApiV1BankInstructionsBulkResponse> {
1510        request.validate().context("parameter validation")?;
1511        let mut url = self.base_url.clone();
1512        url.path_segments_mut()
1513            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
1514            .push("gw")
1515            .push("api")
1516            .push("v1")
1517            .push("internal-cash-transfers:bulk");
1518        let response = self
1519            .client
1520            .post(url)
1521            .query(&request.query)
1522            .json(&request.body)
1523            .send()
1524            .await?;
1525        Ok(PostGwApiV1InternalCashTransfersBulkRequest::parse_response(response).await?)
1526    }
1527    /// Get Participating Banks
1528    ///
1529    /// Get list of banks which support banking connection with Interactive Brokers.<br><br>**Scope**: `enumerations.read`<br>**Security Policy**: `HTTPS`
1530    ///
1531    /// * Path: `GET /gw/api/v1/participating-banks`
1532    pub async fn get_gw_api_v1_participating_banks(
1533        &self,
1534        request: GetGwApiV1ParticipatingBanksRequest,
1535    ) -> anyhow::Result<GetGwApiV1ParticipatingBanksResponse> {
1536        request.validate().context("parameter validation")?;
1537        let mut url = self.base_url.clone();
1538        url.path_segments_mut()
1539            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
1540            .push("gw")
1541            .push("api")
1542            .push("v1")
1543            .push("participating-banks");
1544        let response = self.client.get(url).query(&request.query).send().await?;
1545        Ok(GetGwApiV1ParticipatingBanksRequest::parse_response(response).await?)
1546    }
1547    /// Get Requests' Details By Timeframe
1548    ///
1549    /// Fetch Requests' Details By Timeframe<br><br>**Scope**: `accounts.read`<br>**Security Policy**: `HTTPS`
1550    ///
1551    /// * Path: `GET /gw/api/v1/requests`
1552    pub async fn get_gw_api_v1_requests(
1553        &self,
1554        request: GetGwApiV1RequestsRequest,
1555    ) -> anyhow::Result<GetGwApiV1RequestsResponse> {
1556        request.validate().context("parameter validation")?;
1557        let mut url = self.base_url.clone();
1558        url.path_segments_mut()
1559            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
1560            .push("gw")
1561            .push("api")
1562            .push("v1")
1563            .push("requests");
1564        let response = self.client.get(url).query(&request.query).send().await?;
1565        Ok(GetGwApiV1RequestsRequest::parse_response(response).await?)
1566    }
1567    /// Update Status Of An Am Request
1568    ///
1569    /// This api will be used to update the status of am request<br><br>**Scope**: `accounts.read`<br>**Security Policy**: `Signed JWT`
1570    ///
1571    /// * Path: `PATCH /gw/api/v1/requests/{requestId}/status`
1572    pub async fn patch_gw_api_v1_requests_requestid_status(
1573        &self,
1574        request: PatchGwApiV1RequestsRequestidStatusRequest,
1575    ) -> anyhow::Result<PatchGwApiV1RequestsRequestidStatusResponse> {
1576        request.validate().context("parameter validation")?;
1577        let mut url = self.base_url.clone();
1578        url.path_segments_mut()
1579            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
1580            .push("gw")
1581            .push("api")
1582            .push("v1")
1583            .push("requests")
1584            .push(&request.path.request_id.to_string())
1585            .push("status");
1586        let response = self
1587            .client
1588            .patch(url)
1589            .body((&request.body).to_string())
1590            .send()
1591            .await?;
1592        Ok(PatchGwApiV1RequestsRequestidStatusRequest::parse_response(response).await?)
1593    }
1594    /// Apply PTC CSV
1595    ///
1596    /// Applies verified CSV changes. Requires both Bearer token (header) and signed JWT (body). CSV must be verified via /csv/v2/verify first. JWT validity: 1 minute.<br><br>**Scope**: `restrictions.write`<br>**Security Policy**: `Signed JWT`
1597    ///
1598    /// * Path: `POST /gw/api/v1/restrictions`
1599    pub async fn apply_csv(&self, request: ApplyCsvRequest) -> anyhow::Result<ApplyCsvResponse> {
1600        request.validate().context("parameter validation")?;
1601        let mut url = self.base_url.clone();
1602        url.path_segments_mut()
1603            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
1604            .push("gw")
1605            .push("api")
1606            .push("v1")
1607            .push("restrictions");
1608        let response = self
1609            .client
1610            .post(url)
1611            .headers(
1612                http::HeaderMap::try_from(&request.header).context("building request headers")?,
1613            )
1614            .body((&request.body).to_string())
1615            .send()
1616            .await?;
1617        Ok(ApplyCsvRequest::parse_response(response).await?)
1618    }
1619    /// Verify PTC CSV
1620    ///
1621    /// Validates CSV structure, restriction names, and rule parameters without applying changes. Must be called before /csv/v2/apply with the same requestId.<br><br>**Scope**: `restrictions.write`<br>**Security Policy**: `Signed JWT`
1622    ///
1623    /// * Path: `POST /gw/api/v1/restrictions/verify`
1624    pub async fn verify_csv(&self, request: VerifyCsvRequest) -> anyhow::Result<ApplyCsvResponse> {
1625        request.validate().context("parameter validation")?;
1626        let mut url = self.base_url.clone();
1627        url.path_segments_mut()
1628            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
1629            .push("gw")
1630            .push("api")
1631            .push("v1")
1632            .push("restrictions")
1633            .push("verify");
1634        let response = self
1635            .client
1636            .post(url)
1637            .headers(
1638                http::HeaderMap::try_from(&request.header).context("building request headers")?,
1639            )
1640            .json(&request.body)
1641            .send()
1642            .await?;
1643        Ok(VerifyCsvRequest::parse_response(response).await?)
1644    }
1645    /// Create SSO Browser Session.
1646    ///
1647    /// <br>**Scope**: `sso-browser-sessions.write`<br>**Security Policy**: `Signed JWT`
1648    ///
1649    /// * Path: `POST /gw/api/v1/sso-browser-sessions`
1650    pub async fn post_gw_api_v1_sso_browser_sessions(
1651        &self,
1652        request: PostGwApiV1SsoBrowserSessionsRequest,
1653    ) -> anyhow::Result<PostGwApiV1SsoBrowserSessionsResponse> {
1654        request.validate().context("parameter validation")?;
1655        let mut url = self.base_url.clone();
1656        url.path_segments_mut()
1657            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
1658            .push("gw")
1659            .push("api")
1660            .push("v1")
1661            .push("sso-browser-sessions");
1662        let response = self
1663            .client
1664            .post(url)
1665            .headers(
1666                http::HeaderMap::try_from(&request.header).context("building request headers")?,
1667            )
1668            .body((&request.body).to_string())
1669            .send()
1670            .await?;
1671        Ok(PostGwApiV1SsoBrowserSessionsRequest::parse_response(response).await?)
1672    }
1673    /// Create A New SSO Session On Behalf Of An End-user.
1674    ///
1675    /// <br>**Scope**: `sso-sessions.write`<br>**Security Policy**: `Signed JWT`
1676    ///
1677    /// * Path: `POST /gw/api/v1/sso-sessions`
1678    pub async fn post_gw_api_v1_sso_sessions(
1679        &self,
1680        request: PostGwApiV1SsoSessionsRequest,
1681    ) -> anyhow::Result<PostGwApiV1SsoSessionsResponse> {
1682        request.validate().context("parameter validation")?;
1683        let mut url = self.base_url.clone();
1684        url.path_segments_mut()
1685            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
1686            .push("gw")
1687            .push("api")
1688            .push("v1")
1689            .push("sso-sessions");
1690        let response = self
1691            .client
1692            .post(url)
1693            .headers(
1694                http::HeaderMap::try_from(&request.header).context("building request headers")?,
1695            )
1696            .body((&request.body).to_string())
1697            .send()
1698            .await?;
1699        Ok(PostGwApiV1SsoSessionsRequest::parse_response(response).await?)
1700    }
1701    /// Generates Statements In Supported Formats Based On Request Parameters.
1702    ///
1703    /// <br>**Scope**: `statements.read` OR `statements.write` OR `reports.write`<br>**Security Policy**: `Signed JWT`
1704    ///
1705    /// * Path: `POST /gw/api/v1/statements`
1706    pub async fn post_gw_api_v1_statements(
1707        &self,
1708        request: PostGwApiV1StatementsRequest,
1709    ) -> anyhow::Result<PostGwApiV1StatementsResponse> {
1710        request.validate().context("parameter validation")?;
1711        let mut url = self.base_url.clone();
1712        url.path_segments_mut()
1713            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
1714            .push("gw")
1715            .push("api")
1716            .push("v1")
1717            .push("statements");
1718        let response = self
1719            .client
1720            .post(url)
1721            .headers(
1722                http::HeaderMap::try_from(&request.header).context("building request headers")?,
1723            )
1724            .json(&request.body)
1725            .send()
1726            .await?;
1727        Ok(PostGwApiV1StatementsRequest::parse_response(response).await?)
1728    }
1729    /// Fetch Available Daily, Monthly, And Annual Report Dates For An Account Id
1730    ///
1731    /// <br>**Scope**: `statements.read` OR `reports.read`<br>**Security Policy**: `HTTPS`
1732    ///
1733    /// * Path: `GET /gw/api/v1/statements/available`
1734    pub async fn get_gw_api_v1_statements_available(
1735        &self,
1736        request: GetGwApiV1StatementsAvailableRequest,
1737    ) -> anyhow::Result<GetGwApiV1StatementsAvailableResponse> {
1738        request.validate().context("parameter validation")?;
1739        let mut url = self.base_url.clone();
1740        url.path_segments_mut()
1741            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
1742            .push("gw")
1743            .push("api")
1744            .push("v1")
1745            .push("statements")
1746            .push("available");
1747        let response = self
1748            .client
1749            .get(url)
1750            .query(&request.query)
1751            .headers(
1752                http::HeaderMap::try_from(&request.header).context("building request headers")?,
1753            )
1754            .send()
1755            .await?;
1756        Ok(GetGwApiV1StatementsAvailableRequest::parse_response(response).await?)
1757    }
1758    /// Fetch Tax Forms In Supported Formats Based On Request Parameters.
1759    ///
1760    /// <br>**Scope**: `statements.write` OR `reports.write`<br>**Security Policy**: `Signed JWT`
1761    ///
1762    /// * Path: `POST /gw/api/v1/tax-documents`
1763    pub async fn post_gw_api_v1_tax_documents(
1764        &self,
1765        request: PostGwApiV1TaxDocumentsRequest,
1766    ) -> anyhow::Result<PostGwApiV1TaxDocumentsResponse> {
1767        request.validate().context("parameter validation")?;
1768        let mut url = self.base_url.clone();
1769        url.path_segments_mut()
1770            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
1771            .push("gw")
1772            .push("api")
1773            .push("v1")
1774            .push("tax-documents");
1775        let response = self
1776            .client
1777            .post(url)
1778            .headers(
1779                http::HeaderMap::try_from(&request.header).context("building request headers")?,
1780            )
1781            .json(&request.body)
1782            .send()
1783            .await?;
1784        Ok(PostGwApiV1TaxDocumentsRequest::parse_response(response).await?)
1785    }
1786    /// Fetch List Of Available Tax Reports/forms/documents For A Specified Account And Tax Year
1787    ///
1788    /// <br>**Scope**: `statements.read` OR `reports.read`<br>**Security Policy**: `HTTPS`
1789    ///
1790    /// * Path: `GET /gw/api/v1/tax-documents/available`
1791    pub async fn get_gw_api_v1_tax_documents_available(
1792        &self,
1793        request: GetGwApiV1TaxDocumentsAvailableRequest,
1794    ) -> anyhow::Result<GetGwApiV1TaxDocumentsAvailableResponse> {
1795        request.validate().context("parameter validation")?;
1796        let mut url = self.base_url.clone();
1797        url.path_segments_mut()
1798            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
1799            .push("gw")
1800            .push("api")
1801            .push("v1")
1802            .push("tax-documents")
1803            .push("available");
1804        let response = self
1805            .client
1806            .get(url)
1807            .query(&request.query)
1808            .headers(
1809                http::HeaderMap::try_from(&request.header).context("building request headers")?,
1810            )
1811            .send()
1812            .await?;
1813        Ok(GetGwApiV1TaxDocumentsAvailableRequest::parse_response(response).await?)
1814    }
1815    /// Fetch Trade Confirmations In Supported Formats Based On Request Parameters.
1816    ///
1817    /// <br>**Scope**: `statements.write` OR `reports.write`<br>**Security Policy**: `Signed JWT`
1818    ///
1819    /// * Path: `POST /gw/api/v1/trade-confirmations`
1820    pub async fn post_gw_api_v1_trade_confirmations(
1821        &self,
1822        request: PostGwApiV1TradeConfirmationsRequest,
1823    ) -> anyhow::Result<PostGwApiV1TradeConfirmationsResponse> {
1824        request.validate().context("parameter validation")?;
1825        let mut url = self.base_url.clone();
1826        url.path_segments_mut()
1827            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
1828            .push("gw")
1829            .push("api")
1830            .push("v1")
1831            .push("trade-confirmations");
1832        let response = self
1833            .client
1834            .post(url)
1835            .headers(
1836                http::HeaderMap::try_from(&request.header).context("building request headers")?,
1837            )
1838            .json(&request.body)
1839            .send()
1840            .await?;
1841        Ok(PostGwApiV1TradeConfirmationsRequest::parse_response(response).await?)
1842    }
1843    /// Fetch List Of Available Trade Confirmation Dates, For A Specific Account Id
1844    ///
1845    /// <br>**Scope**: `statements.read` OR `reports.read`<br>**Security Policy**: `HTTPS`
1846    ///
1847    /// * Path: `GET /gw/api/v1/trade-confirmations/available`
1848    pub async fn get_gw_api_v1_trade_confirmations_available(
1849        &self,
1850        request: GetGwApiV1TradeConfirmationsAvailableRequest,
1851    ) -> anyhow::Result<GetGwApiV1TradeConfirmationsAvailableResponse> {
1852        request.validate().context("parameter validation")?;
1853        let mut url = self.base_url.clone();
1854        url.path_segments_mut()
1855            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
1856            .push("gw")
1857            .push("api")
1858            .push("v1")
1859            .push("trade-confirmations")
1860            .push("available");
1861        let response = self
1862            .client
1863            .get(url)
1864            .query(&request.query)
1865            .headers(
1866                http::HeaderMap::try_from(&request.header).context("building request headers")?,
1867            )
1868            .send()
1869            .await?;
1870        Ok(GetGwApiV1TradeConfirmationsAvailableRequest::parse_response(response).await?)
1871    }
1872    /// Verify User Availability
1873    ///
1874    /// Verify whether user is valid and available<br><br>**Scope**: `accounts.read` OR `validations.read`<br>**Security Policy**: `HTTPS`
1875    ///
1876    /// * Path: `GET /gw/api/v1/validations/usernames/{username}`
1877    pub async fn get_gw_api_v1_validations_usernames_username(
1878        &self,
1879        request: GetGwApiV1ValidationsUsernamesUsernameRequest,
1880    ) -> anyhow::Result<GetGwApiV1ValidationsUsernamesUsernameResponse> {
1881        request.validate().context("parameter validation")?;
1882        let mut url = self.base_url.clone();
1883        url.path_segments_mut()
1884            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
1885            .push("gw")
1886            .push("api")
1887            .push("v1")
1888            .push("validations")
1889            .push("usernames")
1890            .push(&request.path.username.to_string());
1891        let response = self.client.get(url).send().await?;
1892        Ok(GetGwApiV1ValidationsUsernamesUsernameRequest::parse_response(response).await?)
1893    }
1894    /// Switch Selected Account
1895    ///
1896    /// Switch the active account for how you request data. Only available for financial advisors and multi-account structures.
1897    ///
1898    /// * Path: `POST /iserver/account`
1899    pub async fn set_active_account(
1900        &self,
1901        request: SetActiveAccountRequest,
1902    ) -> anyhow::Result<SetActiveAccountResponse> {
1903        request.validate().context("parameter validation")?;
1904        let mut url = self.base_url.clone();
1905        url.path_segments_mut()
1906            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
1907            .push("iserver")
1908            .push("account");
1909        let response = self.client.post(url).json(&request.body).send().await?;
1910        Ok(SetActiveAccountRequest::parse_response(response).await?)
1911    }
1912    /// Details Of A Specific Alert
1913    ///
1914    /// Request details of a specific alert by providing the assigned alertId Id.
1915    ///
1916    /// * Path: `GET /iserver/account/alert/{alertId}`
1917    pub async fn get_alert_details(
1918        &self,
1919        request: GetAlertDetailsRequest,
1920    ) -> anyhow::Result<GetAlertDetailsResponse> {
1921        request.validate().context("parameter validation")?;
1922        let mut url = self.base_url.clone();
1923        url.path_segments_mut()
1924            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
1925            .push("iserver")
1926            .push("account")
1927            .push("alert")
1928            .push(&request.path.alert_id.to_string());
1929        let response = self.client.get(url).query(&request.query).send().await?;
1930        Ok(GetAlertDetailsRequest::parse_response(response).await?)
1931    }
1932    /// List Allocatable Subaccounts
1933    ///
1934    /// Retrieves a list of all sub-accounts and returns their net liquidity and available equity for advisors to make decisions on what accounts should be allocated and how. This endpoint is only supported for Financial Advisors and IBroker Accounts.
1935    ///
1936    /// * Path: `GET /iserver/account/allocation/accounts`
1937    pub async fn get_allocatable_subaccounts(
1938        &self,
1939        request: GetAllocatableSubaccountsRequest,
1940    ) -> anyhow::Result<GetAllocatableSubaccountsResponse> {
1941        request.validate().context("parameter validation")?;
1942        let mut url = self.base_url.clone();
1943        url.path_segments_mut()
1944            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
1945            .push("iserver")
1946            .push("account")
1947            .push("allocation")
1948            .push("accounts");
1949        let response = self.client.get(url).send().await?;
1950        Ok(GetAllocatableSubaccountsRequest::parse_response(response).await?)
1951    }
1952    /// List All Allocation Groups
1953    ///
1954    /// Retrieves a list of all of the advisor's allocation groups. This describes the name of the allocation group, number of subaccounts within the group, and the method in use for the group. This endpoint is only supported for Financial Advisors and IBroker Accounts.
1955    ///
1956    /// * Path: `GET /iserver/account/allocation/group`
1957    pub async fn get_allocation_groups(
1958        &self,
1959        request: GetAllocationGroupsRequest,
1960    ) -> anyhow::Result<GetAllocationGroupsResponse> {
1961        request.validate().context("parameter validation")?;
1962        let mut url = self.base_url.clone();
1963        url.path_segments_mut()
1964            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
1965            .push("iserver")
1966            .push("account")
1967            .push("allocation")
1968            .push("group");
1969        let response = self.client.get(url).send().await?;
1970        Ok(GetAllocationGroupsRequest::parse_response(response).await?)
1971    }
1972    /// Modify Allocation Group
1973    ///
1974    /// Modify an existing allocation group.
1975    ///
1976    /// * Path: `PUT /iserver/account/allocation/group`
1977    pub async fn modify_allocation_group(
1978        &self,
1979        request: ModifyAllocationGroupRequest,
1980    ) -> anyhow::Result<CreateAllocationGroupResponse> {
1981        request.validate().context("parameter validation")?;
1982        let mut url = self.base_url.clone();
1983        url.path_segments_mut()
1984            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
1985            .push("iserver")
1986            .push("account")
1987            .push("allocation")
1988            .push("group");
1989        let response = self.client.put(url).json(&request.body).send().await?;
1990        Ok(ModifyAllocationGroupRequest::parse_response(response).await?)
1991    }
1992    /// Add Allocation Group
1993    ///
1994    /// Add a new allocation group. This group can be used to trade in place of the {accountId} for the /iserver/account/{accountId}/orders endpoint.
1995    ///
1996    /// * Path: `POST /iserver/account/allocation/group`
1997    pub async fn create_allocation_group(
1998        &self,
1999        request: CreateAllocationGroupRequest,
2000    ) -> anyhow::Result<CreateAllocationGroupResponse> {
2001        request.validate().context("parameter validation")?;
2002        let mut url = self.base_url.clone();
2003        url.path_segments_mut()
2004            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
2005            .push("iserver")
2006            .push("account")
2007            .push("allocation")
2008            .push("group");
2009        let response = self.client.post(url).json(&request.body).send().await?;
2010        Ok(CreateAllocationGroupRequest::parse_response(response).await?)
2011    }
2012    /// Delete An Allocation Group
2013    ///
2014    /// Deletes a previously created allocation group. This endpoint is only supported for Financial Advisors and IBroker Accounts.
2015    ///
2016    /// * Path: `POST /iserver/account/allocation/group/delete`
2017    pub async fn delete_allocation_group(
2018        &self,
2019        request: DeleteAllocationGroupRequest,
2020    ) -> anyhow::Result<CreateAllocationGroupResponse> {
2021        request.validate().context("parameter validation")?;
2022        let mut url = self.base_url.clone();
2023        url.path_segments_mut()
2024            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
2025            .push("iserver")
2026            .push("account")
2027            .push("allocation")
2028            .push("group")
2029            .push("delete");
2030        let response = self.client.post(url).json(&request.body).send().await?;
2031        Ok(DeleteAllocationGroupRequest::parse_response(response).await?)
2032    }
2033    /// Retrieve Single Allocation Group
2034    ///
2035    /// Retrieves the configuration of a single account group.  This describes the name of the allocation group, the specific accounts contained in the group, and the allocation method in use along with any relevant quantities. This endpoint is only supported for Financial Advisors and IBroker Accounts.
2036    ///
2037    /// * Path: `POST /iserver/account/allocation/group/single`
2038    pub async fn get_single_allocation_group(
2039        &self,
2040        request: GetSingleAllocationGroupRequest,
2041    ) -> anyhow::Result<GetSingleAllocationGroupResponse> {
2042        request.validate().context("parameter validation")?;
2043        let mut url = self.base_url.clone();
2044        url.path_segments_mut()
2045            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
2046            .push("iserver")
2047            .push("account")
2048            .push("allocation")
2049            .push("group")
2050            .push("single");
2051        let response = self.client.post(url).json(&request.body).send().await?;
2052        Ok(GetSingleAllocationGroupRequest::parse_response(response).await?)
2053    }
2054    /// Retrieve Allocation Presets
2055    ///
2056    /// Retrieve the preset behavior for allocation groups for specific events. This endpoint is only supported for Financial Advisors and IBroker Accounts.
2057    ///
2058    /// * Path: `GET /iserver/account/allocation/presets`
2059    pub async fn get_allocation_presets(
2060        &self,
2061        request: GetAllocationPresetsRequest,
2062    ) -> anyhow::Result<GetAllocationPresetsResponse> {
2063        request.validate().context("parameter validation")?;
2064        let mut url = self.base_url.clone();
2065        url.path_segments_mut()
2066            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
2067            .push("iserver")
2068            .push("account")
2069            .push("allocation")
2070            .push("presets");
2071        let response = self.client.get(url).send().await?;
2072        Ok(GetAllocationPresetsRequest::parse_response(response).await?)
2073    }
2074    /// Set Allocation Preset
2075    ///
2076    /// Set the preset behavior for new allocation groups for specific events.
2077    ///
2078    /// * Path: `POST /iserver/account/allocation/presets`
2079    pub async fn set_allocation_preset(
2080        &self,
2081        request: SetAllocationPresetRequest,
2082    ) -> anyhow::Result<SetAllocationPresetResponse> {
2083        request.validate().context("parameter validation")?;
2084        let mut url = self.base_url.clone();
2085        url.path_segments_mut()
2086            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
2087            .push("iserver")
2088            .push("account")
2089            .push("allocation")
2090            .push("presets");
2091        let response = self.client.post(url).json(&request.body).send().await?;
2092        Ok(SetAllocationPresetRequest::parse_response(response).await?)
2093    }
2094    /// Details Of A Mobile Trading Alert
2095    ///
2096    /// Retrieve information about your MTA alert. Each login user only has one mobile trading assistant (MTA) alert with it's own unique tool id that cannot be changed. MTA alerts can not be created or deleted, only modified. When modified a new order Id is generated.
2097    ///
2098    /// * Path: `GET /iserver/account/mta`
2099    pub async fn get_mta_details(
2100        &self,
2101        request: GetMtaDetailsRequest,
2102    ) -> anyhow::Result<GetMtaDetailsResponse> {
2103        request.validate().context("parameter validation")?;
2104        let mut url = self.base_url.clone();
2105        url.path_segments_mut()
2106            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
2107            .push("iserver")
2108            .push("account")
2109            .push("mta");
2110        let response = self.client.get(url).send().await?;
2111        Ok(GetMtaDetailsRequest::parse_response(response).await?)
2112    }
2113    /// Status Of A Single Order
2114    ///
2115    /// Retrieve the status of a single order. Only displays orders from the current brokerage session. If orders executed on a previous day or session, queries will 503 error.
2116    ///
2117    /// * Path: `GET /iserver/account/order/status/{orderId}`
2118    pub async fn get_order_status(
2119        &self,
2120        request: GetOrderStatusRequest,
2121    ) -> anyhow::Result<GetOrderStatusResponse> {
2122        request.validate().context("parameter validation")?;
2123        let mut url = self.base_url.clone();
2124        url.path_segments_mut()
2125            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
2126            .push("iserver")
2127            .push("account")
2128            .push("order")
2129            .push("status")
2130            .push(&request.path.order_id.to_string());
2131        let response = self.client.get(url).send().await?;
2132        Ok(GetOrderStatusRequest::parse_response(response).await?)
2133    }
2134    /// List Open Orders
2135    ///
2136    /// Returns open orders and filled or cancelled orders submitted during the current brokerage session.
2137    ///
2138    /// * Path: `GET /iserver/account/orders`
2139    pub async fn get_open_orders(
2140        &self,
2141        request: GetOpenOrdersRequest,
2142    ) -> anyhow::Result<GetOpenOrdersResponse> {
2143        request.validate().context("parameter validation")?;
2144        let mut url = self.base_url.clone();
2145        url.path_segments_mut()
2146            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
2147            .push("iserver")
2148            .push("account")
2149            .push("orders");
2150        let response = self.client.get(url).query(&request.query).send().await?;
2151        Ok(GetOpenOrdersRequest::parse_response(response).await?)
2152    }
2153    /// Account Profit And Loss
2154    ///
2155    /// Returns updated profit and loss values for the selected account. Initial request will return an empty array in the upnl object.
2156    ///
2157    /// * Path: `GET /iserver/account/pnl/partitioned`
2158    pub async fn get_pnl(&self, request: GetPnlRequest) -> anyhow::Result<GetPnlResponse> {
2159        request.validate().context("parameter validation")?;
2160        let mut url = self.base_url.clone();
2161        url.path_segments_mut()
2162            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
2163            .push("iserver")
2164            .push("account")
2165            .push("pnl")
2166            .push("partitioned");
2167        let response = self.client.get(url).send().await?;
2168        Ok(GetPnlRequest::parse_response(response).await?)
2169    }
2170    /// Search Dynamic Accounts
2171    ///
2172    /// Returns a list of accounts matching a query pattern set in the request. Broker accounts configured with the DYNACCT property will not receive account information at login. Instead, they must dynamically query then set their account number. Customers without the DYNACCT property will receive a 503 error.
2173    ///
2174    /// * Path: `GET /iserver/account/search/{searchPattern}`
2175    pub async fn get_dynamic_accounts(
2176        &self,
2177        request: GetDynamicAccountsRequest,
2178    ) -> anyhow::Result<GetDynamicAccountsResponse> {
2179        request.validate().context("parameter validation")?;
2180        let mut url = self.base_url.clone();
2181        url.path_segments_mut()
2182            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
2183            .push("iserver")
2184            .push("account")
2185            .push("search")
2186            .push(&request.path.search_pattern.to_string());
2187        let response = self.client.get(url).send().await?;
2188        Ok(GetDynamicAccountsRequest::parse_response(response).await?)
2189    }
2190    /// Trade History
2191    ///
2192    /// Retrieve a list of trades, up to a maximum of 7 days prior.
2193    ///
2194    /// * Path: `GET /iserver/account/trades`
2195    pub async fn get_trade_history(
2196        &self,
2197        request: GetTradeHistoryRequest,
2198    ) -> anyhow::Result<GetTradeHistoryResponse> {
2199        request.validate().context("parameter validation")?;
2200        let mut url = self.base_url.clone();
2201        url.path_segments_mut()
2202            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
2203            .push("iserver")
2204            .push("account")
2205            .push("trades");
2206        let response = self.client.get(url).query(&request.query).send().await?;
2207        Ok(GetTradeHistoryRequest::parse_response(response).await?)
2208    }
2209    /// Create Or Modify Alert
2210    ///
2211    /// Endpoint used to create a new alert, or modify an existing alert.
2212    ///
2213    /// * Path: `POST /iserver/account/{accountId}/alert`
2214    pub async fn create_alert(
2215        &self,
2216        request: CreateAlertRequest,
2217    ) -> anyhow::Result<CreateAlertResponse> {
2218        request.validate().context("parameter validation")?;
2219        let mut url = self.base_url.clone();
2220        url.path_segments_mut()
2221            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
2222            .push("iserver")
2223            .push("account")
2224            .push(&request.path.account_id.to_string())
2225            .push("alert");
2226        let response = self.client.post(url).json(&request.body).send().await?;
2227        Ok(CreateAlertRequest::parse_response(response).await?)
2228    }
2229    /// Activate Or Deactivate An Alert
2230    ///
2231    /// Activate or Deactivate existing alerts created for this account. This does not delete alerts, but disables notifications until reactivated.
2232    ///
2233    /// * Path: `POST /iserver/account/{accountId}/alert/activate`
2234    pub async fn activate_alert(
2235        &self,
2236        request: ActivateAlertRequest,
2237    ) -> anyhow::Result<ActivateAlertResponse> {
2238        request.validate().context("parameter validation")?;
2239        let mut url = self.base_url.clone();
2240        url.path_segments_mut()
2241            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
2242            .push("iserver")
2243            .push("account")
2244            .push(&request.path.account_id.to_string())
2245            .push("alert")
2246            .push("activate");
2247        let response = self.client.post(url).json(&request.body).send().await?;
2248        Ok(ActivateAlertRequest::parse_response(response).await?)
2249    }
2250    /// Delete An Alert
2251    ///
2252    /// Permanently delete an existing alert. Deleting an MTA alert will reset it to the default state.
2253    ///
2254    /// * Path: `DELETE /iserver/account/{accountId}/alert/{alertId}`
2255    pub async fn delete_alert(
2256        &self,
2257        request: DeleteAlertRequest,
2258    ) -> anyhow::Result<DeleteAlertResponse> {
2259        request.validate().context("parameter validation")?;
2260        let mut url = self.base_url.clone();
2261        url.path_segments_mut()
2262            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
2263            .push("iserver")
2264            .push("account")
2265            .push(&request.path.account_id.to_string())
2266            .push("alert")
2267            .push(&request.path.alert_id.to_string());
2268        let response = self.client.delete(url).json(&request.body).send().await?;
2269        Ok(DeleteAlertRequest::parse_response(response).await?)
2270    }
2271    /// List All Alerts
2272    ///
2273    /// Retrieve a list of all alerts attached to the provided account.
2274    ///
2275    /// * Path: `GET /iserver/account/{accountId}/alerts`
2276    pub async fn get_all_alerts(
2277        &self,
2278        request: GetAllAlertsRequest,
2279    ) -> anyhow::Result<GetAllAlertsResponse> {
2280        request.validate().context("parameter validation")?;
2281        let mut url = self.base_url.clone();
2282        url.path_segments_mut()
2283            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
2284            .push("iserver")
2285            .push("account")
2286            .push(&request.path.account_id.to_string())
2287            .push("alerts");
2288        let response = self.client.get(url).send().await?;
2289        Ok(GetAllAlertsRequest::parse_response(response).await?)
2290    }
2291    /// Modify Open Order
2292    ///
2293    /// Modify an existing, unfilled order.
2294    ///
2295    /// * Path: `POST /iserver/account/{accountId}/order/{orderId}`
2296    pub async fn modify_open_order(
2297        &self,
2298        request: ModifyOpenOrderRequest,
2299    ) -> anyhow::Result<ModifyOpenOrderResponse> {
2300        request.validate().context("parameter validation")?;
2301        let mut url = self.base_url.clone();
2302        url.path_segments_mut()
2303            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
2304            .push("iserver")
2305            .push("account")
2306            .push(&request.path.account_id.to_string())
2307            .push("order")
2308            .push(&request.path.order_id.to_string());
2309        let response = self.client.post(url).json(&request.body).send().await?;
2310        Ok(ModifyOpenOrderRequest::parse_response(response).await?)
2311    }
2312    /// Cancel An Open Order
2313    ///
2314    /// Cancel an existing, unfilled order.
2315    ///
2316    /// * Path: `DELETE /iserver/account/{accountId}/order/{orderId}`
2317    pub async fn cancel_open_order(
2318        &self,
2319        request: CancelOpenOrderRequest,
2320    ) -> anyhow::Result<CancelOpenOrderResponse> {
2321        request.validate().context("parameter validation")?;
2322        let mut url = self.base_url.clone();
2323        url.path_segments_mut()
2324            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
2325            .push("iserver")
2326            .push("account")
2327            .push(&request.path.account_id.to_string())
2328            .push("order")
2329            .push(&request.path.order_id.to_string());
2330        let response = self.client.delete(url).query(&request.query).send().await?;
2331        Ok(CancelOpenOrderRequest::parse_response(response).await?)
2332    }
2333    /// Submit New Order
2334    ///
2335    /// Submit a new order(s) ticket, bracket, or OCA group.
2336    ///
2337    /// * Path: `POST /iserver/account/{accountId}/orders`
2338    pub async fn submit_new_order(
2339        &self,
2340        request: SubmitNewOrderRequest,
2341    ) -> anyhow::Result<SubmitNewOrderResponse> {
2342        request.validate().context("parameter validation")?;
2343        let mut url = self.base_url.clone();
2344        url.path_segments_mut()
2345            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
2346            .push("iserver")
2347            .push("account")
2348            .push(&request.path.account_id.to_string())
2349            .push("orders");
2350        let response = self.client.post(url).json(&request.body).send().await?;
2351        Ok(SubmitNewOrderRequest::parse_response(response).await?)
2352    }
2353    /// New Order Preview
2354    ///
2355    /// Preview the projected effects of an order ticket or bracket of orders, including cost and changes to margin and account equity.
2356    ///
2357    /// * Path: `POST /iserver/account/{accountId}/orders/whatif`
2358    pub async fn preview_margin_impact(
2359        &self,
2360        request: PreviewMarginImpactRequest,
2361    ) -> anyhow::Result<PreviewMarginImpactResponse> {
2362        request.validate().context("parameter validation")?;
2363        let mut url = self.base_url.clone();
2364        url.path_segments_mut()
2365            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
2366            .push("iserver")
2367            .push("account")
2368            .push(&request.path.account_id.to_string())
2369            .push("orders")
2370            .push("whatif");
2371        let response = self.client.post(url).json(&request.body).send().await?;
2372        Ok(PreviewMarginImpactRequest::parse_response(response).await?)
2373    }
2374    /// Summary Of Account Values
2375    ///
2376    /// Provides a general overview of the account details such as balance values.
2377    ///
2378    /// * Path: `GET /iserver/account/{accountId}/summary`
2379    pub async fn get_account_summary(
2380        &self,
2381        request: GetAccountSummaryRequest,
2382    ) -> anyhow::Result<GetAccountSummaryResponse> {
2383        request.validate().context("parameter validation")?;
2384        let mut url = self.base_url.clone();
2385        url.path_segments_mut()
2386            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
2387            .push("iserver")
2388            .push("account")
2389            .push(&request.path.account_id.to_string())
2390            .push("summary");
2391        let response = self.client.get(url).send().await?;
2392        Ok(GetAccountSummaryRequest::parse_response(response).await?)
2393    }
2394    /// Summary Of Available Funds
2395    ///
2396    /// Provides a summary specific for avilable funds giving more depth than the standard /summary endpoint.
2397    ///
2398    /// * Path: `GET /iserver/account/{accountId}/summary/available_funds`
2399    pub async fn get_fund_summary(
2400        &self,
2401        request: GetFundSummaryRequest,
2402    ) -> anyhow::Result<GetFundSummaryResponse> {
2403        request.validate().context("parameter validation")?;
2404        let mut url = self.base_url.clone();
2405        url.path_segments_mut()
2406            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
2407            .push("iserver")
2408            .push("account")
2409            .push(&request.path.account_id.to_string())
2410            .push("summary")
2411            .push("available_funds");
2412        let response = self.client.get(url).send().await?;
2413        Ok(GetFundSummaryRequest::parse_response(response).await?)
2414    }
2415    /// Summary Of Account Balances
2416    ///
2417    /// Returns a summary of an account's equity and cash balances, in total and by account segment.
2418    ///
2419    /// * Path: `GET /iserver/account/{accountId}/summary/balances`
2420    pub async fn get_balance_summary(
2421        &self,
2422        request: GetBalanceSummaryRequest,
2423    ) -> anyhow::Result<GetBalanceSummaryResponse> {
2424        request.validate().context("parameter validation")?;
2425        let mut url = self.base_url.clone();
2426        url.path_segments_mut()
2427            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
2428            .push("iserver")
2429            .push("account")
2430            .push(&request.path.account_id.to_string())
2431            .push("summary")
2432            .push("balances");
2433        let response = self.client.get(url).send().await?;
2434        Ok(GetBalanceSummaryRequest::parse_response(response).await?)
2435    }
2436    /// Summary Of Account Margin Usage
2437    ///
2438    /// Returns a summary of an account's margin, in total and by account segment.
2439    ///
2440    /// * Path: `GET /iserver/account/{accountId}/summary/margins`
2441    pub async fn get_margin_summary(
2442        &self,
2443        request: GetMarginSummaryRequest,
2444    ) -> anyhow::Result<GetMarginSummaryResponse> {
2445        request.validate().context("parameter validation")?;
2446        let mut url = self.base_url.clone();
2447        url.path_segments_mut()
2448            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
2449            .push("iserver")
2450            .push("account")
2451            .push(&request.path.account_id.to_string())
2452            .push("summary")
2453            .push("margins");
2454        let response = self.client.get(url).send().await?;
2455        Ok(GetMarginSummaryRequest::parse_response(response).await?)
2456    }
2457    /// Summary Of Account Market Value
2458    ///
2459    /// Returns a summary of an account's market value, by currency and asset class.
2460    ///
2461    /// * Path: `GET /iserver/account/{accountId}/summary/market_value`
2462    pub async fn get_account_market_summary(
2463        &self,
2464        request: GetAccountMarketSummaryRequest,
2465    ) -> anyhow::Result<GetAccountMarketSummaryResponse> {
2466        request.validate().context("parameter validation")?;
2467        let mut url = self.base_url.clone();
2468        url.path_segments_mut()
2469            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
2470            .push("iserver")
2471            .push("account")
2472            .push(&request.path.account_id.to_string())
2473            .push("summary")
2474            .push("market_value");
2475        let response = self.client.get(url).send().await?;
2476        Ok(GetAccountMarketSummaryRequest::parse_response(response).await?)
2477    }
2478    /// List All Tradable Accounts
2479    ///
2480    /// Returns a list of accounts the user has trading access to, their respective aliases and the currently selected account. Note this endpoint must be called before modifying an order or querying open orders.
2481    ///
2482    /// * Path: `GET /iserver/accounts`
2483    pub async fn get_brokerage_accounts(
2484        &self,
2485        request: GetBrokerageAccountsRequest,
2486    ) -> anyhow::Result<GetBrokerageAccountsResponse> {
2487        request.validate().context("parameter validation")?;
2488        let mut url = self.base_url.clone();
2489        url.path_segments_mut()
2490            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
2491            .push("iserver")
2492            .push("accounts");
2493        let response = self.client.get(url).send().await?;
2494        Ok(GetBrokerageAccountsRequest::parse_response(response).await?)
2495    }
2496    /// Initialize Brokerage Session
2497    ///
2498    /// After retrieving the access token and subsequent Live Session Token, customers can initialize their brokerage session with the ssodh/init endpoint.
2499    ///
2500    /// * Path: `POST /iserver/auth/ssodh/init`
2501    pub async fn initialize_session(
2502        &self,
2503        request: InitializeSessionRequest,
2504    ) -> anyhow::Result<InitializeSessionResponse> {
2505        request.validate().context("parameter validation")?;
2506        let mut url = self.base_url.clone();
2507        url.path_segments_mut()
2508            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
2509            .push("iserver")
2510            .push("auth")
2511            .push("ssodh")
2512            .push("init");
2513        let response = self.client.post(url).json(&request.body).send().await?;
2514        Ok(InitializeSessionRequest::parse_response(response).await?)
2515    }
2516    /// Brokerage Session Status
2517    ///
2518    /// Current Authentication status to the Brokerage system. Market Data and Trading is not possible if not authenticated.
2519    ///
2520    /// * Path: `POST /iserver/auth/status`
2521    pub async fn get_brokerage_status(
2522        &self,
2523        request: GetBrokerageStatusRequest,
2524    ) -> anyhow::Result<GetBrokerageStatusResponse> {
2525        request.validate().context("parameter validation")?;
2526        let mut url = self.base_url.clone();
2527        url.path_segments_mut()
2528            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
2529            .push("iserver")
2530            .push("auth")
2531            .push("status");
2532        let response = self.client.post(url).body(Vec::<u8>::new()).send().await?;
2533        Ok(GetBrokerageStatusRequest::parse_response(response).await?)
2534    }
2535    /// Search Contract Rules
2536    ///
2537    /// Returns trading related rules for a specific contract and side.
2538    ///
2539    /// * Path: `POST /iserver/contract/rules`
2540    pub async fn get_contract_rules(
2541        &self,
2542        request: GetContractRulesRequest,
2543    ) -> anyhow::Result<GetContractRulesResponse> {
2544        request.validate().context("parameter validation")?;
2545        let mut url = self.base_url.clone();
2546        url.path_segments_mut()
2547            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
2548            .push("iserver")
2549            .push("contract")
2550            .push("rules");
2551        let response = self.client.post(url).json(&request.body).send().await?;
2552        Ok(GetContractRulesRequest::parse_response(response).await?)
2553    }
2554    /// Search Algos For An Instrument
2555    ///
2556    /// Returns supported IB Algos for an instrument. A pre-flight request must be submitted before retrieving information.
2557    ///
2558    /// * Path: `GET /iserver/contract/{conid}/algos`
2559    pub async fn get_algos_by_instrument(
2560        &self,
2561        request: GetAlgosByInstrumentRequest,
2562    ) -> anyhow::Result<GetAlgosByInstrumentResponse> {
2563        request.validate().context("parameter validation")?;
2564        let mut url = self.base_url.clone();
2565        url.path_segments_mut()
2566            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
2567            .push("iserver")
2568            .push("contract")
2569            .push(&request.path.conid.to_string())
2570            .push("algos");
2571        let response = self.client.get(url).query(&request.query).send().await?;
2572        Ok(GetAlgosByInstrumentRequest::parse_response(response).await?)
2573    }
2574    /// General Instrument Information
2575    ///
2576    /// Requests full contract details for the given conid.
2577    ///
2578    /// * Path: `GET /iserver/contract/{conid}/info`
2579    pub async fn get_instrument_info(
2580        &self,
2581        request: GetInstrumentInfoRequest,
2582    ) -> anyhow::Result<GetInstrumentInfoResponse> {
2583        request.validate().context("parameter validation")?;
2584        let mut url = self.base_url.clone();
2585        url.path_segments_mut()
2586            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
2587            .push("iserver")
2588            .push("contract")
2589            .push(&request.path.conid.to_string())
2590            .push("info");
2591        let response = self.client.get(url).send().await?;
2592        Ok(GetInstrumentInfoRequest::parse_response(response).await?)
2593    }
2594    /// Instrument Info And Market Rules
2595    ///
2596    /// Requests full contract details and trading rules for the given conid. A follow-up request will provide additional trading rules.
2597    ///
2598    /// * Path: `GET /iserver/contract/{conid}/info-and-rules`
2599    pub async fn get_info_and_rules(
2600        &self,
2601        request: GetInfoAndRulesRequest,
2602    ) -> anyhow::Result<GetInfoAndRulesResponse> {
2603        request.validate().context("parameter validation")?;
2604        let mut url = self.base_url.clone();
2605        url.path_segments_mut()
2606            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
2607            .push("iserver")
2608            .push("contract")
2609            .push(&request.path.conid.to_string())
2610            .push("info-and-rules");
2611        let response = self.client.get(url).send().await?;
2612        Ok(GetInfoAndRulesRequest::parse_response(response).await?)
2613    }
2614    /// Available Currency Pairs
2615    ///
2616    /// Obtains available currency pairs corresponding to the given target currency.
2617    ///
2618    /// * Path: `GET /iserver/currency/pairs`
2619    pub async fn get_currency_pairs(
2620        &self,
2621        request: GetCurrencyPairsRequest,
2622    ) -> anyhow::Result<GetCurrencyPairsResponse> {
2623        request.validate().context("parameter validation")?;
2624        let mut url = self.base_url.clone();
2625        url.path_segments_mut()
2626            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
2627            .push("iserver")
2628            .push("currency")
2629            .push("pairs");
2630        let response = self.client.get(url).query(&request.query).send().await?;
2631        Ok(GetCurrencyPairsRequest::parse_response(response).await?)
2632    }
2633    /// Set Active Dynamic Account
2634    ///
2635    /// Set the active dynamic account.
2636    ///
2637    /// * Path: `POST /iserver/dynaccount`
2638    pub async fn set_dynamic_account(
2639        &self,
2640        request: SetDynamicAccountRequest,
2641    ) -> anyhow::Result<SetActiveAccountResponse> {
2642        request.validate().context("parameter validation")?;
2643        let mut url = self.base_url.clone();
2644        url.path_segments_mut()
2645            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
2646            .push("iserver")
2647            .push("dynaccount");
2648        let response = self.client.post(url).json(&request.body).send().await?;
2649        Ok(SetDynamicAccountRequest::parse_response(response).await?)
2650    }
2651    /// Currency Exchange Rate
2652    ///
2653    /// Obtains the exchange rates of the currency pair.
2654    ///
2655    /// * Path: `GET /iserver/exchangerate`
2656    pub async fn get_exchange_rates(
2657        &self,
2658        request: GetExchangeRatesRequest,
2659    ) -> anyhow::Result<GetExchangeRatesResponse> {
2660        request.validate().context("parameter validation")?;
2661        let mut url = self.base_url.clone();
2662        url.path_segments_mut()
2663            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
2664            .push("iserver")
2665            .push("exchangerate");
2666        let response = self.client.get(url).query(&request.query).send().await?;
2667        Ok(GetExchangeRatesRequest::parse_response(response).await?)
2668    }
2669    /// Historical OHLC Bar Data
2670    ///
2671    /// Request historical data for an instrument in the form of OHLC bars.
2672    ///
2673    /// * Path: `GET /iserver/marketdata/history`
2674    pub async fn get_md_history(
2675        &self,
2676        request: GetMdHistoryRequest,
2677    ) -> anyhow::Result<GetMdHistoryResponse> {
2678        request.validate().context("parameter validation")?;
2679        let mut url = self.base_url.clone();
2680        url.path_segments_mut()
2681            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
2682            .push("iserver")
2683            .push("marketdata")
2684            .push("history");
2685        let response = self.client.get(url).query(&request.query).send().await?;
2686        Ok(GetMdHistoryRequest::parse_response(response).await?)
2687    }
2688    /// Live Market Data Snapshot
2689    ///
2690    /// Get Market Data for the given conid(s). A pre-flight request must be made prior to ever receiving data. For some fields, it may take more than a few moments to receive information. See response fields for a list of available fields that can be request via fields argument. The endpoint /iserver/accounts must be called prior to /iserver/marketdata/snapshot. For derivative contracts the endpoint /iserver/secdef/search must be called first.
2691    ///
2692    /// * Path: `GET /iserver/marketdata/snapshot`
2693    pub async fn get_md_snapshot(
2694        &self,
2695        request: GetMdSnapshotRequest,
2696    ) -> anyhow::Result<GetMdSnapshotResponse> {
2697        request.validate().context("parameter validation")?;
2698        let mut url = self.base_url.clone();
2699        url.path_segments_mut()
2700            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
2701            .push("iserver")
2702            .push("marketdata")
2703            .push("snapshot");
2704        let response = self.client.get(url).query(&request.query).send().await?;
2705        Ok(GetMdSnapshotRequest::parse_response(response).await?)
2706    }
2707    /// Close A Backend Data Stream
2708    ///
2709    /// Instruct IServer to close its backend stream for the instrument when real-time snapshots are no longer needed.
2710    ///
2711    /// * Path: `POST /iserver/marketdata/unsubscribe`
2712    pub async fn close_md_stream(
2713        &self,
2714        request: CloseMdStreamRequest,
2715    ) -> anyhow::Result<CloseMdStreamResponse> {
2716        request.validate().context("parameter validation")?;
2717        let mut url = self.base_url.clone();
2718        url.path_segments_mut()
2719            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
2720            .push("iserver")
2721            .push("marketdata")
2722            .push("unsubscribe");
2723        let response = self.client.post(url).json(&request.body).send().await?;
2724        Ok(CloseMdStreamRequest::parse_response(response).await?)
2725    }
2726    /// Close All Backend Data Streams
2727    ///
2728    /// Instruct IServer to close all of its open backend data streams for all instruments.
2729    ///
2730    /// * Path: `GET /iserver/marketdata/unsubscribeall`
2731    pub async fn close_all_md_streams(
2732        &self,
2733        request: CloseAllMdStreamsRequest,
2734    ) -> anyhow::Result<CloseAllMdStreamsResponse> {
2735        request.validate().context("parameter validation")?;
2736        let mut url = self.base_url.clone();
2737        url.path_segments_mut()
2738            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
2739            .push("iserver")
2740            .push("marketdata")
2741            .push("unsubscribeall");
2742        let response = self.client.get(url).send().await?;
2743        Ok(CloseAllMdStreamsRequest::parse_response(response).await?)
2744    }
2745    /// Dismiss Server Prompt
2746    ///
2747    /// Respond to a server prompt received via ntf websocket message.
2748    ///
2749    /// * Path: `POST /iserver/notification`
2750    pub async fn ack_server_prompt(
2751        &self,
2752        request: AckServerPromptRequest,
2753    ) -> anyhow::Result<AckServerPromptResponse> {
2754        request.validate().context("parameter validation")?;
2755        let mut url = self.base_url.clone();
2756        url.path_segments_mut()
2757            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
2758            .push("iserver")
2759            .push("notification");
2760        let response = self.client.post(url).json(&request.body).send().await?;
2761        Ok(AckServerPromptRequest::parse_response(response).await?)
2762    }
2763    /// Suppress Order Reply Messages
2764    ///
2765    /// Suppress the specified order reply messages for the duration of the brokerage session.
2766    ///
2767    /// * Path: `POST /iserver/questions/suppress`
2768    pub async fn suppress_order_replies(
2769        &self,
2770        request: SuppressOrderRepliesRequest,
2771    ) -> anyhow::Result<SuppressOrderRepliesResponse> {
2772        request.validate().context("parameter validation")?;
2773        let mut url = self.base_url.clone();
2774        url.path_segments_mut()
2775            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
2776            .push("iserver")
2777            .push("questions")
2778            .push("suppress");
2779        let response = self.client.post(url).json(&request.body).send().await?;
2780        Ok(SuppressOrderRepliesRequest::parse_response(response).await?)
2781    }
2782    /// Reset Order Reply Message Suppression
2783    ///
2784    /// Removes suppression of all order reply messages that were previously suppressed in the current brokerage session.
2785    ///
2786    /// * Path: `POST /iserver/questions/suppress/reset`
2787    pub async fn reset_order_suppression(
2788        &self,
2789        request: ResetOrderSuppressionRequest,
2790    ) -> anyhow::Result<ResetOrderSuppressionResponse> {
2791        request.validate().context("parameter validation")?;
2792        let mut url = self.base_url.clone();
2793        url.path_segments_mut()
2794            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
2795            .push("iserver")
2796            .push("questions")
2797            .push("suppress")
2798            .push("reset");
2799        let response = self.client.post(url).body(Vec::<u8>::new()).send().await?;
2800        Ok(ResetOrderSuppressionRequest::parse_response(response).await?)
2801    }
2802    /// Confirm Order Reply Message
2803    ///
2804    /// Confirm an order reply message and continue with submission of order ticket.
2805    ///
2806    /// * Path: `POST /iserver/reply/{replyId}`
2807    pub async fn confirm_order_reply(
2808        &self,
2809        request: ConfirmOrderReplyRequest,
2810    ) -> anyhow::Result<ConfirmOrderReplyResponse> {
2811        request.validate().context("parameter validation")?;
2812        let mut url = self.base_url.clone();
2813        url.path_segments_mut()
2814            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
2815            .push("iserver")
2816            .push("reply")
2817            .push(&request.path.reply_id.to_string());
2818        let response = self.client.post(url).json(&request.body).send().await?;
2819        Ok(ConfirmOrderReplyRequest::parse_response(response).await?)
2820    }
2821    /// Get Valid IServer Scanner Parameters
2822    ///
2823    /// Returns an xml file containing all available parameters to be sent for the Iserver scanner request.
2824    ///
2825    /// * Path: `GET /iserver/scanner/params`
2826    pub async fn get_scanner_parameters(
2827        &self,
2828        request: GetScannerParametersRequest,
2829    ) -> anyhow::Result<GetScannerParametersResponse> {
2830        request.validate().context("parameter validation")?;
2831        let mut url = self.base_url.clone();
2832        url.path_segments_mut()
2833            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
2834            .push("iserver")
2835            .push("scanner")
2836            .push("params");
2837        let response = self.client.get(url).send().await?;
2838        Ok(GetScannerParametersRequest::parse_response(response).await?)
2839    }
2840    /// Run An IServer Market Scanner
2841    ///
2842    /// Searches for contracts according to the filters specified in /iserver/scanner/params endpoint.
2843    ///
2844    /// * Path: `POST /iserver/scanner/run`
2845    pub async fn get_scanner_results(
2846        &self,
2847        request: GetScannerResultsRequest,
2848    ) -> anyhow::Result<GetScannerResultsResponse> {
2849        request.validate().context("parameter validation")?;
2850        let mut url = self.base_url.clone();
2851        url.path_segments_mut()
2852            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
2853            .push("iserver")
2854            .push("scanner")
2855            .push("run");
2856        let response = self.client.post(url).json(&request.body).send().await?;
2857        Ok(GetScannerResultsRequest::parse_response(response).await?)
2858    }
2859    /// Search Bond Filter Information
2860    ///
2861    /// Request a list of filters relating to a given Bond issuerID. The issuerId is retrieved from /iserver/secdef/search and can be used in /iserver/secdef/info?issuerId={issuerId} for retrieving conIds.
2862    ///
2863    /// * Path: `GET /iserver/secdef/bond-filters`
2864    pub async fn get_bond_filters(
2865        &self,
2866        request: GetBondFiltersRequest,
2867    ) -> anyhow::Result<GetBondFiltersResponse> {
2868        request.validate().context("parameter validation")?;
2869        let mut url = self.base_url.clone();
2870        url.path_segments_mut()
2871            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
2872            .push("iserver")
2873            .push("secdef")
2874            .push("bond-filters");
2875        let response = self.client.get(url).query(&request.query).send().await?;
2876        Ok(GetBondFiltersRequest::parse_response(response).await?)
2877    }
2878    /// Instrument Attributes Detail
2879    ///
2880    /// Returns the attributes of the instrument.
2881    ///
2882    /// * Path: `GET /iserver/secdef/info`
2883    pub async fn get_contract_info(
2884        &self,
2885        request: GetContractInfoRequest,
2886    ) -> anyhow::Result<GetContractInfoResponse> {
2887        request.validate().context("parameter validation")?;
2888        let mut url = self.base_url.clone();
2889        url.path_segments_mut()
2890            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
2891            .push("iserver")
2892            .push("secdef")
2893            .push("info");
2894        let response = self.client.get(url).query(&request.query).send().await?;
2895        Ok(GetContractInfoRequest::parse_response(response).await?)
2896    }
2897    /// Search Instruments By Symbol
2898    ///
2899    /// Returns a list of contracts based on the search symbol provided as a query param.
2900    ///
2901    /// * Path: `GET /iserver/secdef/search`
2902    pub async fn get_contract_symbols(
2903        &self,
2904        request: GetContractSymbolsRequest,
2905    ) -> anyhow::Result<GetContractSymbolsResponse> {
2906        request.validate().context("parameter validation")?;
2907        let mut url = self.base_url.clone();
2908        url.path_segments_mut()
2909            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
2910            .push("iserver")
2911            .push("secdef")
2912            .push("search");
2913        let response = self.client.get(url).query(&request.query).send().await?;
2914        Ok(GetContractSymbolsRequest::parse_response(response).await?)
2915    }
2916    /// Search Instruments By Symbol
2917    ///
2918    /// Returns a list of contracts based on the search symbol provided as a query param.
2919    ///
2920    /// * Path: `POST /iserver/secdef/search`
2921    pub async fn get_contract_symbols_from_body(
2922        &self,
2923        request: GetContractSymbolsFromBodyRequest,
2924    ) -> anyhow::Result<GetContractSymbolsResponse> {
2925        request.validate().context("parameter validation")?;
2926        let mut url = self.base_url.clone();
2927        url.path_segments_mut()
2928            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
2929            .push("iserver")
2930            .push("secdef")
2931            .push("search");
2932        let response = self.client.post(url).json(&request.body).send().await?;
2933        Ok(GetContractSymbolsFromBodyRequest::parse_response(response).await?)
2934    }
2935    /// Search Strikes For An Underlier
2936    ///
2937    /// Returns lists of valid strikes for options contracts on a given underlier, for all currently trading expirations. The /iserver/secdef/search endpoint must be called prior for the underlying. Otherwise empty arrays will return for "puts" and "calls".
2938    ///
2939    /// * Path: `GET /iserver/secdef/strikes`
2940    pub async fn get_contract_strikes(
2941        &self,
2942        request: GetContractStrikesRequest,
2943    ) -> anyhow::Result<GetContractStrikesResponse> {
2944        request.validate().context("parameter validation")?;
2945        let mut url = self.base_url.clone();
2946        url.path_segments_mut()
2947            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
2948            .push("iserver")
2949            .push("secdef")
2950            .push("strikes");
2951        let response = self.client.get(url).query(&request.query).send().await?;
2952        Ok(GetContractStrikesRequest::parse_response(response).await?)
2953    }
2954    /// Return A Single Saved Watchlist
2955    ///
2956    /// Retrieve details of a single watchlist stored in the username's settings.
2957    ///
2958    /// * Path: `GET /iserver/watchlist`
2959    pub async fn get_specific_watchlist(
2960        &self,
2961        request: GetSpecificWatchlistRequest,
2962    ) -> anyhow::Result<GetSpecificWatchlistResponse> {
2963        request.validate().context("parameter validation")?;
2964        let mut url = self.base_url.clone();
2965        url.path_segments_mut()
2966            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
2967            .push("iserver")
2968            .push("watchlist");
2969        let response = self.client.get(url).query(&request.query).send().await?;
2970        Ok(GetSpecificWatchlistRequest::parse_response(response).await?)
2971    }
2972    /// Create A Watchlist
2973    ///
2974    /// Create a named watchlist by submitting a set of conids.
2975    ///
2976    /// * Path: `POST /iserver/watchlist`
2977    pub async fn post_new_watchlist(
2978        &self,
2979        request: PostNewWatchlistRequest,
2980    ) -> anyhow::Result<PostNewWatchlistResponse> {
2981        request.validate().context("parameter validation")?;
2982        let mut url = self.base_url.clone();
2983        url.path_segments_mut()
2984            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
2985            .push("iserver")
2986            .push("watchlist");
2987        let response = self.client.post(url).json(&request.body).send().await?;
2988        Ok(PostNewWatchlistRequest::parse_response(response).await?)
2989    }
2990    /// Delete A Saved Watchlist
2991    ///
2992    /// Delete a specified watchlist from the username's settings.
2993    ///
2994    /// * Path: `DELETE /iserver/watchlist`
2995    pub async fn delete_watchlist(
2996        &self,
2997        request: DeleteWatchlistRequest,
2998    ) -> anyhow::Result<DeleteWatchlistResponse> {
2999        request.validate().context("parameter validation")?;
3000        let mut url = self.base_url.clone();
3001        url.path_segments_mut()
3002            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
3003            .push("iserver")
3004            .push("watchlist");
3005        let response = self.client.delete(url).query(&request.query).send().await?;
3006        Ok(DeleteWatchlistRequest::parse_response(response).await?)
3007    }
3008    /// Return All Saved Watchlists
3009    ///
3010    /// Returns all saved watchlists stored on IB backend for the username in use in the current Web API session.
3011    ///
3012    /// * Path: `GET /iserver/watchlists`
3013    pub async fn get_all_watchlists(
3014        &self,
3015        request: GetAllWatchlistsRequest,
3016    ) -> anyhow::Result<GetAllWatchlistsResponse> {
3017        request.validate().context("parameter validation")?;
3018        let mut url = self.base_url.clone();
3019        url.path_segments_mut()
3020            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
3021            .push("iserver")
3022            .push("watchlists");
3023        let response = self.client.get(url).query(&request.query).send().await?;
3024        Ok(GetAllWatchlistsRequest::parse_response(response).await?)
3025    }
3026    /// Terminate Web API Session
3027    ///
3028    /// Logs the user out of the gateway session. Any further activity requires re-authentication. Discard client-side cookies upon logout.
3029    ///
3030    /// * Path: `POST /logout`
3031    pub async fn logout(&self, request: LogoutRequest) -> anyhow::Result<LogoutResponse> {
3032        request.validate().context("parameter validation")?;
3033        let mut url = self.base_url.clone();
3034        url.path_segments_mut()
3035            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
3036            .push("logout");
3037        let response = self.client.post(url).body(Vec::<u8>::new()).send().await?;
3038        Ok(LogoutRequest::parse_response(response).await?)
3039    }
3040    /// Generate An Access Token
3041    ///
3042    /// Request an access token for the IB username that has granted authorization to the consumer.
3043    ///
3044    /// * Path: `POST /oauth/access_token`
3045    pub async fn req_access_token(
3046        &self,
3047        request: ReqAccessTokenRequest,
3048    ) -> anyhow::Result<ReqAccessTokenResponse> {
3049        request.validate().context("parameter validation")?;
3050        let mut url = self.base_url.clone();
3051        url.path_segments_mut()
3052            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
3053            .push("oauth")
3054            .push("access_token");
3055        let response = self
3056            .client
3057            .post(url)
3058            .headers(
3059                http::HeaderMap::try_from(&request.header).context("building request headers")?,
3060            )
3061            .send()
3062            .await?;
3063        Ok(ReqAccessTokenRequest::parse_response(response).await?)
3064    }
3065    /// Generate A Live Session Token
3066    ///
3067    /// Generate a Live Session Token shared secret and gain access to Web API.
3068    ///
3069    /// * Path: `POST /oauth/live_session_token`
3070    pub async fn req_live_session_token(
3071        &self,
3072        request: ReqLiveSessionTokenRequest,
3073    ) -> anyhow::Result<ReqLiveSessionTokenResponse> {
3074        request.validate().context("parameter validation")?;
3075        let mut url = self.base_url.clone();
3076        url.path_segments_mut()
3077            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
3078            .push("oauth")
3079            .push("live_session_token");
3080        let response = self
3081            .client
3082            .post(url)
3083            .headers(
3084                http::HeaderMap::try_from(&request.header).context("building request headers")?,
3085            )
3086            .send()
3087            .await?;
3088        Ok(ReqLiveSessionTokenRequest::parse_response(response).await?)
3089    }
3090    /// Obtain A Request Token
3091    ///
3092    /// Request a temporary token as a third party to begin the OAuth 1.0a authorization workflow.
3093    ///
3094    /// * Path: `POST /oauth/request_token`
3095    pub async fn req_temp_token(
3096        &self,
3097        request: ReqTempTokenRequest,
3098    ) -> anyhow::Result<ReqTempTokenResponse> {
3099        request.validate().context("parameter validation")?;
3100        let mut url = self.base_url.clone();
3101        url.path_segments_mut()
3102            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
3103            .push("oauth")
3104            .push("request_token");
3105        let response = self
3106            .client
3107            .post(url)
3108            .headers(
3109                http::HeaderMap::try_from(&request.header).context("building request headers")?,
3110            )
3111            .send()
3112            .await?;
3113        Ok(ReqTempTokenRequest::parse_response(response).await?)
3114    }
3115    /// Create Access Token
3116    ///
3117    /// Generate OAuth 2.0 access tokens based on request parameters.
3118    ///
3119    /// * Path: `POST /oauth2/api/v1/token`
3120    pub async fn generate_token(
3121        &self,
3122        request: GenerateTokenRequest,
3123    ) -> anyhow::Result<GenerateTokenResponse> {
3124        request.validate().context("parameter validation")?;
3125        let mut url = self.base_url.clone();
3126        url.path_segments_mut()
3127            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
3128            .push("oauth2")
3129            .push("api")
3130            .push("v1")
3131            .push("token");
3132        let response = self.client.post(url).form(&request.body).send().await?;
3133        Ok(GenerateTokenRequest::parse_response(response).await?)
3134    }
3135    /// Account Performance (All Time Periods)
3136    ///
3137    /// Returns the performance (MTM) for the given accounts, if more than one account is passed, the result is consolidated.
3138    ///
3139    /// * Path: `POST /pa/allperiods`
3140    pub async fn get_performance_all_periods(
3141        &self,
3142        request: GetPerformanceAllPeriodsRequest,
3143    ) -> anyhow::Result<GetPerformanceAllPeriodsResponse> {
3144        request.validate().context("parameter validation")?;
3145        let mut url = self.base_url.clone();
3146        url.path_segments_mut()
3147            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
3148            .push("pa")
3149            .push("allperiods");
3150        let response = self
3151            .client
3152            .post(url)
3153            .query(&request.query)
3154            .json(&request.body)
3155            .send()
3156            .await?;
3157        Ok(GetPerformanceAllPeriodsRequest::parse_response(response).await?)
3158    }
3159    /// Account Performance
3160    ///
3161    /// Returns the performance (MTM) for the given accounts, if more than one account is passed, the result is consolidated.
3162    ///
3163    /// * Path: `POST /pa/performance`
3164    pub async fn get_single_performance_period(
3165        &self,
3166        request: GetSinglePerformancePeriodRequest,
3167    ) -> anyhow::Result<GetSinglePerformancePeriodResponse> {
3168        request.validate().context("parameter validation")?;
3169        let mut url = self.base_url.clone();
3170        url.path_segments_mut()
3171            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
3172            .push("pa")
3173            .push("performance");
3174        let response = self.client.post(url).json(&request.body).send().await?;
3175        Ok(GetSinglePerformancePeriodRequest::parse_response(response).await?)
3176    }
3177    /// Transaction History
3178    ///
3179    /// Transaction history for a given number of conids and accounts. Types of transactions include dividend payments, buy and sell transactions, transfers.
3180    ///
3181    /// * Path: `POST /pa/transactions`
3182    pub async fn get_transactions(
3183        &self,
3184        request: GetTransactionsRequest,
3185    ) -> anyhow::Result<GetTransactionsResponse> {
3186        request.validate().context("parameter validation")?;
3187        let mut url = self.base_url.clone();
3188        url.path_segments_mut()
3189            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
3190            .push("pa")
3191            .push("transactions");
3192        let response = self.client.post(url).json(&request.body).send().await?;
3193        Ok(GetTransactionsRequest::parse_response(response).await?)
3194    }
3195    /// List All Accounts
3196    ///
3197    /// return accounts
3198    ///
3199    /// * Path: `GET /portfolio/accounts`
3200    pub async fn get_all_accounts(
3201        &self,
3202        request: GetAllAccountsRequest,
3203    ) -> anyhow::Result<GetAllAccountsResponse> {
3204        request.validate().context("parameter validation")?;
3205        let mut url = self.base_url.clone();
3206        url.path_segments_mut()
3207            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
3208            .push("portfolio")
3209            .push("accounts");
3210        let response = self.client.get(url).send().await?;
3211        Ok(GetAllAccountsRequest::parse_response(response).await?)
3212    }
3213    /// All Account Positions In An Instrument
3214    ///
3215    /// Get positions in accounts for a given instrument (no secDef await control)
3216    ///
3217    /// * Path: `GET /portfolio/positions/{conid}`
3218    pub async fn get_all_accounts_for_conid(
3219        &self,
3220        request: GetAllAccountsForConidRequest,
3221    ) -> anyhow::Result<GetAllAccountsForConidResponse> {
3222        request.validate().context("parameter validation")?;
3223        let mut url = self.base_url.clone();
3224        url.path_segments_mut()
3225            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
3226            .push("portfolio")
3227            .push("positions")
3228            .push(&request.path.conid.to_string());
3229        let response = self.client.get(url).send().await?;
3230        Ok(GetAllAccountsForConidRequest::parse_response(response).await?)
3231    }
3232    /// List All Subaccounts
3233    ///
3234    /// Retrieve attributes of the subaccounts in the account structure.
3235    ///
3236    /// * Path: `GET /portfolio/subaccounts`
3237    pub async fn get_all_subaccounts(
3238        &self,
3239        request: GetAllSubaccountsRequest,
3240    ) -> anyhow::Result<GetAllSubaccountsResponse> {
3241        request.validate().context("parameter validation")?;
3242        let mut url = self.base_url.clone();
3243        url.path_segments_mut()
3244            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
3245            .push("portfolio")
3246            .push("subaccounts");
3247        let response = self.client.get(url).send().await?;
3248        Ok(GetAllSubaccountsRequest::parse_response(response).await?)
3249    }
3250    /// Portfolio Subaccounts (Large Account Structures)
3251    ///
3252    /// Used in tiered account structures (such as Financial Advisor and IBroker Accounts) to return a list of sub-accounts, paginated up to 20 accounts per page, for which the user can view position and account-related information.  This endpoint must be called prior to calling other /portfolio endpoints for those sub-accounts. If you have less than 100 sub-accounts use /portfolio/subaccounts.  To query a list of accounts the user can trade, see /iserver/accounts.
3253    ///
3254    /// * Path: `GET /portfolio/subaccounts2`
3255    pub async fn get_many_subaccounts(
3256        &self,
3257        request: GetManySubaccountsRequest,
3258    ) -> anyhow::Result<GetManySubaccountsResponse> {
3259        request.validate().context("parameter validation")?;
3260        let mut url = self.base_url.clone();
3261        url.path_segments_mut()
3262            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
3263            .push("portfolio")
3264            .push("subaccounts2");
3265        let response = self.client.get(url).query(&request.query).send().await?;
3266        Ok(GetManySubaccountsRequest::parse_response(response).await?)
3267    }
3268    /// Account Allocations
3269    ///
3270    /// Get an account's allocations by asset class, sector group, and sector.
3271    ///
3272    /// * Path: `GET /portfolio/{accountId}/allocation`
3273    pub async fn get_asset_allocation(
3274        &self,
3275        request: GetAssetAllocationRequest,
3276    ) -> anyhow::Result<GetAssetAllocationResponse> {
3277        request.validate().context("parameter validation")?;
3278        let mut url = self.base_url.clone();
3279        url.path_segments_mut()
3280            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
3281            .push("portfolio")
3282            .push(&request.path.account_id.to_string())
3283            .push("allocation");
3284        let response = self.client.get(url).query(&request.query).send().await?;
3285        Ok(GetAssetAllocationRequest::parse_response(response).await?)
3286    }
3287    /// Combination Positions
3288    ///
3289    /// Provides all positions held in the account acquired as a combination, including values such as ratios, size, and market value.
3290    ///
3291    /// * Path: `GET /portfolio/{accountId}/combo/positions`
3292    pub async fn get_combo_positions(
3293        &self,
3294        request: GetComboPositionsRequest,
3295    ) -> anyhow::Result<GetComboPositionsResponse> {
3296        request.validate().context("parameter validation")?;
3297        let mut url = self.base_url.clone();
3298        url.path_segments_mut()
3299            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
3300            .push("portfolio")
3301            .push(&request.path.account_id.to_string())
3302            .push("combo")
3303            .push("positions");
3304        let response = self.client.get(url).query(&request.query).send().await?;
3305        Ok(GetComboPositionsRequest::parse_response(response).await?)
3306    }
3307    /// Account Ledger
3308    ///
3309    /// Get the given account's ledger data detailing its balances by currency.
3310    ///
3311    /// * Path: `GET /portfolio/{accountId}/ledger`
3312    pub async fn get_portfolio_ledger(
3313        &self,
3314        request: GetPortfolioLedgerRequest,
3315    ) -> anyhow::Result<GetPortfolioLedgerResponse> {
3316        request.validate().context("parameter validation")?;
3317        let mut url = self.base_url.clone();
3318        url.path_segments_mut()
3319            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
3320            .push("portfolio")
3321            .push(&request.path.account_id.to_string())
3322            .push("ledger");
3323        let response = self.client.get(url).send().await?;
3324        Ok(GetPortfolioLedgerRequest::parse_response(response).await?)
3325    }
3326    /// Account Attributes
3327    ///
3328    /// Get a single account's attributes and capabilities.
3329    ///
3330    /// * Path: `GET /portfolio/{accountId}/meta`
3331    pub async fn get_portfolio_metadata(
3332        &self,
3333        request: GetPortfolioMetadataRequest,
3334    ) -> anyhow::Result<GetPortfolioMetadataResponse> {
3335        request.validate().context("parameter validation")?;
3336        let mut url = self.base_url.clone();
3337        url.path_segments_mut()
3338            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
3339            .push("portfolio")
3340            .push(&request.path.account_id.to_string())
3341            .push("meta");
3342        let response = self.client.get(url).send().await?;
3343        Ok(GetPortfolioMetadataRequest::parse_response(response).await?)
3344    }
3345    /// Refresh Position Cache
3346    ///
3347    /// Instructs IB to discard cached portfolio positions for a given account, so that the next request for positions delivers freshly obtained data.
3348    ///
3349    /// * Path: `POST /portfolio/{accountId}/positions/invalidate`
3350    pub async fn invalidate_position_cache(
3351        &self,
3352        request: InvalidatePositionCacheRequest,
3353    ) -> anyhow::Result<InvalidatePositionCacheResponse> {
3354        request.validate().context("parameter validation")?;
3355        let mut url = self.base_url.clone();
3356        url.path_segments_mut()
3357            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
3358            .push("portfolio")
3359            .push(&request.path.account_id.to_string())
3360            .push("positions")
3361            .push("invalidate");
3362        let response = self.client.post(url).body(Vec::<u8>::new()).send().await?;
3363        Ok(InvalidatePositionCacheRequest::parse_response(response).await?)
3364    }
3365    /// Account Positions
3366    ///
3367    /// Get all positions in an account.
3368    ///
3369    /// * Path: `GET /portfolio/{accountId}/positions/{pageId}`
3370    pub async fn get_paginated_positions(
3371        &self,
3372        request: GetPaginatedPositionsRequest,
3373    ) -> anyhow::Result<GetPaginatedPositionsResponse> {
3374        request.validate().context("parameter validation")?;
3375        let mut url = self.base_url.clone();
3376        url.path_segments_mut()
3377            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
3378            .push("portfolio")
3379            .push(&request.path.account_id.to_string())
3380            .push("positions")
3381            .push(&request.path.page_id.to_string());
3382        let response = self.client.get(url).query(&request.query).send().await?;
3383        Ok(GetPaginatedPositionsRequest::parse_response(response).await?)
3384    }
3385    /// Account Portfolio Summary
3386    ///
3387    /// Returns detailed summary of account values, by segment where appropriate.
3388    ///
3389    /// * Path: `GET /portfolio/{accountId}/summary`
3390    pub async fn get_portfolio_summary(
3391        &self,
3392        request: GetPortfolioSummaryRequest,
3393    ) -> anyhow::Result<GetPortfolioSummaryResponse> {
3394        request.validate().context("parameter validation")?;
3395        let mut url = self.base_url.clone();
3396        url.path_segments_mut()
3397            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
3398            .push("portfolio")
3399            .push(&request.path.account_id.to_string())
3400            .push("summary");
3401        let response = self.client.get(url).send().await?;
3402        Ok(GetPortfolioSummaryRequest::parse_response(response).await?)
3403    }
3404    /// Account Position In An Instrument
3405    ///
3406    /// Get position for a given instrument in a single account.
3407    ///
3408    /// * Path: `GET /portfolio/{accountid}/position/{conid}`
3409    pub async fn get_position_by_conid(
3410        &self,
3411        request: GetPositionByConidRequest,
3412    ) -> anyhow::Result<GetPositionByConidResponse> {
3413        request.validate().context("parameter validation")?;
3414        let mut url = self.base_url.clone();
3415        url.path_segments_mut()
3416            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
3417            .push("portfolio")
3418            .push(&request.path.accountid.to_string())
3419            .push("position")
3420            .push(&request.path.conid.to_string());
3421        let response = self.client.get(url).send().await?;
3422        Ok(GetPositionByConidRequest::parse_response(response).await?)
3423    }
3424    /// Account Positions (NEW)
3425    ///
3426    /// Returns a list of positions for the given account. /portfolio/accounts or /portfolio/subaccounts must be called prior to this endpoint. This endpoint provides near-real time updates and removes caching otherwise found in the /portfolio/{accountId}/positions/{pageId} endpoint.
3427    ///
3428    /// * Path: `GET /portfolio2/{accountId}/positions`
3429    pub async fn get_uncached_positions(
3430        &self,
3431        request: GetUncachedPositionsRequest,
3432    ) -> anyhow::Result<GetUncachedPositionsResponse> {
3433        request.validate().context("parameter validation")?;
3434        let mut url = self.base_url.clone();
3435        url.path_segments_mut()
3436            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
3437            .push("portfolio2")
3438            .push(&request.path.account_id.to_string())
3439            .push("positions");
3440        let response = self.client.get(url).query(&request.query).send().await?;
3441        Ok(GetUncachedPositionsRequest::parse_response(response).await?)
3442    }
3443    /// Validate SSO Web API Session
3444    ///
3445    /// Validates the current session for the SSO user.
3446    ///
3447    /// * Path: `GET /sso/validate`
3448    pub async fn get_session_validation(
3449        &self,
3450        request: GetSessionValidationRequest,
3451    ) -> anyhow::Result<GetSessionValidationResponse> {
3452        request.validate().context("parameter validation")?;
3453        let mut url = self.base_url.clone();
3454        url.path_segments_mut()
3455            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
3456            .push("sso")
3457            .push("validate");
3458        let response = self.client.get(url).send().await?;
3459        Ok(GetSessionValidationRequest::parse_response(response).await?)
3460    }
3461    /// Brokerage Keep-Alive Ping
3462    ///
3463    /// If the gateway has not received any requests for several minutes an open session will automatically timeout. The tickle endpoint pings the server to prevent the session from ending. It is expected to call this endpoint approximately every 60 seconds to maintain the connection to the brokerage session.
3464    ///
3465    /// * Path: `POST /tickle`
3466    pub async fn get_session_token(
3467        &self,
3468        request: GetSessionTokenRequest,
3469    ) -> anyhow::Result<GetSessionTokenResponse> {
3470        request.validate().context("parameter validation")?;
3471        let mut url = self.base_url.clone();
3472        url.path_segments_mut()
3473            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
3474            .push("tickle");
3475        let response = self.client.post(url).body(Vec::<u8>::new()).send().await?;
3476        Ok(GetSessionTokenRequest::parse_response(response).await?)
3477    }
3478    /// List All Stock Conids By Exchange
3479    ///
3480    /// Send out a request to retrieve all contracts made available on a requested exchange. This returns all contracts that are tradable on the exchange, even those that are not using the exchange as their primary listing.
3481    ///
3482    /// * Path: `GET /trsrv/all-conids`
3483    pub async fn get_conids_by_exchange(
3484        &self,
3485        request: GetConidsByExchangeRequest,
3486    ) -> anyhow::Result<GetConidsByExchangeResponse> {
3487        request.validate().context("parameter validation")?;
3488        let mut url = self.base_url.clone();
3489        url.path_segments_mut()
3490            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
3491            .push("trsrv")
3492            .push("all-conids");
3493        let response = self.client.get(url).query(&request.query).send().await?;
3494        Ok(GetConidsByExchangeRequest::parse_response(response).await?)
3495    }
3496    /// Search Futures By Symbol
3497    ///
3498    /// Returns a list of non-expired future contracts for given symbol(s)
3499    ///
3500    /// * Path: `GET /trsrv/futures`
3501    pub async fn get_future_by_symbol(
3502        &self,
3503        request: GetFutureBySymbolRequest,
3504    ) -> anyhow::Result<GetFutureBySymbolResponse> {
3505        request.validate().context("parameter validation")?;
3506        let mut url = self.base_url.clone();
3507        url.path_segments_mut()
3508            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
3509            .push("trsrv")
3510            .push("futures");
3511        let response = self.client.get(url).query(&request.query).send().await?;
3512        Ok(GetFutureBySymbolRequest::parse_response(response).await?)
3513    }
3514    /// Instrument Definition Detail
3515    ///
3516    /// Returns a list of security definitions for the given conids.
3517    ///
3518    /// * Path: `GET /trsrv/secdef`
3519    pub async fn get_instrument_definition(
3520        &self,
3521        request: GetInstrumentDefinitionRequest,
3522    ) -> anyhow::Result<GetInstrumentDefinitionResponse> {
3523        request.validate().context("parameter validation")?;
3524        let mut url = self.base_url.clone();
3525        url.path_segments_mut()
3526            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
3527            .push("trsrv")
3528            .push("secdef");
3529        let response = self.client.get(url).query(&request.query).send().await?;
3530        Ok(GetInstrumentDefinitionRequest::parse_response(response).await?)
3531    }
3532    /// Trading Schedule By Symbol
3533    ///
3534    /// Returns the trading schedule up to a month for the requested contract.
3535    ///
3536    /// * Path: `GET /trsrv/secdef/schedule`
3537    pub async fn get_trading_schedule_get_trsrv_secdef_schedule(
3538        &self,
3539        request: GetTradingScheduleGetTrsrvSecdefScheduleRequest,
3540    ) -> anyhow::Result<GetTradingScheduleGetTrsrvSecdefScheduleResponse> {
3541        request.validate().context("parameter validation")?;
3542        let mut url = self.base_url.clone();
3543        url.path_segments_mut()
3544            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
3545            .push("trsrv")
3546            .push("secdef")
3547            .push("schedule");
3548        let response = self.client.get(url).query(&request.query).send().await?;
3549        Ok(GetTradingScheduleGetTrsrvSecdefScheduleRequest::parse_response(response).await?)
3550    }
3551    /// Search Stocks By Symbol
3552    ///
3553    /// Returns an object contains all stock contracts for given symbol(s)
3554    ///
3555    /// * Path: `GET /trsrv/stocks`
3556    pub async fn get_stock_by_symbol(
3557        &self,
3558        request: GetStockBySymbolRequest,
3559    ) -> anyhow::Result<GetStockBySymbolResponse> {
3560        request.validate().context("parameter validation")?;
3561        let mut url = self.base_url.clone();
3562        url.path_segments_mut()
3563            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
3564            .push("trsrv")
3565            .push("stocks");
3566        let response = self.client.get(url).query(&request.query).send().await?;
3567        Ok(GetStockBySymbolRequest::parse_response(response).await?)
3568    }
3569}