bezant-api 0.3.0

Auto-generated Rust client for the IBKR Client Portal Web API
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
//!
//! AUTO-GENERATED CODE - DO NOT EDIT!
//!
//! IB REST API
//! Source: crates/bezant-spec/ibkr-openapi-3.1.json
//! Version: 2.29.0
//! Generated by `oas3-gen v0.25.3`
//!
//! The IB REST API reference documentation

use super::types::*;
use anyhow::Context;
use reqwest::{Client, Url};
use validator::Validate;
pub const BASE_URL: &str = "https://api.ibkr.com";
#[derive(Debug, Clone)]
pub struct IbRestApiClient {
    pub client: Client,
    pub base_url: Url,
}
impl Default for IbRestApiClient {
    fn default() -> Self {
        Self::new()
    }
}
impl IbRestApiClient {
    /// Create a client using the OpenAPI `servers[0]` URL.
    #[must_use]
    #[track_caller]
    pub fn new() -> Self {
        Self {
            client: Client::builder().build().expect("client"),
            base_url: Url::parse(BASE_URL).expect("valid base url"),
        }
    }
    /// Create a client with a custom base URL.
    pub fn with_base_url(base_url: impl AsRef<str>) -> anyhow::Result<Self> {
        Ok(Self {
            client: Client::builder()
                .build()
                .context("building reqwest client")?,
            base_url: Url::parse(base_url.as_ref()).context("parsing base url")?,
        })
    }
    /// Create a client from an existing `reqwest::Client`.
    pub fn with_client(base_url: impl AsRef<str>, client: Client) -> anyhow::Result<Self> {
        let url = Url::parse(base_url.as_ref()).context("parsing base url")?;
        Ok(Self {
            client,
            base_url: url,
        })
    }
    /// List Account Signatures And Owners
    ///
    /// Receive a list of all applicant names on the account and for which account and entity is represented.
    ///
    /// * Path: `GET /acesws/{accountId}/signatures-and-owners`
    pub async fn get_account_owners(
        &self,
        request: GetAccountOwnersRequest,
    ) -> anyhow::Result<GetAccountOwnersResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("acesws")
            .push(&request.path.account_id.to_string())
            .push("signatures-and-owners");
        let response = self.client.get(url).send().await?;
        Ok(GetAccountOwnersRequest::parse_response(response).await?)
    }
    /// Trading Schedule (NEW)
    ///
    /// Returns the trading schedule for the 6 total days surrounding the current trading day. Non-Trading days, such as holidays, will not be returned.
    ///
    /// * Path: `GET /contract/trading-schedule`
    pub async fn get_trading_schedule(
        &self,
        request: GetTradingScheduleRequest,
    ) -> anyhow::Result<GetTradingScheduleResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("contract")
            .push("trading-schedule");
        let response = self.client.get(url).query(&request.query).send().await?;
        Ok(GetTradingScheduleRequest::parse_response(response).await?)
    }
    /// Get Model Preset
    ///
    /// Get the preset behavior for model rebalancing.
    ///
    /// * Path: `POST /fa/fa-preset/get`
    pub async fn get_model_presets(
        &self,
        request: GetModelPresetsRequest,
    ) -> anyhow::Result<GetModelPresetsResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("fa")
            .push("fa-preset")
            .push("get");
        let response = self.client.post(url).json(&request.body).send().await?;
        Ok(GetModelPresetsRequest::parse_response(response).await?)
    }
    /// Set Model Preset
    ///
    /// Set the preset behavior for models.
    ///
    /// * Path: `POST /fa/fa-preset/save`
    pub async fn set_model_presets(
        &self,
        request: SetModelPresetsRequest,
    ) -> anyhow::Result<SetModelPresetsResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("fa")
            .push("fa-preset")
            .push("save");
        let response = self.client.post(url).json(&request.body).send().await?;
        Ok(SetModelPresetsRequest::parse_response(response).await?)
    }
    /// Get Models Accounts
    ///
    /// Request all accounts held within a model.
    ///
    /// * Path: `POST /fa/model/accounts-details`
    pub async fn get_accounts_in_model(
        &self,
        request: GetAccountsInModelRequest,
    ) -> anyhow::Result<GetAccountsInModelResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("fa")
            .push("model")
            .push("accounts-details");
        let response = self.client.post(url).json(&request.body).send().await?;
        Ok(GetAccountsInModelRequest::parse_response(response).await?)
    }
    /// Invest Account Into Model
    ///
    /// Assign an account and the amount of cash to allocate into a model.
    ///
    /// * Path: `POST /fa/model/invest-divest`
    pub async fn set_accountinvestment_in_model(
        &self,
        request: SetAccountinvestmentInModelRequest,
    ) -> anyhow::Result<SetAccountinvestmentInModelResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("fa")
            .push("model")
            .push("invest-divest");
        let response = self.client.post(url).json(&request.body).send().await?;
        Ok(SetAccountinvestmentInModelRequest::parse_response(response).await?)
    }
    /// Summary Of Accounts Invested In The Model
    ///
    /// Request the list of all accounts already invested in the provided model and a summary of their investment.
    ///
    /// * Path: `POST /fa/model/invest-divest-positions`
    pub async fn get_invested_accounts_in_model(
        &self,
        request: GetInvestedAccountsInModelRequest,
    ) -> anyhow::Result<GetInvestedAccountsInModelResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("fa")
            .push("model")
            .push("invest-divest-positions");
        let response = self.client.post(url).json(&request.body).send().await?;
        Ok(GetInvestedAccountsInModelRequest::parse_response(response).await?)
    }
    /// Request All Models
    ///
    /// Retrieve summaries for all models under the advisor account.
    ///
    /// * Path: `POST /fa/model/list`
    pub async fn get_allmodels(
        &self,
        request: GetAllmodelsRequest,
    ) -> anyhow::Result<GetAllmodelsResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("fa")
            .push("model")
            .push("list");
        let response = self.client.post(url).json(&request.body).send().await?;
        Ok(GetAllmodelsRequest::parse_response(response).await?)
    }
    /// Request Model Positions
    ///
    /// Request all positions held within the model.
    ///
    /// * Path: `POST /fa/model/positions`
    pub async fn get_all_model_positions(
        &self,
        request: GetAllModelPositionsRequest,
    ) -> anyhow::Result<GetAllModelPositionsResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("fa")
            .push("model")
            .push("positions");
        let response = self.client.post(url).json(&request.body).send().await?;
        Ok(GetAllModelPositionsRequest::parse_response(response).await?)
    }
    /// Set Model Allocations
    ///
    /// Create or Modify a model's target positions.
    ///
    /// * Path: `POST /fa/model/save`
    pub async fn set_model_target_positions(
        &self,
        request: SetModelTargetPositionsRequest,
    ) -> anyhow::Result<SetModelTargetPositionsResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("fa")
            .push("model")
            .push("save");
        let response = self.client.post(url).json(&request.body).send().await?;
        Ok(SetModelTargetPositionsRequest::parse_response(response).await?)
    }
    /// Submit Transfers
    ///
    /// Submit all pending orders to the models. This is similar to the Model page's Submit All Orders selection.
    ///
    /// * Path: `POST /fa/model/submit-transfers`
    pub async fn submit_model_orders(
        &self,
        request: SubmitModelOrdersRequest,
    ) -> anyhow::Result<SubmitModelOrdersResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("fa")
            .push("model")
            .push("submit-transfers");
        let response = self.client.post(url).json(&request.body).send().await?;
        Ok(SubmitModelOrdersRequest::parse_response(response).await?)
    }
    /// Request Model Summary
    ///
    /// Request a summary for a single model.
    ///
    /// * Path: `POST /fa/model/summary`
    pub async fn get_model_summary_single(
        &self,
        request: GetModelSummarySingleRequest,
    ) -> anyhow::Result<GetModelSummarySingleResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("fa")
            .push("model")
            .push("summary");
        let response = self.client.post(url).json(&request.body).send().await?;
        Ok(GetModelSummarySingleRequest::parse_response(response).await?)
    }
    /// Event Contract Categories
    ///
    /// Returns the category names, parent ids, and markets for Event Contracts.
    ///
    /// * Path: `GET /forecast/category/tree`
    pub async fn get_forecast_categories(
        &self,
        request: GetForecastCategoriesRequest,
    ) -> anyhow::Result<GetForecastCategoriesResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("forecast")
            .push("category")
            .push("tree");
        let response = self.client.get(url).send().await?;
        Ok(GetForecastCategoriesRequest::parse_response(response).await?)
    }
    /// Event Contract Details
    ///
    /// Provides instrument details for the specific forecast contract.
    ///
    /// * Path: `GET /forecast/contract/details`
    pub async fn get_forecast_contract(
        &self,
        request: GetForecastContractRequest,
    ) -> anyhow::Result<GetForecastContractResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("forecast")
            .push("contract")
            .push("details");
        let response = self.client.get(url).query(&request.query).send().await?;
        Ok(GetForecastContractRequest::parse_response(response).await?)
    }
    /// Provides All Contracts For Given Underlying Market.
    ///
    /// Returns all high level contract details affiliated with the underlying market conid provided.
    ///
    /// * Path: `GET /forecast/contract/market`
    pub async fn get_forecast_markets(
        &self,
        request: GetForecastMarketsRequest,
    ) -> anyhow::Result<GetForecastMarketsResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("forecast")
            .push("contract")
            .push("market");
        let response = self.client.get(url).query(&request.query).send().await?;
        Ok(GetForecastMarketsRequest::parse_response(response).await?)
    }
    /// Event Contract Rules
    ///
    /// Provides trading rules for specific event contracts.
    ///
    /// * Path: `GET /forecast/contract/rules`
    pub async fn get_forecast_rules(
        &self,
        request: GetForecastRulesRequest,
    ) -> anyhow::Result<GetForecastRulesResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("forecast")
            .push("contract")
            .push("rules");
        let response = self.client.get(url).query(&request.query).send().await?;
        Ok(GetForecastRulesRequest::parse_response(response).await?)
    }
    /// Event Contract Schedules
    ///
    /// Provides forecast trading schedules.
    ///
    /// * Path: `GET /forecast/contract/schedules`
    pub async fn get_forecast_schedule(
        &self,
        request: GetForecastScheduleRequest,
    ) -> anyhow::Result<GetForecastScheduleResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("forecast")
            .push("contract")
            .push("schedules");
        let response = self.client.get(url).query(&request.query).send().await?;
        Ok(GetForecastScheduleRequest::parse_response(response).await?)
    }
    /// Get Delivery Options
    ///
    /// Options for sending fyis to email and other devices.
    ///
    /// * Path: `GET /fyi/deliveryoptions`
    pub async fn get_fyi_delivery(
        &self,
        request: GetFyiDeliveryRequest,
    ) -> anyhow::Result<GetFyiDeliveryResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("fyi")
            .push("deliveryoptions");
        let response = self.client.get(url).send().await?;
        Ok(GetFyiDeliveryRequest::parse_response(response).await?)
    }
    /// Toggle Delivery To A Device
    ///
    /// Choose whether a particular device is enabled or disabled.
    ///
    /// * Path: `POST /fyi/deliveryoptions/device`
    pub async fn modify_fyi_delivery(
        &self,
        request: ModifyFyiDeliveryRequest,
    ) -> anyhow::Result<ModifyFyiDeliveryResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("fyi")
            .push("deliveryoptions")
            .push("device");
        let response = self.client.post(url).json(&request.body).send().await?;
        Ok(ModifyFyiDeliveryRequest::parse_response(response).await?)
    }
    /// Toggle Email Delivery
    ///
    /// Enable or disable your account's primary email to receive notifications.
    ///
    /// * Path: `PUT /fyi/deliveryoptions/email`
    pub async fn modify_fyi_emails(
        &self,
        request: ModifyFyiEmailsRequest,
    ) -> anyhow::Result<ModifyFyiEmailsResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("fyi")
            .push("deliveryoptions")
            .push("email");
        let response = self.client.put(url).query(&request.query).send().await?;
        Ok(ModifyFyiEmailsRequest::parse_response(response).await?)
    }
    /// Delete A Device
    ///
    /// Delete a specific device from our saved list of notification devices.
    ///
    /// * Path: `DELETE /fyi/deliveryoptions/{deviceId}`
    pub async fn delete_fyi_device(
        &self,
        request: DeleteFyiDeviceRequest,
    ) -> anyhow::Result<DeleteFyiDeviceResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("fyi")
            .push("deliveryoptions")
            .push(&request.path.device_id.to_string());
        let response = self.client.delete(url).send().await?;
        Ok(DeleteFyiDeviceRequest::parse_response(response).await?)
    }
    /// Get Disclaimers By FYI Type
    ///
    /// Receive additional disclaimers based on the specified typecode.
    ///
    /// * Path: `GET /fyi/disclaimer/{typecode}`
    pub async fn get_fyi_disclaimerss(
        &self,
        request: GetFyiDisclaimerssRequest,
    ) -> anyhow::Result<GetFyiDisclaimerssResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("fyi")
            .push("disclaimer")
            .push(&request.path.typecode.to_string());
        let response = self.client.get(url).send().await?;
        Ok(GetFyiDisclaimerssRequest::parse_response(response).await?)
    }
    /// Mark FYI Disclaimer Read
    ///
    /// Mark a specific disclaimer message as read.
    ///
    /// * Path: `PUT /fyi/disclaimer/{typecode}`
    pub async fn read_fyi_disclaimer(
        &self,
        request: ReadFyiDisclaimerRequest,
    ) -> anyhow::Result<ModifyFyiDeliveryResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("fyi")
            .push("disclaimer")
            .push(&request.path.typecode.to_string());
        let response = self.client.put(url).send().await?;
        Ok(ReadFyiDisclaimerRequest::parse_response(response).await?)
    }
    /// List All Notifications
    ///
    /// Get a list of available notifications.
    ///
    /// * Path: `GET /fyi/notifications`
    pub async fn get_all_fyis(
        &self,
        request: GetAllFyisRequest,
    ) -> anyhow::Result<GetAllFyisResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("fyi")
            .push("notifications");
        let response = self.client.get(url).query(&request.query).send().await?;
        Ok(GetAllFyisRequest::parse_response(response).await?)
    }
    /// Mark Notification Read
    ///
    /// Mark a particular notification message as read or unread.
    ///
    /// * Path: `PUT /fyi/notifications/{notificationID}`
    pub async fn read_fyi_notification(
        &self,
        request: ReadFyiNotificationRequest,
    ) -> anyhow::Result<ReadFyiNotificationResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("fyi")
            .push("notifications")
            .push(&request.path.notification_id.to_string());
        let response = self.client.put(url).send().await?;
        Ok(ReadFyiNotificationRequest::parse_response(response).await?)
    }
    /// Get Notification Settings
    ///
    /// Return the current choices of subscriptions for notifications.
    ///
    /// * Path: `GET /fyi/settings`
    pub async fn get_fyi_settings(
        &self,
        request: GetFyiSettingsRequest,
    ) -> anyhow::Result<GetFyiSettingsResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("fyi")
            .push("settings");
        let response = self.client.get(url).send().await?;
        Ok(GetFyiSettingsRequest::parse_response(response).await?)
    }
    /// Modify FYI Notifications
    ///
    /// Enable or disable group of notifications by the specific typecode.
    ///
    /// * Path: `POST /fyi/settings/{typecode}`
    pub async fn modify_fyi_notification(
        &self,
        request: ModifyFyiNotificationRequest,
    ) -> anyhow::Result<ModifyFyiEmailsResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("fyi")
            .push("settings")
            .push(&request.path.typecode.to_string());
        let response = self.client.post(url).json(&request.body).send().await?;
        Ok(ModifyFyiNotificationRequest::parse_response(response).await?)
    }
    /// Get Number Of Unread Notifications
    ///
    /// Returns the total number of unread notifications
    ///
    /// * Path: `GET /fyi/unreadnumber`
    pub async fn get_unread_fyis(
        &self,
        request: GetUnreadFyisRequest,
    ) -> anyhow::Result<GetUnreadFyisResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("fyi")
            .push("unreadnumber");
        let response = self.client.get(url).send().await?;
        Ok(GetUnreadFyisRequest::parse_response(response).await?)
    }
    /// Retrieve Processed Application
    ///
    /// 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`
    ///
    /// * Path: `GET /gw/api/v1/accounts`
    pub async fn get_gw_api_v1_accounts(
        &self,
        request: GetGwApiV1AccountsRequest,
    ) -> anyhow::Result<GetGwApiV1AccountsResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("gw")
            .push("api")
            .push("v1")
            .push("accounts");
        let response = self.client.get(url).query(&request.query).send().await?;
        Ok(GetGwApiV1AccountsRequest::parse_response(response).await?)
    }
    /// Create Account
    ///
    /// Submit account application. This will create brokerage account for the end user.<br><br>**Scope**: `accounts.write`<br>**Security Policy**: `Signed JWT`
    ///
    /// * Path: `POST /gw/api/v1/accounts`
    pub async fn post_gw_api_v1_accounts(
        &self,
        request: PostGwApiV1AccountsRequest,
    ) -> anyhow::Result<PostGwApiV1AccountsResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("gw")
            .push("api")
            .push("v1")
            .push("accounts");
        let response = self
            .client
            .post(url)
            .body((&request.body).to_string())
            .send()
            .await?;
        Ok(PostGwApiV1AccountsRequest::parse_response(response).await?)
    }
    /// Update Account
    ///
    /// Update information for an existing accountId<br><br>**Scope**: `accounts.write`<br>**Security Policy**: `Signed JWT`
    ///
    /// * Path: `PATCH /gw/api/v1/accounts`
    pub async fn patch_gw_api_v1_accounts(
        &self,
        request: PatchGwApiV1AccountsRequest,
    ) -> anyhow::Result<PostGwApiV1AccountsResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("gw")
            .push("api")
            .push("v1")
            .push("accounts");
        let response = self
            .client
            .patch(url)
            .body((&request.body).to_string())
            .send()
            .await?;
        Ok(PatchGwApiV1AccountsRequest::parse_response(response).await?)
    }
    /// Submit General Agreements And Disclosures
    ///
    /// 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`
    ///
    /// * Path: `POST /gw/api/v1/accounts/documents`
    pub async fn post_gw_api_v1_accounts_documents(
        &self,
        request: PostGwApiV1AccountsDocumentsRequest,
    ) -> anyhow::Result<PostGwApiV1AccountsResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("gw")
            .push("api")
            .push("v1")
            .push("accounts")
            .push("documents");
        let response = self
            .client
            .post(url)
            .body((&request.body).to_string())
            .send()
            .await?;
        Ok(PostGwApiV1AccountsDocumentsRequest::parse_response(response).await?)
    }
    /// Get Login Messages
    ///
    /// Query all accounts associated with ‘Client ID’ that have incomplete login message<br><br>**Scope**: `accounts.read`<br>**Security Policy**: `HTTPS`
    ///
    /// * Path: `GET /gw/api/v1/accounts/login-messages`
    pub async fn get_gw_api_v1_accounts_login_messages(
        &self,
        request: GetGwApiV1AccountsLoginMessagesRequest,
    ) -> anyhow::Result<GetGwApiV1AccountsLoginMessagesResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("gw")
            .push("api")
            .push("v1")
            .push("accounts")
            .push("login-messages");
        let response = self.client.get(url).query(&request.query).send().await?;
        Ok(GetGwApiV1AccountsLoginMessagesRequest::parse_response(response).await?)
    }
    /// Get Status Of Accounts
    ///
    /// Query status of all accounts associated with ‘Client ID'<br><br>**Scope**: `accounts.read`<br>**Security Policy**: `HTTPS`
    ///
    /// * Path: `GET /gw/api/v1/accounts/status`
    pub async fn get_gw_api_v1_accounts_status(
        &self,
        request: GetGwApiV1AccountsStatusRequest,
    ) -> anyhow::Result<GetGwApiV1AccountsStatusResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("gw")
            .push("api")
            .push("v1")
            .push("accounts")
            .push("status");
        let response = self.client.get(url).query(&request.query).send().await?;
        Ok(GetGwApiV1AccountsStatusRequest::parse_response(response).await?)
    }
    /// Get Account Information
    ///
    /// <br>**Scope**: `accounts.read`<br>**Security Policy**: `HTTPS`
    ///
    /// * Path: `GET /gw/api/v1/accounts/{accountId}/details`
    pub async fn get_gw_api_v1_accounts_accountid_details(
        &self,
        request: GetGwApiV1AccountsAccountidDetailsRequest,
    ) -> anyhow::Result<GetGwApiV1AccountsAccountidDetailsResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("gw")
            .push("api")
            .push("v1")
            .push("accounts")
            .push(&request.path.account_id.to_string())
            .push("details");
        let response = self.client.get(url).send().await?;
        Ok(GetGwApiV1AccountsAccountidDetailsRequest::parse_response(response).await?)
    }
    /// Retrieve Au10Tix URL
    ///
    /// Generate URL address to complete real-time KYC verification using Au10Tix<br><br>**Scope**: `accounts.read`<br>**Security Policy**: `HTTPS`
    ///
    /// * Path: `GET /gw/api/v1/accounts/{accountId}/kyc`
    pub async fn get_gw_api_v1_accounts_accountid_kyc(
        &self,
        request: GetGwApiV1AccountsAccountidKycRequest,
    ) -> anyhow::Result<GetGwApiV1AccountsAccountidKycResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("gw")
            .push("api")
            .push("v1")
            .push("accounts")
            .push(&request.path.account_id.to_string())
            .push("kyc");
        let response = self.client.get(url).send().await?;
        Ok(GetGwApiV1AccountsAccountidKycRequest::parse_response(response).await?)
    }
    /// Get Login Message By Account
    ///
    /// Query login messages assigned by accountId<br><br>**Scope**: `accounts.read`<br>**Security Policy**: `HTTPS`
    ///
    /// * Path: `GET /gw/api/v1/accounts/{accountId}/login-messages`
    pub async fn get_gw_api_v1_accounts_accountid_login_messages(
        &self,
        request: GetGwApiV1AccountsAccountidLoginMessagesRequest,
    ) -> anyhow::Result<GetGwApiV1AccountsLoginMessagesResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("gw")
            .push("api")
            .push("v1")
            .push("accounts")
            .push(&request.path.account_id.to_string())
            .push("login-messages");
        let response = self.client.get(url).query(&request.query).send().await?;
        Ok(GetGwApiV1AccountsAccountidLoginMessagesRequest::parse_response(response).await?)
    }
    /// Get Status By Account
    ///
    /// Query status of account by accountId<br><br>**Scope**: `accounts.read`<br>**Security Policy**: `HTTPS`
    ///
    /// * Path: `GET /gw/api/v1/accounts/{accountId}/status`
    pub async fn get_gw_api_v1_accounts_accountid_status(
        &self,
        request: GetGwApiV1AccountsAccountidStatusRequest,
    ) -> anyhow::Result<GetGwApiV1AccountsAccountidStatusResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("gw")
            .push("api")
            .push("v1")
            .push("accounts")
            .push(&request.path.account_id.to_string())
            .push("status");
        let response = self.client.get(url).send().await?;
        Ok(GetGwApiV1AccountsAccountidStatusRequest::parse_response(response).await?)
    }
    /// Update Status By Account
    ///
    /// Query status of account by accountId<br><br>**Scope**: `accounts.write`<br>**Security Policy**: `Signed JWT`
    ///
    /// * Path: `PATCH /gw/api/v1/accounts/{accountId}/status`
    pub async fn patch_gw_api_v1_accounts_accountid_status(
        &self,
        request: PatchGwApiV1AccountsAccountidStatusRequest,
    ) -> anyhow::Result<GetGwApiV1AccountsAccountidStatusResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("gw")
            .push("api")
            .push("v1")
            .push("accounts")
            .push(&request.path.account_id.to_string())
            .push("status");
        let response = self
            .client
            .patch(url)
            .body((&request.body).to_string())
            .send()
            .await?;
        Ok(PatchGwApiV1AccountsAccountidStatusRequest::parse_response(response).await?)
    }
    /// Get Registration Tasks
    ///
    /// Query registration tasks assigned to account and pending tasks that are required for account approval<br><br>**Scope**: `accounts.read`<br>**Security Policy**: `HTTPS`
    ///
    /// * Path: `GET /gw/api/v1/accounts/{accountId}/tasks`
    pub async fn get_gw_api_v1_accounts_accountid_tasks(
        &self,
        request: GetGwApiV1AccountsAccountidTasksRequest,
    ) -> anyhow::Result<GetGwApiV1AccountsAccountidTasksResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("gw")
            .push("api")
            .push("v1")
            .push("accounts")
            .push(&request.path.account_id.to_string())
            .push("tasks");
        let response = self.client.get(url).query(&request.query).send().await?;
        Ok(GetGwApiV1AccountsAccountidTasksRequest::parse_response(response).await?)
    }
    /// Assign Tasks
    ///
    /// Task can be assigned from this api<br><br>**Scope**: `accounts.write`<br>**Security Policy**: `Signed JWT`
    ///
    /// * Path: `POST /gw/api/v1/accounts/{accountId}/tasks`
    pub async fn post_gw_api_v1_accounts_accountid_tasks(
        &self,
        request: PostGwApiV1AccountsAccountidTasksRequest,
    ) -> anyhow::Result<PostGwApiV1AccountsAccountidTasksResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("gw")
            .push("api")
            .push("v1")
            .push("accounts")
            .push(&request.path.account_id.to_string())
            .push("tasks");
        let response = self
            .client
            .post(url)
            .body((&request.body).to_string())
            .send()
            .await?;
        Ok(PostGwApiV1AccountsAccountidTasksRequest::parse_response(response).await?)
    }
    /// Update Tasks Status
    ///
    /// Task status can be updated from this api<br><br>**Scope**: `accounts.write`<br>**Security Policy**: `Signed JWT`
    ///
    /// * Path: `PATCH /gw/api/v1/accounts/{accountId}/tasks`
    pub async fn patch_gw_api_v1_accounts_accountid_tasks(
        &self,
        request: PatchGwApiV1AccountsAccountidTasksRequest,
    ) -> anyhow::Result<PostGwApiV1AccountsAccountidTasksResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("gw")
            .push("api")
            .push("v1")
            .push("accounts")
            .push(&request.path.account_id.to_string())
            .push("tasks");
        let response = self
            .client
            .patch(url)
            .body((&request.body).to_string())
            .send()
            .await?;
        Ok(PatchGwApiV1AccountsAccountidTasksRequest::parse_response(response).await?)
    }
    /// View Cash Balances
    ///
    /// View available cash for withdrawal and account equity value by accountId<br><br>**Scope**: `balances.read`<br>**Security Policy**: `Signed JWT`
    ///
    /// * Path: `POST /gw/api/v1/balances/query`
    pub async fn post_gw_api_v1_balances_query(
        &self,
        request: PostGwApiV1BalancesQueryRequest,
    ) -> anyhow::Result<PostGwApiV1BalancesQueryResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("gw")
            .push("api")
            .push("v1")
            .push("balances")
            .push("query");
        let response = self
            .client
            .post(url)
            .query(&request.query)
            .json(&request.body)
            .send()
            .await?;
        Ok(PostGwApiV1BalancesQueryRequest::parse_response(response).await?)
    }
    /// Manage Bank Instructions
    ///
    /// 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`
    ///
    /// * Path: `POST /gw/api/v1/bank-instructions`
    pub async fn post_gw_api_v1_bank_instructions(
        &self,
        request: PostGwApiV1BankInstructionsRequest,
    ) -> anyhow::Result<PostGwApiV1BankInstructionsResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("gw")
            .push("api")
            .push("v1")
            .push("bank-instructions");
        let response = self
            .client
            .post(url)
            .query(&request.query)
            .json(&request.body)
            .send()
            .await?;
        Ok(PostGwApiV1BankInstructionsRequest::parse_response(response).await?)
    }
    /// View Bank Instructions
    ///
    /// View active bank instructions for an accountId.<br><br>**Scope**: `bank-instructions.read`<br>**Security Policy**: `Signed JWT`
    ///
    /// * Path: `POST /gw/api/v1/bank-instructions/query`
    pub async fn post_gw_api_v1_bank_instructions_query(
        &self,
        request: PostGwApiV1BankInstructionsQueryRequest,
    ) -> anyhow::Result<PostGwApiV1BankInstructionsQueryResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("gw")
            .push("api")
            .push("v1")
            .push("bank-instructions")
            .push("query");
        let response = self
            .client
            .post(url)
            .query(&request.query)
            .json(&request.body)
            .send()
            .await?;
        Ok(PostGwApiV1BankInstructionsQueryRequest::parse_response(response).await?)
    }
    /// Creates Multiple Banking Instructions(ach, Delete, Micro-amount, Predefined-destination-instruction)
    ///
    /// <br>**Scope**: `bank-instructions.write`<br>**Security Policy**: `Signed JWT`
    ///
    /// * Path: `POST /gw/api/v1/bank-instructions:bulk`
    pub async fn post_gw_api_v1_bank_instructions_bulk(
        &self,
        request: PostGwApiV1BankInstructionsBulkRequest,
    ) -> anyhow::Result<PostGwApiV1BankInstructionsBulkResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("gw")
            .push("api")
            .push("v1")
            .push("bank-instructions:bulk");
        let response = self
            .client
            .post(url)
            .query(&request.query)
            .json(&request.body)
            .send()
            .await?;
        Ok(PostGwApiV1BankInstructionsBulkRequest::parse_response(response).await?)
    }
    /// Get Status For ClientInstructionId
    ///
    /// Retrieve status of request by clientInstructionId.<br><br>**Scope**: `instructions.read`<br>**Security Policy**: `HTTPS`
    ///
    /// * Path: `GET /gw/api/v1/client-instructions/{clientInstructionId}`
    pub async fn get_gw_api_v1_client_instructions_clientinstructionid(
        &self,
        request: GetGwApiV1ClientInstructionsClientinstructionidRequest,
    ) -> anyhow::Result<GetGwApiV1InstructionsInstructionidResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("gw")
            .push("api")
            .push("v1")
            .push("client-instructions")
            .push(&request.path.client_instruction_id.to_string());
        let response = self.client.get(url).query(&request.query).send().await?;
        Ok(
            GetGwApiV1ClientInstructionsClientinstructionidRequest::parse_response(response)
                .await?,
        )
    }
    /// Echo A Request With HTTPS Security Policy Back After Validation.
    ///
    /// <br>**Scope**: `echo.read`<br>**Security Policy**: `HTTPS`
    ///
    /// * Path: `GET /gw/api/v1/echo/https`
    pub async fn get_gw_api_v1_echo_https(
        &self,
        request: GetGwApiV1EchoHttpsRequest,
    ) -> anyhow::Result<GetGwApiV1EchoHttpsResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("gw")
            .push("api")
            .push("v1")
            .push("echo")
            .push("https");
        let response = self.client.get(url).send().await?;
        Ok(GetGwApiV1EchoHttpsRequest::parse_response(response).await?)
    }
    /// Echo A Request With Signed JWT Security Policy Back After Validation.
    ///
    /// <br>**Scope**: `echo.write`<br>**Security Policy**: `Signed JWT`
    ///
    /// * Path: `POST /gw/api/v1/echo/signed-jwt`
    pub async fn post_gw_api_v1_echo_signed_jwt(
        &self,
        request: PostGwApiV1EchoSignedJwtRequest,
    ) -> anyhow::Result<GetGwApiV1EchoHttpsResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("gw")
            .push("api")
            .push("v1")
            .push("echo")
            .push("signed-jwt");
        let response = self
            .client
            .post(url)
            .body((&request.body).to_string())
            .send()
            .await?;
        Ok(PostGwApiV1EchoSignedJwtRequest::parse_response(response).await?)
    }
    /// Get A List Of Participating Brokers For The Given Asset Type
    ///
    /// Get list of brokers supported for given asset transfer type<br><br>**Scope**: `enumerations.read`<br>**Security Policy**: `HTTPS`
    ///
    /// * Path: `GET /gw/api/v1/enumerations/complex-asset-transfer`
    pub async fn get_gw_api_v1_enumerations_complex_asset_transfer(
        &self,
        request: GetGwApiV1EnumerationsComplexAssetTransferRequest,
    ) -> anyhow::Result<GetGwApiV1EnumerationsComplexAssetTransferResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("gw")
            .push("api")
            .push("v1")
            .push("enumerations")
            .push("complex-asset-transfer");
        let response = self.client.get(url).query(&request.query).send().await?;
        Ok(GetGwApiV1EnumerationsComplexAssetTransferRequest::parse_response(response).await?)
    }
    /// Get Enumerations
    ///
    /// 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`
    ///
    /// * Path: `GET /gw/api/v1/enumerations/{enumerationType}`
    pub async fn get_gw_api_v1_enumerations_enumerationtype(
        &self,
        request: GetGwApiV1EnumerationsEnumerationtypeRequest,
    ) -> anyhow::Result<GetGwApiV1EnumerationsEnumerationtypeResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("gw")
            .push("api")
            .push("v1")
            .push("enumerations")
            .push(&request.path.enumeration_type.to_string());
        let response = self.client.get(url).query(&request.query).send().await?;
        Ok(GetGwApiV1EnumerationsEnumerationtypeRequest::parse_response(response).await?)
    }
    /// Transfer Positions Externally (ACATS, ATON, FOP, DWAC, Complex Asset Transfer)
    ///
    /// 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`
    ///
    /// * Path: `POST /gw/api/v1/external-asset-transfers`
    pub async fn post_gw_api_v1_external_asset_transfers(
        &self,
        request: PostGwApiV1ExternalAssetTransfersRequest,
    ) -> anyhow::Result<PostGwApiV1BankInstructionsResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("gw")
            .push("api")
            .push("v1")
            .push("external-asset-transfers");
        let response = self
            .client
            .post(url)
            .query(&request.query)
            .json(&request.body)
            .send()
            .await?;
        Ok(PostGwApiV1ExternalAssetTransfersRequest::parse_response(response).await?)
    }
    /// Creates Multiple External Asset Transfers (Fop, DWAC And Complex Asset Transfer)
    ///
    /// <br>**Scope**: `transfers.write`<br>**Security Policy**: `Signed JWT`
    ///
    /// * Path: `POST /gw/api/v1/external-asset-transfers:bulk`
    pub async fn post_gw_api_v1_external_asset_transfers_bulk(
        &self,
        request: PostGwApiV1ExternalAssetTransfersBulkRequest,
    ) -> anyhow::Result<PostGwApiV1BankInstructionsBulkResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("gw")
            .push("api")
            .push("v1")
            .push("external-asset-transfers:bulk");
        let response = self
            .client
            .post(url)
            .query(&request.query)
            .json(&request.body)
            .send()
            .await?;
        Ok(PostGwApiV1ExternalAssetTransfersBulkRequest::parse_response(response).await?)
    }
    /// Transfer Cash Externally
    ///
    /// 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`
    ///
    /// * Path: `POST /gw/api/v1/external-cash-transfers`
    pub async fn post_gw_api_v1_external_cash_transfers(
        &self,
        request: PostGwApiV1ExternalCashTransfersRequest,
    ) -> anyhow::Result<PostGwApiV1BankInstructionsResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("gw")
            .push("api")
            .push("v1")
            .push("external-cash-transfers");
        let response = self
            .client
            .post(url)
            .query(&request.query)
            .json(&request.body)
            .send()
            .await?;
        Ok(PostGwApiV1ExternalCashTransfersRequest::parse_response(response).await?)
    }
    /// View Cash Balances
    ///
    /// View available cash for withdrawal with and without margin loan by accountId<br><br>**Scope**: `transfers.read`<br>**Security Policy**: `Signed JWT`
    ///
    /// * Path: `POST /gw/api/v1/external-cash-transfers/query`
    pub async fn post_gw_api_v1_external_cash_transfers_query(
        &self,
        request: PostGwApiV1ExternalCashTransfersQueryRequest,
    ) -> anyhow::Result<PostGwApiV1ExternalCashTransfersQueryResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("gw")
            .push("api")
            .push("v1")
            .push("external-cash-transfers")
            .push("query");
        let response = self
            .client
            .post(url)
            .query(&request.query)
            .json(&request.body)
            .send()
            .await?;
        Ok(PostGwApiV1ExternalCashTransfersQueryRequest::parse_response(response).await?)
    }
    /// Creates Multiple External Cash Transfers (Deposit And Withdraw Fund)
    ///
    /// <br>**Scope**: `transfers.write`<br>**Security Policy**: `Signed JWT`
    ///
    /// * Path: `POST /gw/api/v1/external-cash-transfers:bulk`
    pub async fn post_gw_api_v1_external_cash_transfers_bulk(
        &self,
        request: PostGwApiV1ExternalCashTransfersBulkRequest,
    ) -> anyhow::Result<PostGwApiV1BankInstructionsBulkResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("gw")
            .push("api")
            .push("v1")
            .push("external-cash-transfers:bulk");
        let response = self
            .client
            .post(url)
            .query(&request.query)
            .json(&request.body)
            .send()
            .await?;
        Ok(PostGwApiV1ExternalCashTransfersBulkRequest::parse_response(response).await?)
    }
    /// Get Forms
    ///
    /// Get forms<br><br>**Scope**: `accounts.read` OR `forms.read`<br>**Security Policy**: `HTTPS`
    ///
    /// * Path: `GET /gw/api/v1/forms`
    pub async fn get_gw_api_v1_forms(
        &self,
        request: GetGwApiV1FormsRequest,
    ) -> anyhow::Result<GetGwApiV1FormsResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("gw")
            .push("api")
            .push("v1")
            .push("forms");
        let response = self.client.get(url).query(&request.query).send().await?;
        Ok(GetGwApiV1FormsRequest::parse_response(response).await?)
    }
    /// Get Required Forms
    ///
    /// Get required forms<br><br>**Scope**: `accounts.read`<br>**Security Policy**: `HTTPS`
    ///
    /// * Path: `GET /gw/api/v1/forms/required-forms`
    pub async fn get_gw_api_v1_forms_required_forms(
        &self,
        request: GetGwApiV1FormsRequiredFormsRequest,
    ) -> anyhow::Result<GetGwApiV1FormsRequiredFormsResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("gw")
            .push("api")
            .push("v1")
            .push("forms")
            .push("required-forms");
        let response = self.client.get(url).query(&request.query).send().await?;
        Ok(GetGwApiV1FormsRequiredFormsRequest::parse_response(response).await?)
    }
    /// Get Status For InstructionSetId
    ///
    /// Retrieve status of all requests associated with instructionSetId.<br><br>**Scope**: `instructions.read`<br>**Security Policy**: `HTTPS`
    ///
    /// * Path: `GET /gw/api/v1/instruction-sets/{instructionSetId}`
    pub async fn get_gw_api_v1_instruction_sets_instructionsetid(
        &self,
        request: GetGwApiV1InstructionSetsInstructionsetidRequest,
    ) -> anyhow::Result<GetGwApiV1InstructionSetsInstructionsetidResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("gw")
            .push("api")
            .push("v1")
            .push("instruction-sets")
            .push(&request.path.instruction_set_id.to_string());
        let response = self.client.get(url).query(&request.query).send().await?;
        Ok(GetGwApiV1InstructionSetsInstructionsetidRequest::parse_response(response).await?)
    }
    /// Cancel Request
    ///
    /// Cancel request by instructionId.<br><br>**Scope**: `instructions.write`<br>**Security Policy**: `Signed JWT`
    ///
    /// * Path: `POST /gw/api/v1/instructions/cancel`
    pub async fn post_gw_api_v1_instructions_cancel(
        &self,
        request: PostGwApiV1InstructionsCancelRequest,
    ) -> anyhow::Result<PostGwApiV1InstructionsCancelResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("gw")
            .push("api")
            .push("v1")
            .push("instructions")
            .push("cancel");
        let response = self
            .client
            .post(url)
            .query(&request.query)
            .json(&request.body)
            .send()
            .await?;
        Ok(PostGwApiV1InstructionsCancelRequest::parse_response(response).await?)
    }
    /// Creates Multiple Cancel Instructions
    ///
    /// <br>**Scope**: `instructions.write`<br>**Security Policy**: `Signed JWT`
    ///
    /// * Path: `POST /gw/api/v1/instructions/cancel:bulk`
    pub async fn post_gw_api_v1_instructions_cancel_bulk(
        &self,
        request: PostGwApiV1InstructionsCancelBulkRequest,
    ) -> anyhow::Result<PostGwApiV1BankInstructionsBulkResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("gw")
            .push("api")
            .push("v1")
            .push("instructions")
            .push("cancel:bulk");
        let response = self
            .client
            .post(url)
            .query(&request.query)
            .json(&request.body)
            .send()
            .await?;
        Ok(PostGwApiV1InstructionsCancelBulkRequest::parse_response(response).await?)
    }
    /// Get Transaction History
    ///
    /// Query list of recent transactions (up to 30 days) based on accountId.<br><br>**Scope**: `instructions.read`<br>**Security Policy**: `Signed JWT`
    ///
    /// * Path: `POST /gw/api/v1/instructions/query`
    pub async fn post_gw_api_v1_instructions_query(
        &self,
        request: PostGwApiV1InstructionsQueryRequest,
    ) -> anyhow::Result<PostGwApiV1BankInstructionsResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("gw")
            .push("api")
            .push("v1")
            .push("instructions")
            .push("query");
        let response = self
            .client
            .post(url)
            .query(&request.query)
            .json(&request.body)
            .send()
            .await?;
        Ok(PostGwApiV1InstructionsQueryRequest::parse_response(response).await?)
    }
    /// Get Status For InstructionId
    ///
    /// Retrieve status of request by instructionId<br><br>**Scope**: `instructions.read`<br>**Security Policy**: `HTTPS`
    ///
    /// * Path: `GET /gw/api/v1/instructions/{instructionId}`
    pub async fn get_gw_api_v1_instructions_instructionid(
        &self,
        request: GetGwApiV1InstructionsInstructionidRequest,
    ) -> anyhow::Result<GetGwApiV1InstructionsInstructionidResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("gw")
            .push("api")
            .push("v1")
            .push("instructions")
            .push(&request.path.instruction_id.to_string());
        let response = self.client.get(url).query(&request.query).send().await?;
        Ok(GetGwApiV1InstructionsInstructionidRequest::parse_response(response).await?)
    }
    /// Transfer Positions Internally
    ///
    /// Transfer positions internally between two accounts with Interactive Brokers<br><br>**Scope**: `transfers.write`<br>**Security Policy**: `Signed JWT`
    ///
    /// * Path: `POST /gw/api/v1/internal-asset-transfers`
    pub async fn post_gw_api_v1_internal_asset_transfers(
        &self,
        request: PostGwApiV1InternalAssetTransfersRequest,
    ) -> anyhow::Result<PostGwApiV1BankInstructionsResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("gw")
            .push("api")
            .push("v1")
            .push("internal-asset-transfers");
        let response = self
            .client
            .post(url)
            .query(&request.query)
            .json(&request.body)
            .send()
            .await?;
        Ok(PostGwApiV1InternalAssetTransfersRequest::parse_response(response).await?)
    }
    /// Creates Multiple Internal Asset Transfers Between The Provided Account Id Pairs
    ///
    /// <br>**Scope**: `transfers.write`<br>**Security Policy**: `Signed JWT`
    ///
    /// * Path: `POST /gw/api/v1/internal-asset-transfers:bulk`
    pub async fn post_gw_api_v1_internal_asset_transfers_bulk(
        &self,
        request: PostGwApiV1InternalAssetTransfersBulkRequest,
    ) -> anyhow::Result<PostGwApiV1BankInstructionsBulkResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("gw")
            .push("api")
            .push("v1")
            .push("internal-asset-transfers:bulk");
        let response = self
            .client
            .post(url)
            .query(&request.query)
            .json(&request.body)
            .send()
            .await?;
        Ok(PostGwApiV1InternalAssetTransfersBulkRequest::parse_response(response).await?)
    }
    /// Transfer Cash Internally
    ///
    /// Transfer cash internally between two accounts with Interactive Brokers.<br><br>**Scope**: `transfers.write`<br>**Security Policy**: `Signed JWT`
    ///
    /// * Path: `POST /gw/api/v1/internal-cash-transfers`
    pub async fn post_gw_api_v1_internal_cash_transfers(
        &self,
        request: PostGwApiV1InternalCashTransfersRequest,
    ) -> anyhow::Result<PostGwApiV1InstructionsCancelResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("gw")
            .push("api")
            .push("v1")
            .push("internal-cash-transfers");
        let response = self
            .client
            .post(url)
            .query(&request.query)
            .json(&request.body)
            .send()
            .await?;
        Ok(PostGwApiV1InternalCashTransfersRequest::parse_response(response).await?)
    }
    /// Creates Multiple Internal Cash Transfers Between The Provided Account Id Pairs
    ///
    /// <br>**Scope**: `transfers.write`<br>**Security Policy**: `Signed JWT`
    ///
    /// * Path: `POST /gw/api/v1/internal-cash-transfers:bulk`
    pub async fn post_gw_api_v1_internal_cash_transfers_bulk(
        &self,
        request: PostGwApiV1InternalCashTransfersBulkRequest,
    ) -> anyhow::Result<PostGwApiV1BankInstructionsBulkResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("gw")
            .push("api")
            .push("v1")
            .push("internal-cash-transfers:bulk");
        let response = self
            .client
            .post(url)
            .query(&request.query)
            .json(&request.body)
            .send()
            .await?;
        Ok(PostGwApiV1InternalCashTransfersBulkRequest::parse_response(response).await?)
    }
    /// Get Participating Banks
    ///
    /// Get list of banks which support banking connection with Interactive Brokers.<br><br>**Scope**: `enumerations.read`<br>**Security Policy**: `HTTPS`
    ///
    /// * Path: `GET /gw/api/v1/participating-banks`
    pub async fn get_gw_api_v1_participating_banks(
        &self,
        request: GetGwApiV1ParticipatingBanksRequest,
    ) -> anyhow::Result<GetGwApiV1ParticipatingBanksResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("gw")
            .push("api")
            .push("v1")
            .push("participating-banks");
        let response = self.client.get(url).query(&request.query).send().await?;
        Ok(GetGwApiV1ParticipatingBanksRequest::parse_response(response).await?)
    }
    /// Get Requests' Details By Timeframe
    ///
    /// Fetch Requests' Details By Timeframe<br><br>**Scope**: `accounts.read`<br>**Security Policy**: `HTTPS`
    ///
    /// * Path: `GET /gw/api/v1/requests`
    pub async fn get_gw_api_v1_requests(
        &self,
        request: GetGwApiV1RequestsRequest,
    ) -> anyhow::Result<GetGwApiV1RequestsResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("gw")
            .push("api")
            .push("v1")
            .push("requests");
        let response = self.client.get(url).query(&request.query).send().await?;
        Ok(GetGwApiV1RequestsRequest::parse_response(response).await?)
    }
    /// Update Status Of An Am Request
    ///
    /// This api will be used to update the status of am request<br><br>**Scope**: `accounts.read`<br>**Security Policy**: `Signed JWT`
    ///
    /// * Path: `PATCH /gw/api/v1/requests/{requestId}/status`
    pub async fn patch_gw_api_v1_requests_requestid_status(
        &self,
        request: PatchGwApiV1RequestsRequestidStatusRequest,
    ) -> anyhow::Result<PatchGwApiV1RequestsRequestidStatusResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("gw")
            .push("api")
            .push("v1")
            .push("requests")
            .push(&request.path.request_id.to_string())
            .push("status");
        let response = self
            .client
            .patch(url)
            .body((&request.body).to_string())
            .send()
            .await?;
        Ok(PatchGwApiV1RequestsRequestidStatusRequest::parse_response(response).await?)
    }
    /// Apply PTC CSV
    ///
    /// 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`
    ///
    /// * Path: `POST /gw/api/v1/restrictions`
    pub async fn apply_csv(&self, request: ApplyCsvRequest) -> anyhow::Result<ApplyCsvResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("gw")
            .push("api")
            .push("v1")
            .push("restrictions");
        let response = self
            .client
            .post(url)
            .headers(
                http::HeaderMap::try_from(&request.header).context("building request headers")?,
            )
            .body((&request.body).to_string())
            .send()
            .await?;
        Ok(ApplyCsvRequest::parse_response(response).await?)
    }
    /// Verify PTC CSV
    ///
    /// 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`
    ///
    /// * Path: `POST /gw/api/v1/restrictions/verify`
    pub async fn verify_csv(&self, request: VerifyCsvRequest) -> anyhow::Result<ApplyCsvResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("gw")
            .push("api")
            .push("v1")
            .push("restrictions")
            .push("verify");
        let response = self
            .client
            .post(url)
            .headers(
                http::HeaderMap::try_from(&request.header).context("building request headers")?,
            )
            .json(&request.body)
            .send()
            .await?;
        Ok(VerifyCsvRequest::parse_response(response).await?)
    }
    /// Create SSO Browser Session.
    ///
    /// <br>**Scope**: `sso-browser-sessions.write`<br>**Security Policy**: `Signed JWT`
    ///
    /// * Path: `POST /gw/api/v1/sso-browser-sessions`
    pub async fn post_gw_api_v1_sso_browser_sessions(
        &self,
        request: PostGwApiV1SsoBrowserSessionsRequest,
    ) -> anyhow::Result<PostGwApiV1SsoBrowserSessionsResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("gw")
            .push("api")
            .push("v1")
            .push("sso-browser-sessions");
        let response = self
            .client
            .post(url)
            .headers(
                http::HeaderMap::try_from(&request.header).context("building request headers")?,
            )
            .body((&request.body).to_string())
            .send()
            .await?;
        Ok(PostGwApiV1SsoBrowserSessionsRequest::parse_response(response).await?)
    }
    /// Create A New SSO Session On Behalf Of An End-user.
    ///
    /// <br>**Scope**: `sso-sessions.write`<br>**Security Policy**: `Signed JWT`
    ///
    /// * Path: `POST /gw/api/v1/sso-sessions`
    pub async fn post_gw_api_v1_sso_sessions(
        &self,
        request: PostGwApiV1SsoSessionsRequest,
    ) -> anyhow::Result<PostGwApiV1SsoSessionsResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("gw")
            .push("api")
            .push("v1")
            .push("sso-sessions");
        let response = self
            .client
            .post(url)
            .headers(
                http::HeaderMap::try_from(&request.header).context("building request headers")?,
            )
            .body((&request.body).to_string())
            .send()
            .await?;
        Ok(PostGwApiV1SsoSessionsRequest::parse_response(response).await?)
    }
    /// Generates Statements In Supported Formats Based On Request Parameters.
    ///
    /// <br>**Scope**: `statements.read` OR `statements.write` OR `reports.write`<br>**Security Policy**: `Signed JWT`
    ///
    /// * Path: `POST /gw/api/v1/statements`
    pub async fn post_gw_api_v1_statements(
        &self,
        request: PostGwApiV1StatementsRequest,
    ) -> anyhow::Result<PostGwApiV1StatementsResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("gw")
            .push("api")
            .push("v1")
            .push("statements");
        let response = self
            .client
            .post(url)
            .headers(
                http::HeaderMap::try_from(&request.header).context("building request headers")?,
            )
            .json(&request.body)
            .send()
            .await?;
        Ok(PostGwApiV1StatementsRequest::parse_response(response).await?)
    }
    /// Fetch Available Daily, Monthly, And Annual Report Dates For An Account Id
    ///
    /// <br>**Scope**: `statements.read` OR `reports.read`<br>**Security Policy**: `HTTPS`
    ///
    /// * Path: `GET /gw/api/v1/statements/available`
    pub async fn get_gw_api_v1_statements_available(
        &self,
        request: GetGwApiV1StatementsAvailableRequest,
    ) -> anyhow::Result<GetGwApiV1StatementsAvailableResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("gw")
            .push("api")
            .push("v1")
            .push("statements")
            .push("available");
        let response = self
            .client
            .get(url)
            .query(&request.query)
            .headers(
                http::HeaderMap::try_from(&request.header).context("building request headers")?,
            )
            .send()
            .await?;
        Ok(GetGwApiV1StatementsAvailableRequest::parse_response(response).await?)
    }
    /// Fetch Tax Forms In Supported Formats Based On Request Parameters.
    ///
    /// <br>**Scope**: `statements.write` OR `reports.write`<br>**Security Policy**: `Signed JWT`
    ///
    /// * Path: `POST /gw/api/v1/tax-documents`
    pub async fn post_gw_api_v1_tax_documents(
        &self,
        request: PostGwApiV1TaxDocumentsRequest,
    ) -> anyhow::Result<PostGwApiV1TaxDocumentsResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("gw")
            .push("api")
            .push("v1")
            .push("tax-documents");
        let response = self
            .client
            .post(url)
            .headers(
                http::HeaderMap::try_from(&request.header).context("building request headers")?,
            )
            .json(&request.body)
            .send()
            .await?;
        Ok(PostGwApiV1TaxDocumentsRequest::parse_response(response).await?)
    }
    /// Fetch List Of Available Tax Reports/forms/documents For A Specified Account And Tax Year
    ///
    /// <br>**Scope**: `statements.read` OR `reports.read`<br>**Security Policy**: `HTTPS`
    ///
    /// * Path: `GET /gw/api/v1/tax-documents/available`
    pub async fn get_gw_api_v1_tax_documents_available(
        &self,
        request: GetGwApiV1TaxDocumentsAvailableRequest,
    ) -> anyhow::Result<GetGwApiV1TaxDocumentsAvailableResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("gw")
            .push("api")
            .push("v1")
            .push("tax-documents")
            .push("available");
        let response = self
            .client
            .get(url)
            .query(&request.query)
            .headers(
                http::HeaderMap::try_from(&request.header).context("building request headers")?,
            )
            .send()
            .await?;
        Ok(GetGwApiV1TaxDocumentsAvailableRequest::parse_response(response).await?)
    }
    /// Fetch Trade Confirmations In Supported Formats Based On Request Parameters.
    ///
    /// <br>**Scope**: `statements.write` OR `reports.write`<br>**Security Policy**: `Signed JWT`
    ///
    /// * Path: `POST /gw/api/v1/trade-confirmations`
    pub async fn post_gw_api_v1_trade_confirmations(
        &self,
        request: PostGwApiV1TradeConfirmationsRequest,
    ) -> anyhow::Result<PostGwApiV1TradeConfirmationsResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("gw")
            .push("api")
            .push("v1")
            .push("trade-confirmations");
        let response = self
            .client
            .post(url)
            .headers(
                http::HeaderMap::try_from(&request.header).context("building request headers")?,
            )
            .json(&request.body)
            .send()
            .await?;
        Ok(PostGwApiV1TradeConfirmationsRequest::parse_response(response).await?)
    }
    /// Fetch List Of Available Trade Confirmation Dates, For A Specific Account Id
    ///
    /// <br>**Scope**: `statements.read` OR `reports.read`<br>**Security Policy**: `HTTPS`
    ///
    /// * Path: `GET /gw/api/v1/trade-confirmations/available`
    pub async fn get_gw_api_v1_trade_confirmations_available(
        &self,
        request: GetGwApiV1TradeConfirmationsAvailableRequest,
    ) -> anyhow::Result<GetGwApiV1TradeConfirmationsAvailableResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("gw")
            .push("api")
            .push("v1")
            .push("trade-confirmations")
            .push("available");
        let response = self
            .client
            .get(url)
            .query(&request.query)
            .headers(
                http::HeaderMap::try_from(&request.header).context("building request headers")?,
            )
            .send()
            .await?;
        Ok(GetGwApiV1TradeConfirmationsAvailableRequest::parse_response(response).await?)
    }
    /// Verify User Availability
    ///
    /// Verify whether user is valid and available<br><br>**Scope**: `accounts.read` OR `validations.read`<br>**Security Policy**: `HTTPS`
    ///
    /// * Path: `GET /gw/api/v1/validations/usernames/{username}`
    pub async fn get_gw_api_v1_validations_usernames_username(
        &self,
        request: GetGwApiV1ValidationsUsernamesUsernameRequest,
    ) -> anyhow::Result<GetGwApiV1ValidationsUsernamesUsernameResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("gw")
            .push("api")
            .push("v1")
            .push("validations")
            .push("usernames")
            .push(&request.path.username.to_string());
        let response = self.client.get(url).send().await?;
        Ok(GetGwApiV1ValidationsUsernamesUsernameRequest::parse_response(response).await?)
    }
    /// Switch Selected Account
    ///
    /// Switch the active account for how you request data. Only available for financial advisors and multi-account structures.
    ///
    /// * Path: `POST /iserver/account`
    pub async fn set_active_account(
        &self,
        request: SetActiveAccountRequest,
    ) -> anyhow::Result<SetActiveAccountResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("account");
        let response = self.client.post(url).json(&request.body).send().await?;
        Ok(SetActiveAccountRequest::parse_response(response).await?)
    }
    /// Details Of A Specific Alert
    ///
    /// Request details of a specific alert by providing the assigned alertId Id.
    ///
    /// * Path: `GET /iserver/account/alert/{alertId}`
    pub async fn get_alert_details(
        &self,
        request: GetAlertDetailsRequest,
    ) -> anyhow::Result<GetAlertDetailsResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("account")
            .push("alert")
            .push(&request.path.alert_id.to_string());
        let response = self.client.get(url).query(&request.query).send().await?;
        Ok(GetAlertDetailsRequest::parse_response(response).await?)
    }
    /// List Allocatable Subaccounts
    ///
    /// 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.
    ///
    /// * Path: `GET /iserver/account/allocation/accounts`
    pub async fn get_allocatable_subaccounts(
        &self,
        request: GetAllocatableSubaccountsRequest,
    ) -> anyhow::Result<GetAllocatableSubaccountsResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("account")
            .push("allocation")
            .push("accounts");
        let response = self.client.get(url).send().await?;
        Ok(GetAllocatableSubaccountsRequest::parse_response(response).await?)
    }
    /// List All Allocation Groups
    ///
    /// 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.
    ///
    /// * Path: `GET /iserver/account/allocation/group`
    pub async fn get_allocation_groups(
        &self,
        request: GetAllocationGroupsRequest,
    ) -> anyhow::Result<GetAllocationGroupsResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("account")
            .push("allocation")
            .push("group");
        let response = self.client.get(url).send().await?;
        Ok(GetAllocationGroupsRequest::parse_response(response).await?)
    }
    /// Modify Allocation Group
    ///
    /// Modify an existing allocation group.
    ///
    /// * Path: `PUT /iserver/account/allocation/group`
    pub async fn modify_allocation_group(
        &self,
        request: ModifyAllocationGroupRequest,
    ) -> anyhow::Result<CreateAllocationGroupResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("account")
            .push("allocation")
            .push("group");
        let response = self.client.put(url).json(&request.body).send().await?;
        Ok(ModifyAllocationGroupRequest::parse_response(response).await?)
    }
    /// Add Allocation Group
    ///
    /// Add a new allocation group. This group can be used to trade in place of the {accountId} for the /iserver/account/{accountId}/orders endpoint.
    ///
    /// * Path: `POST /iserver/account/allocation/group`
    pub async fn create_allocation_group(
        &self,
        request: CreateAllocationGroupRequest,
    ) -> anyhow::Result<CreateAllocationGroupResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("account")
            .push("allocation")
            .push("group");
        let response = self.client.post(url).json(&request.body).send().await?;
        Ok(CreateAllocationGroupRequest::parse_response(response).await?)
    }
    /// Delete An Allocation Group
    ///
    /// Deletes a previously created allocation group. This endpoint is only supported for Financial Advisors and IBroker Accounts.
    ///
    /// * Path: `POST /iserver/account/allocation/group/delete`
    pub async fn delete_allocation_group(
        &self,
        request: DeleteAllocationGroupRequest,
    ) -> anyhow::Result<CreateAllocationGroupResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("account")
            .push("allocation")
            .push("group")
            .push("delete");
        let response = self.client.post(url).json(&request.body).send().await?;
        Ok(DeleteAllocationGroupRequest::parse_response(response).await?)
    }
    /// Retrieve Single Allocation Group
    ///
    /// 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.
    ///
    /// * Path: `POST /iserver/account/allocation/group/single`
    pub async fn get_single_allocation_group(
        &self,
        request: GetSingleAllocationGroupRequest,
    ) -> anyhow::Result<GetSingleAllocationGroupResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("account")
            .push("allocation")
            .push("group")
            .push("single");
        let response = self.client.post(url).json(&request.body).send().await?;
        Ok(GetSingleAllocationGroupRequest::parse_response(response).await?)
    }
    /// Retrieve Allocation Presets
    ///
    /// Retrieve the preset behavior for allocation groups for specific events. This endpoint is only supported for Financial Advisors and IBroker Accounts.
    ///
    /// * Path: `GET /iserver/account/allocation/presets`
    pub async fn get_allocation_presets(
        &self,
        request: GetAllocationPresetsRequest,
    ) -> anyhow::Result<GetAllocationPresetsResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("account")
            .push("allocation")
            .push("presets");
        let response = self.client.get(url).send().await?;
        Ok(GetAllocationPresetsRequest::parse_response(response).await?)
    }
    /// Set Allocation Preset
    ///
    /// Set the preset behavior for new allocation groups for specific events.
    ///
    /// * Path: `POST /iserver/account/allocation/presets`
    pub async fn set_allocation_preset(
        &self,
        request: SetAllocationPresetRequest,
    ) -> anyhow::Result<SetAllocationPresetResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("account")
            .push("allocation")
            .push("presets");
        let response = self.client.post(url).json(&request.body).send().await?;
        Ok(SetAllocationPresetRequest::parse_response(response).await?)
    }
    /// Details Of A Mobile Trading Alert
    ///
    /// 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.
    ///
    /// * Path: `GET /iserver/account/mta`
    pub async fn get_mta_details(
        &self,
        request: GetMtaDetailsRequest,
    ) -> anyhow::Result<GetMtaDetailsResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("account")
            .push("mta");
        let response = self.client.get(url).send().await?;
        Ok(GetMtaDetailsRequest::parse_response(response).await?)
    }
    /// Status Of A Single Order
    ///
    /// 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.
    ///
    /// * Path: `GET /iserver/account/order/status/{orderId}`
    pub async fn get_order_status(
        &self,
        request: GetOrderStatusRequest,
    ) -> anyhow::Result<GetOrderStatusResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("account")
            .push("order")
            .push("status")
            .push(&request.path.order_id.to_string());
        let response = self.client.get(url).send().await?;
        Ok(GetOrderStatusRequest::parse_response(response).await?)
    }
    /// List Open Orders
    ///
    /// Returns open orders and filled or cancelled orders submitted during the current brokerage session.
    ///
    /// * Path: `GET /iserver/account/orders`
    pub async fn get_open_orders(
        &self,
        request: GetOpenOrdersRequest,
    ) -> anyhow::Result<GetOpenOrdersResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("account")
            .push("orders");
        let response = self.client.get(url).query(&request.query).send().await?;
        Ok(GetOpenOrdersRequest::parse_response(response).await?)
    }
    /// Account Profit And Loss
    ///
    /// Returns updated profit and loss values for the selected account. Initial request will return an empty array in the upnl object.
    ///
    /// * Path: `GET /iserver/account/pnl/partitioned`
    pub async fn get_pnl(&self, request: GetPnlRequest) -> anyhow::Result<GetPnlResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("account")
            .push("pnl")
            .push("partitioned");
        let response = self.client.get(url).send().await?;
        Ok(GetPnlRequest::parse_response(response).await?)
    }
    /// Search Dynamic Accounts
    ///
    /// 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.
    ///
    /// * Path: `GET /iserver/account/search/{searchPattern}`
    pub async fn get_dynamic_accounts(
        &self,
        request: GetDynamicAccountsRequest,
    ) -> anyhow::Result<GetDynamicAccountsResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("account")
            .push("search")
            .push(&request.path.search_pattern.to_string());
        let response = self.client.get(url).send().await?;
        Ok(GetDynamicAccountsRequest::parse_response(response).await?)
    }
    /// Trade History
    ///
    /// Retrieve a list of trades, up to a maximum of 7 days prior.
    ///
    /// * Path: `GET /iserver/account/trades`
    pub async fn get_trade_history(
        &self,
        request: GetTradeHistoryRequest,
    ) -> anyhow::Result<GetTradeHistoryResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("account")
            .push("trades");
        let response = self.client.get(url).query(&request.query).send().await?;
        Ok(GetTradeHistoryRequest::parse_response(response).await?)
    }
    /// Create Or Modify Alert
    ///
    /// Endpoint used to create a new alert, or modify an existing alert.
    ///
    /// * Path: `POST /iserver/account/{accountId}/alert`
    pub async fn create_alert(
        &self,
        request: CreateAlertRequest,
    ) -> anyhow::Result<CreateAlertResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("account")
            .push(&request.path.account_id.to_string())
            .push("alert");
        let response = self.client.post(url).json(&request.body).send().await?;
        Ok(CreateAlertRequest::parse_response(response).await?)
    }
    /// Activate Or Deactivate An Alert
    ///
    /// Activate or Deactivate existing alerts created for this account. This does not delete alerts, but disables notifications until reactivated.
    ///
    /// * Path: `POST /iserver/account/{accountId}/alert/activate`
    pub async fn activate_alert(
        &self,
        request: ActivateAlertRequest,
    ) -> anyhow::Result<ActivateAlertResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("account")
            .push(&request.path.account_id.to_string())
            .push("alert")
            .push("activate");
        let response = self.client.post(url).json(&request.body).send().await?;
        Ok(ActivateAlertRequest::parse_response(response).await?)
    }
    /// Delete An Alert
    ///
    /// Permanently delete an existing alert. Deleting an MTA alert will reset it to the default state.
    ///
    /// * Path: `DELETE /iserver/account/{accountId}/alert/{alertId}`
    pub async fn delete_alert(
        &self,
        request: DeleteAlertRequest,
    ) -> anyhow::Result<DeleteAlertResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("account")
            .push(&request.path.account_id.to_string())
            .push("alert")
            .push(&request.path.alert_id.to_string());
        let response = self.client.delete(url).json(&request.body).send().await?;
        Ok(DeleteAlertRequest::parse_response(response).await?)
    }
    /// List All Alerts
    ///
    /// Retrieve a list of all alerts attached to the provided account.
    ///
    /// * Path: `GET /iserver/account/{accountId}/alerts`
    pub async fn get_all_alerts(
        &self,
        request: GetAllAlertsRequest,
    ) -> anyhow::Result<GetAllAlertsResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("account")
            .push(&request.path.account_id.to_string())
            .push("alerts");
        let response = self.client.get(url).send().await?;
        Ok(GetAllAlertsRequest::parse_response(response).await?)
    }
    /// Modify Open Order
    ///
    /// Modify an existing, unfilled order.
    ///
    /// * Path: `POST /iserver/account/{accountId}/order/{orderId}`
    pub async fn modify_open_order(
        &self,
        request: ModifyOpenOrderRequest,
    ) -> anyhow::Result<ModifyOpenOrderResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("account")
            .push(&request.path.account_id.to_string())
            .push("order")
            .push(&request.path.order_id.to_string());
        let response = self.client.post(url).json(&request.body).send().await?;
        Ok(ModifyOpenOrderRequest::parse_response(response).await?)
    }
    /// Cancel An Open Order
    ///
    /// Cancel an existing, unfilled order.
    ///
    /// * Path: `DELETE /iserver/account/{accountId}/order/{orderId}`
    pub async fn cancel_open_order(
        &self,
        request: CancelOpenOrderRequest,
    ) -> anyhow::Result<CancelOpenOrderResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("account")
            .push(&request.path.account_id.to_string())
            .push("order")
            .push(&request.path.order_id.to_string());
        let response = self.client.delete(url).query(&request.query).send().await?;
        Ok(CancelOpenOrderRequest::parse_response(response).await?)
    }
    /// Submit New Order
    ///
    /// Submit a new order(s) ticket, bracket, or OCA group.
    ///
    /// * Path: `POST /iserver/account/{accountId}/orders`
    pub async fn submit_new_order(
        &self,
        request: SubmitNewOrderRequest,
    ) -> anyhow::Result<SubmitNewOrderResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("account")
            .push(&request.path.account_id.to_string())
            .push("orders");
        let response = self.client.post(url).json(&request.body).send().await?;
        Ok(SubmitNewOrderRequest::parse_response(response).await?)
    }
    /// New Order Preview
    ///
    /// Preview the projected effects of an order ticket or bracket of orders, including cost and changes to margin and account equity.
    ///
    /// * Path: `POST /iserver/account/{accountId}/orders/whatif`
    pub async fn preview_margin_impact(
        &self,
        request: PreviewMarginImpactRequest,
    ) -> anyhow::Result<PreviewMarginImpactResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("account")
            .push(&request.path.account_id.to_string())
            .push("orders")
            .push("whatif");
        let response = self.client.post(url).json(&request.body).send().await?;
        Ok(PreviewMarginImpactRequest::parse_response(response).await?)
    }
    /// Summary Of Account Values
    ///
    /// Provides a general overview of the account details such as balance values.
    ///
    /// * Path: `GET /iserver/account/{accountId}/summary`
    pub async fn get_account_summary(
        &self,
        request: GetAccountSummaryRequest,
    ) -> anyhow::Result<GetAccountSummaryResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("account")
            .push(&request.path.account_id.to_string())
            .push("summary");
        let response = self.client.get(url).send().await?;
        Ok(GetAccountSummaryRequest::parse_response(response).await?)
    }
    /// Summary Of Available Funds
    ///
    /// Provides a summary specific for avilable funds giving more depth than the standard /summary endpoint.
    ///
    /// * Path: `GET /iserver/account/{accountId}/summary/available_funds`
    pub async fn get_fund_summary(
        &self,
        request: GetFundSummaryRequest,
    ) -> anyhow::Result<GetFundSummaryResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("account")
            .push(&request.path.account_id.to_string())
            .push("summary")
            .push("available_funds");
        let response = self.client.get(url).send().await?;
        Ok(GetFundSummaryRequest::parse_response(response).await?)
    }
    /// Summary Of Account Balances
    ///
    /// Returns a summary of an account's equity and cash balances, in total and by account segment.
    ///
    /// * Path: `GET /iserver/account/{accountId}/summary/balances`
    pub async fn get_balance_summary(
        &self,
        request: GetBalanceSummaryRequest,
    ) -> anyhow::Result<GetBalanceSummaryResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("account")
            .push(&request.path.account_id.to_string())
            .push("summary")
            .push("balances");
        let response = self.client.get(url).send().await?;
        Ok(GetBalanceSummaryRequest::parse_response(response).await?)
    }
    /// Summary Of Account Margin Usage
    ///
    /// Returns a summary of an account's margin, in total and by account segment.
    ///
    /// * Path: `GET /iserver/account/{accountId}/summary/margins`
    pub async fn get_margin_summary(
        &self,
        request: GetMarginSummaryRequest,
    ) -> anyhow::Result<GetMarginSummaryResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("account")
            .push(&request.path.account_id.to_string())
            .push("summary")
            .push("margins");
        let response = self.client.get(url).send().await?;
        Ok(GetMarginSummaryRequest::parse_response(response).await?)
    }
    /// Summary Of Account Market Value
    ///
    /// Returns a summary of an account's market value, by currency and asset class.
    ///
    /// * Path: `GET /iserver/account/{accountId}/summary/market_value`
    pub async fn get_account_market_summary(
        &self,
        request: GetAccountMarketSummaryRequest,
    ) -> anyhow::Result<GetAccountMarketSummaryResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("account")
            .push(&request.path.account_id.to_string())
            .push("summary")
            .push("market_value");
        let response = self.client.get(url).send().await?;
        Ok(GetAccountMarketSummaryRequest::parse_response(response).await?)
    }
    /// List All Tradable Accounts
    ///
    /// 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.
    ///
    /// * Path: `GET /iserver/accounts`
    pub async fn get_brokerage_accounts(
        &self,
        request: GetBrokerageAccountsRequest,
    ) -> anyhow::Result<GetBrokerageAccountsResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("accounts");
        let response = self.client.get(url).send().await?;
        Ok(GetBrokerageAccountsRequest::parse_response(response).await?)
    }
    /// Initialize Brokerage Session
    ///
    /// After retrieving the access token and subsequent Live Session Token, customers can initialize their brokerage session with the ssodh/init endpoint.
    ///
    /// * Path: `POST /iserver/auth/ssodh/init`
    pub async fn initialize_session(
        &self,
        request: InitializeSessionRequest,
    ) -> anyhow::Result<InitializeSessionResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("auth")
            .push("ssodh")
            .push("init");
        let response = self.client.post(url).json(&request.body).send().await?;
        Ok(InitializeSessionRequest::parse_response(response).await?)
    }
    /// Brokerage Session Status
    ///
    /// Current Authentication status to the Brokerage system. Market Data and Trading is not possible if not authenticated.
    ///
    /// * Path: `POST /iserver/auth/status`
    pub async fn get_brokerage_status(
        &self,
        request: GetBrokerageStatusRequest,
    ) -> anyhow::Result<GetBrokerageStatusResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("auth")
            .push("status");
        let response = self.client.post(url).body(Vec::<u8>::new()).send().await?;
        Ok(GetBrokerageStatusRequest::parse_response(response).await?)
    }
    /// Search Contract Rules
    ///
    /// Returns trading related rules for a specific contract and side.
    ///
    /// * Path: `POST /iserver/contract/rules`
    pub async fn get_contract_rules(
        &self,
        request: GetContractRulesRequest,
    ) -> anyhow::Result<GetContractRulesResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("contract")
            .push("rules");
        let response = self.client.post(url).json(&request.body).send().await?;
        Ok(GetContractRulesRequest::parse_response(response).await?)
    }
    /// Search Algos For An Instrument
    ///
    /// Returns supported IB Algos for an instrument. A pre-flight request must be submitted before retrieving information.
    ///
    /// * Path: `GET /iserver/contract/{conid}/algos`
    pub async fn get_algos_by_instrument(
        &self,
        request: GetAlgosByInstrumentRequest,
    ) -> anyhow::Result<GetAlgosByInstrumentResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("contract")
            .push(&request.path.conid.to_string())
            .push("algos");
        let response = self.client.get(url).query(&request.query).send().await?;
        Ok(GetAlgosByInstrumentRequest::parse_response(response).await?)
    }
    /// General Instrument Information
    ///
    /// Requests full contract details for the given conid.
    ///
    /// * Path: `GET /iserver/contract/{conid}/info`
    pub async fn get_instrument_info(
        &self,
        request: GetInstrumentInfoRequest,
    ) -> anyhow::Result<GetInstrumentInfoResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("contract")
            .push(&request.path.conid.to_string())
            .push("info");
        let response = self.client.get(url).send().await?;
        Ok(GetInstrumentInfoRequest::parse_response(response).await?)
    }
    /// Instrument Info And Market Rules
    ///
    /// Requests full contract details and trading rules for the given conid. A follow-up request will provide additional trading rules.
    ///
    /// * Path: `GET /iserver/contract/{conid}/info-and-rules`
    pub async fn get_info_and_rules(
        &self,
        request: GetInfoAndRulesRequest,
    ) -> anyhow::Result<GetInfoAndRulesResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("contract")
            .push(&request.path.conid.to_string())
            .push("info-and-rules");
        let response = self.client.get(url).send().await?;
        Ok(GetInfoAndRulesRequest::parse_response(response).await?)
    }
    /// Available Currency Pairs
    ///
    /// Obtains available currency pairs corresponding to the given target currency.
    ///
    /// * Path: `GET /iserver/currency/pairs`
    pub async fn get_currency_pairs(
        &self,
        request: GetCurrencyPairsRequest,
    ) -> anyhow::Result<GetCurrencyPairsResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("currency")
            .push("pairs");
        let response = self.client.get(url).query(&request.query).send().await?;
        Ok(GetCurrencyPairsRequest::parse_response(response).await?)
    }
    /// Set Active Dynamic Account
    ///
    /// Set the active dynamic account.
    ///
    /// * Path: `POST /iserver/dynaccount`
    pub async fn set_dynamic_account(
        &self,
        request: SetDynamicAccountRequest,
    ) -> anyhow::Result<SetActiveAccountResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("dynaccount");
        let response = self.client.post(url).json(&request.body).send().await?;
        Ok(SetDynamicAccountRequest::parse_response(response).await?)
    }
    /// Currency Exchange Rate
    ///
    /// Obtains the exchange rates of the currency pair.
    ///
    /// * Path: `GET /iserver/exchangerate`
    pub async fn get_exchange_rates(
        &self,
        request: GetExchangeRatesRequest,
    ) -> anyhow::Result<GetExchangeRatesResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("exchangerate");
        let response = self.client.get(url).query(&request.query).send().await?;
        Ok(GetExchangeRatesRequest::parse_response(response).await?)
    }
    /// Historical OHLC Bar Data
    ///
    /// Request historical data for an instrument in the form of OHLC bars.
    ///
    /// * Path: `GET /iserver/marketdata/history`
    pub async fn get_md_history(
        &self,
        request: GetMdHistoryRequest,
    ) -> anyhow::Result<GetMdHistoryResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("marketdata")
            .push("history");
        let response = self.client.get(url).query(&request.query).send().await?;
        Ok(GetMdHistoryRequest::parse_response(response).await?)
    }
    /// Live Market Data Snapshot
    ///
    /// 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.
    ///
    /// * Path: `GET /iserver/marketdata/snapshot`
    pub async fn get_md_snapshot(
        &self,
        request: GetMdSnapshotRequest,
    ) -> anyhow::Result<GetMdSnapshotResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("marketdata")
            .push("snapshot");
        let response = self.client.get(url).query(&request.query).send().await?;
        Ok(GetMdSnapshotRequest::parse_response(response).await?)
    }
    /// Close A Backend Data Stream
    ///
    /// Instruct IServer to close its backend stream for the instrument when real-time snapshots are no longer needed.
    ///
    /// * Path: `POST /iserver/marketdata/unsubscribe`
    pub async fn close_md_stream(
        &self,
        request: CloseMdStreamRequest,
    ) -> anyhow::Result<CloseMdStreamResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("marketdata")
            .push("unsubscribe");
        let response = self.client.post(url).json(&request.body).send().await?;
        Ok(CloseMdStreamRequest::parse_response(response).await?)
    }
    /// Close All Backend Data Streams
    ///
    /// Instruct IServer to close all of its open backend data streams for all instruments.
    ///
    /// * Path: `GET /iserver/marketdata/unsubscribeall`
    pub async fn close_all_md_streams(
        &self,
        request: CloseAllMdStreamsRequest,
    ) -> anyhow::Result<CloseAllMdStreamsResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("marketdata")
            .push("unsubscribeall");
        let response = self.client.get(url).send().await?;
        Ok(CloseAllMdStreamsRequest::parse_response(response).await?)
    }
    /// Dismiss Server Prompt
    ///
    /// Respond to a server prompt received via ntf websocket message.
    ///
    /// * Path: `POST /iserver/notification`
    pub async fn ack_server_prompt(
        &self,
        request: AckServerPromptRequest,
    ) -> anyhow::Result<AckServerPromptResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("notification");
        let response = self.client.post(url).json(&request.body).send().await?;
        Ok(AckServerPromptRequest::parse_response(response).await?)
    }
    /// Suppress Order Reply Messages
    ///
    /// Suppress the specified order reply messages for the duration of the brokerage session.
    ///
    /// * Path: `POST /iserver/questions/suppress`
    pub async fn suppress_order_replies(
        &self,
        request: SuppressOrderRepliesRequest,
    ) -> anyhow::Result<SuppressOrderRepliesResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("questions")
            .push("suppress");
        let response = self.client.post(url).json(&request.body).send().await?;
        Ok(SuppressOrderRepliesRequest::parse_response(response).await?)
    }
    /// Reset Order Reply Message Suppression
    ///
    /// Removes suppression of all order reply messages that were previously suppressed in the current brokerage session.
    ///
    /// * Path: `POST /iserver/questions/suppress/reset`
    pub async fn reset_order_suppression(
        &self,
        request: ResetOrderSuppressionRequest,
    ) -> anyhow::Result<ResetOrderSuppressionResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("questions")
            .push("suppress")
            .push("reset");
        let response = self.client.post(url).body(Vec::<u8>::new()).send().await?;
        Ok(ResetOrderSuppressionRequest::parse_response(response).await?)
    }
    /// Confirm Order Reply Message
    ///
    /// Confirm an order reply message and continue with submission of order ticket.
    ///
    /// * Path: `POST /iserver/reply/{replyId}`
    pub async fn confirm_order_reply(
        &self,
        request: ConfirmOrderReplyRequest,
    ) -> anyhow::Result<ConfirmOrderReplyResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("reply")
            .push(&request.path.reply_id.to_string());
        let response = self.client.post(url).json(&request.body).send().await?;
        Ok(ConfirmOrderReplyRequest::parse_response(response).await?)
    }
    /// Get Valid IServer Scanner Parameters
    ///
    /// Returns an xml file containing all available parameters to be sent for the Iserver scanner request.
    ///
    /// * Path: `GET /iserver/scanner/params`
    pub async fn get_scanner_parameters(
        &self,
        request: GetScannerParametersRequest,
    ) -> anyhow::Result<GetScannerParametersResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("scanner")
            .push("params");
        let response = self.client.get(url).send().await?;
        Ok(GetScannerParametersRequest::parse_response(response).await?)
    }
    /// Run An IServer Market Scanner
    ///
    /// Searches for contracts according to the filters specified in /iserver/scanner/params endpoint.
    ///
    /// * Path: `POST /iserver/scanner/run`
    pub async fn get_scanner_results(
        &self,
        request: GetScannerResultsRequest,
    ) -> anyhow::Result<GetScannerResultsResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("scanner")
            .push("run");
        let response = self.client.post(url).json(&request.body).send().await?;
        Ok(GetScannerResultsRequest::parse_response(response).await?)
    }
    /// Search Bond Filter Information
    ///
    /// 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.
    ///
    /// * Path: `GET /iserver/secdef/bond-filters`
    pub async fn get_bond_filters(
        &self,
        request: GetBondFiltersRequest,
    ) -> anyhow::Result<GetBondFiltersResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("secdef")
            .push("bond-filters");
        let response = self.client.get(url).query(&request.query).send().await?;
        Ok(GetBondFiltersRequest::parse_response(response).await?)
    }
    /// Instrument Attributes Detail
    ///
    /// Returns the attributes of the instrument.
    ///
    /// * Path: `GET /iserver/secdef/info`
    pub async fn get_contract_info(
        &self,
        request: GetContractInfoRequest,
    ) -> anyhow::Result<GetContractInfoResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("secdef")
            .push("info");
        let response = self.client.get(url).query(&request.query).send().await?;
        Ok(GetContractInfoRequest::parse_response(response).await?)
    }
    /// Search Instruments By Symbol
    ///
    /// Returns a list of contracts based on the search symbol provided as a query param.
    ///
    /// * Path: `GET /iserver/secdef/search`
    pub async fn get_contract_symbols(
        &self,
        request: GetContractSymbolsRequest,
    ) -> anyhow::Result<GetContractSymbolsResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("secdef")
            .push("search");
        let response = self.client.get(url).query(&request.query).send().await?;
        Ok(GetContractSymbolsRequest::parse_response(response).await?)
    }
    /// Search Instruments By Symbol
    ///
    /// Returns a list of contracts based on the search symbol provided as a query param.
    ///
    /// * Path: `POST /iserver/secdef/search`
    pub async fn get_contract_symbols_from_body(
        &self,
        request: GetContractSymbolsFromBodyRequest,
    ) -> anyhow::Result<GetContractSymbolsResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("secdef")
            .push("search");
        let response = self.client.post(url).json(&request.body).send().await?;
        Ok(GetContractSymbolsFromBodyRequest::parse_response(response).await?)
    }
    /// Search Strikes For An Underlier
    ///
    /// 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".
    ///
    /// * Path: `GET /iserver/secdef/strikes`
    pub async fn get_contract_strikes(
        &self,
        request: GetContractStrikesRequest,
    ) -> anyhow::Result<GetContractStrikesResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("secdef")
            .push("strikes");
        let response = self.client.get(url).query(&request.query).send().await?;
        Ok(GetContractStrikesRequest::parse_response(response).await?)
    }
    /// Return A Single Saved Watchlist
    ///
    /// Retrieve details of a single watchlist stored in the username's settings.
    ///
    /// * Path: `GET /iserver/watchlist`
    pub async fn get_specific_watchlist(
        &self,
        request: GetSpecificWatchlistRequest,
    ) -> anyhow::Result<GetSpecificWatchlistResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("watchlist");
        let response = self.client.get(url).query(&request.query).send().await?;
        Ok(GetSpecificWatchlistRequest::parse_response(response).await?)
    }
    /// Create A Watchlist
    ///
    /// Create a named watchlist by submitting a set of conids.
    ///
    /// * Path: `POST /iserver/watchlist`
    pub async fn post_new_watchlist(
        &self,
        request: PostNewWatchlistRequest,
    ) -> anyhow::Result<PostNewWatchlistResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("watchlist");
        let response = self.client.post(url).json(&request.body).send().await?;
        Ok(PostNewWatchlistRequest::parse_response(response).await?)
    }
    /// Delete A Saved Watchlist
    ///
    /// Delete a specified watchlist from the username's settings.
    ///
    /// * Path: `DELETE /iserver/watchlist`
    pub async fn delete_watchlist(
        &self,
        request: DeleteWatchlistRequest,
    ) -> anyhow::Result<DeleteWatchlistResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("watchlist");
        let response = self.client.delete(url).query(&request.query).send().await?;
        Ok(DeleteWatchlistRequest::parse_response(response).await?)
    }
    /// Return All Saved Watchlists
    ///
    /// Returns all saved watchlists stored on IB backend for the username in use in the current Web API session.
    ///
    /// * Path: `GET /iserver/watchlists`
    pub async fn get_all_watchlists(
        &self,
        request: GetAllWatchlistsRequest,
    ) -> anyhow::Result<GetAllWatchlistsResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("iserver")
            .push("watchlists");
        let response = self.client.get(url).query(&request.query).send().await?;
        Ok(GetAllWatchlistsRequest::parse_response(response).await?)
    }
    /// Terminate Web API Session
    ///
    /// Logs the user out of the gateway session. Any further activity requires re-authentication. Discard client-side cookies upon logout.
    ///
    /// * Path: `POST /logout`
    pub async fn logout(&self, request: LogoutRequest) -> anyhow::Result<LogoutResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("logout");
        let response = self.client.post(url).body(Vec::<u8>::new()).send().await?;
        Ok(LogoutRequest::parse_response(response).await?)
    }
    /// Generate An Access Token
    ///
    /// Request an access token for the IB username that has granted authorization to the consumer.
    ///
    /// * Path: `POST /oauth/access_token`
    pub async fn req_access_token(
        &self,
        request: ReqAccessTokenRequest,
    ) -> anyhow::Result<ReqAccessTokenResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("oauth")
            .push("access_token");
        let response = self
            .client
            .post(url)
            .headers(
                http::HeaderMap::try_from(&request.header).context("building request headers")?,
            )
            .send()
            .await?;
        Ok(ReqAccessTokenRequest::parse_response(response).await?)
    }
    /// Generate A Live Session Token
    ///
    /// Generate a Live Session Token shared secret and gain access to Web API.
    ///
    /// * Path: `POST /oauth/live_session_token`
    pub async fn req_live_session_token(
        &self,
        request: ReqLiveSessionTokenRequest,
    ) -> anyhow::Result<ReqLiveSessionTokenResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("oauth")
            .push("live_session_token");
        let response = self
            .client
            .post(url)
            .headers(
                http::HeaderMap::try_from(&request.header).context("building request headers")?,
            )
            .send()
            .await?;
        Ok(ReqLiveSessionTokenRequest::parse_response(response).await?)
    }
    /// Obtain A Request Token
    ///
    /// Request a temporary token as a third party to begin the OAuth 1.0a authorization workflow.
    ///
    /// * Path: `POST /oauth/request_token`
    pub async fn req_temp_token(
        &self,
        request: ReqTempTokenRequest,
    ) -> anyhow::Result<ReqTempTokenResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("oauth")
            .push("request_token");
        let response = self
            .client
            .post(url)
            .headers(
                http::HeaderMap::try_from(&request.header).context("building request headers")?,
            )
            .send()
            .await?;
        Ok(ReqTempTokenRequest::parse_response(response).await?)
    }
    /// Create Access Token
    ///
    /// Generate OAuth 2.0 access tokens based on request parameters.
    ///
    /// * Path: `POST /oauth2/api/v1/token`
    pub async fn generate_token(
        &self,
        request: GenerateTokenRequest,
    ) -> anyhow::Result<GenerateTokenResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("oauth2")
            .push("api")
            .push("v1")
            .push("token");
        let response = self.client.post(url).form(&request.body).send().await?;
        Ok(GenerateTokenRequest::parse_response(response).await?)
    }
    /// Account Performance (All Time Periods)
    ///
    /// Returns the performance (MTM) for the given accounts, if more than one account is passed, the result is consolidated.
    ///
    /// * Path: `POST /pa/allperiods`
    pub async fn get_performance_all_periods(
        &self,
        request: GetPerformanceAllPeriodsRequest,
    ) -> anyhow::Result<GetPerformanceAllPeriodsResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("pa")
            .push("allperiods");
        let response = self
            .client
            .post(url)
            .query(&request.query)
            .json(&request.body)
            .send()
            .await?;
        Ok(GetPerformanceAllPeriodsRequest::parse_response(response).await?)
    }
    /// Account Performance
    ///
    /// Returns the performance (MTM) for the given accounts, if more than one account is passed, the result is consolidated.
    ///
    /// * Path: `POST /pa/performance`
    pub async fn get_single_performance_period(
        &self,
        request: GetSinglePerformancePeriodRequest,
    ) -> anyhow::Result<GetSinglePerformancePeriodResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("pa")
            .push("performance");
        let response = self.client.post(url).json(&request.body).send().await?;
        Ok(GetSinglePerformancePeriodRequest::parse_response(response).await?)
    }
    /// Transaction History
    ///
    /// Transaction history for a given number of conids and accounts. Types of transactions include dividend payments, buy and sell transactions, transfers.
    ///
    /// * Path: `POST /pa/transactions`
    pub async fn get_transactions(
        &self,
        request: GetTransactionsRequest,
    ) -> anyhow::Result<GetTransactionsResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("pa")
            .push("transactions");
        let response = self.client.post(url).json(&request.body).send().await?;
        Ok(GetTransactionsRequest::parse_response(response).await?)
    }
    /// List All Accounts
    ///
    /// return accounts
    ///
    /// * Path: `GET /portfolio/accounts`
    pub async fn get_all_accounts(
        &self,
        request: GetAllAccountsRequest,
    ) -> anyhow::Result<GetAllAccountsResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("portfolio")
            .push("accounts");
        let response = self.client.get(url).send().await?;
        Ok(GetAllAccountsRequest::parse_response(response).await?)
    }
    /// All Account Positions In An Instrument
    ///
    /// Get positions in accounts for a given instrument (no secDef await control)
    ///
    /// * Path: `GET /portfolio/positions/{conid}`
    pub async fn get_all_accounts_for_conid(
        &self,
        request: GetAllAccountsForConidRequest,
    ) -> anyhow::Result<GetAllAccountsForConidResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("portfolio")
            .push("positions")
            .push(&request.path.conid.to_string());
        let response = self.client.get(url).send().await?;
        Ok(GetAllAccountsForConidRequest::parse_response(response).await?)
    }
    /// List All Subaccounts
    ///
    /// Retrieve attributes of the subaccounts in the account structure.
    ///
    /// * Path: `GET /portfolio/subaccounts`
    pub async fn get_all_subaccounts(
        &self,
        request: GetAllSubaccountsRequest,
    ) -> anyhow::Result<GetAllSubaccountsResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("portfolio")
            .push("subaccounts");
        let response = self.client.get(url).send().await?;
        Ok(GetAllSubaccountsRequest::parse_response(response).await?)
    }
    /// Portfolio Subaccounts (Large Account Structures)
    ///
    /// 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.
    ///
    /// * Path: `GET /portfolio/subaccounts2`
    pub async fn get_many_subaccounts(
        &self,
        request: GetManySubaccountsRequest,
    ) -> anyhow::Result<GetManySubaccountsResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("portfolio")
            .push("subaccounts2");
        let response = self.client.get(url).query(&request.query).send().await?;
        Ok(GetManySubaccountsRequest::parse_response(response).await?)
    }
    /// Account Allocations
    ///
    /// Get an account's allocations by asset class, sector group, and sector.
    ///
    /// * Path: `GET /portfolio/{accountId}/allocation`
    pub async fn get_asset_allocation(
        &self,
        request: GetAssetAllocationRequest,
    ) -> anyhow::Result<GetAssetAllocationResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("portfolio")
            .push(&request.path.account_id.to_string())
            .push("allocation");
        let response = self.client.get(url).query(&request.query).send().await?;
        Ok(GetAssetAllocationRequest::parse_response(response).await?)
    }
    /// Combination Positions
    ///
    /// Provides all positions held in the account acquired as a combination, including values such as ratios, size, and market value.
    ///
    /// * Path: `GET /portfolio/{accountId}/combo/positions`
    pub async fn get_combo_positions(
        &self,
        request: GetComboPositionsRequest,
    ) -> anyhow::Result<GetComboPositionsResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("portfolio")
            .push(&request.path.account_id.to_string())
            .push("combo")
            .push("positions");
        let response = self.client.get(url).query(&request.query).send().await?;
        Ok(GetComboPositionsRequest::parse_response(response).await?)
    }
    /// Account Ledger
    ///
    /// Get the given account's ledger data detailing its balances by currency.
    ///
    /// * Path: `GET /portfolio/{accountId}/ledger`
    pub async fn get_portfolio_ledger(
        &self,
        request: GetPortfolioLedgerRequest,
    ) -> anyhow::Result<GetPortfolioLedgerResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("portfolio")
            .push(&request.path.account_id.to_string())
            .push("ledger");
        let response = self.client.get(url).send().await?;
        Ok(GetPortfolioLedgerRequest::parse_response(response).await?)
    }
    /// Account Attributes
    ///
    /// Get a single account's attributes and capabilities.
    ///
    /// * Path: `GET /portfolio/{accountId}/meta`
    pub async fn get_portfolio_metadata(
        &self,
        request: GetPortfolioMetadataRequest,
    ) -> anyhow::Result<GetPortfolioMetadataResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("portfolio")
            .push(&request.path.account_id.to_string())
            .push("meta");
        let response = self.client.get(url).send().await?;
        Ok(GetPortfolioMetadataRequest::parse_response(response).await?)
    }
    /// Refresh Position Cache
    ///
    /// Instructs IB to discard cached portfolio positions for a given account, so that the next request for positions delivers freshly obtained data.
    ///
    /// * Path: `POST /portfolio/{accountId}/positions/invalidate`
    pub async fn invalidate_position_cache(
        &self,
        request: InvalidatePositionCacheRequest,
    ) -> anyhow::Result<InvalidatePositionCacheResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("portfolio")
            .push(&request.path.account_id.to_string())
            .push("positions")
            .push("invalidate");
        let response = self.client.post(url).body(Vec::<u8>::new()).send().await?;
        Ok(InvalidatePositionCacheRequest::parse_response(response).await?)
    }
    /// Account Positions
    ///
    /// Get all positions in an account.
    ///
    /// * Path: `GET /portfolio/{accountId}/positions/{pageId}`
    pub async fn get_paginated_positions(
        &self,
        request: GetPaginatedPositionsRequest,
    ) -> anyhow::Result<GetPaginatedPositionsResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("portfolio")
            .push(&request.path.account_id.to_string())
            .push("positions")
            .push(&request.path.page_id.to_string());
        let response = self.client.get(url).query(&request.query).send().await?;
        Ok(GetPaginatedPositionsRequest::parse_response(response).await?)
    }
    /// Account Portfolio Summary
    ///
    /// Returns detailed summary of account values, by segment where appropriate.
    ///
    /// * Path: `GET /portfolio/{accountId}/summary`
    pub async fn get_portfolio_summary(
        &self,
        request: GetPortfolioSummaryRequest,
    ) -> anyhow::Result<GetPortfolioSummaryResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("portfolio")
            .push(&request.path.account_id.to_string())
            .push("summary");
        let response = self.client.get(url).send().await?;
        Ok(GetPortfolioSummaryRequest::parse_response(response).await?)
    }
    /// Account Position In An Instrument
    ///
    /// Get position for a given instrument in a single account.
    ///
    /// * Path: `GET /portfolio/{accountid}/position/{conid}`
    pub async fn get_position_by_conid(
        &self,
        request: GetPositionByConidRequest,
    ) -> anyhow::Result<GetPositionByConidResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("portfolio")
            .push(&request.path.accountid.to_string())
            .push("position")
            .push(&request.path.conid.to_string());
        let response = self.client.get(url).send().await?;
        Ok(GetPositionByConidRequest::parse_response(response).await?)
    }
    /// Account Positions (NEW)
    ///
    /// 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.
    ///
    /// * Path: `GET /portfolio2/{accountId}/positions`
    pub async fn get_uncached_positions(
        &self,
        request: GetUncachedPositionsRequest,
    ) -> anyhow::Result<GetUncachedPositionsResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("portfolio2")
            .push(&request.path.account_id.to_string())
            .push("positions");
        let response = self.client.get(url).query(&request.query).send().await?;
        Ok(GetUncachedPositionsRequest::parse_response(response).await?)
    }
    /// Validate SSO Web API Session
    ///
    /// Validates the current session for the SSO user.
    ///
    /// * Path: `GET /sso/validate`
    pub async fn get_session_validation(
        &self,
        request: GetSessionValidationRequest,
    ) -> anyhow::Result<GetSessionValidationResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("sso")
            .push("validate");
        let response = self.client.get(url).send().await?;
        Ok(GetSessionValidationRequest::parse_response(response).await?)
    }
    /// Brokerage Keep-Alive Ping
    ///
    /// 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.
    ///
    /// * Path: `POST /tickle`
    pub async fn get_session_token(
        &self,
        request: GetSessionTokenRequest,
    ) -> anyhow::Result<GetSessionTokenResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("tickle");
        let response = self.client.post(url).body(Vec::<u8>::new()).send().await?;
        Ok(GetSessionTokenRequest::parse_response(response).await?)
    }
    /// List All Stock Conids By Exchange
    ///
    /// 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.
    ///
    /// * Path: `GET /trsrv/all-conids`
    pub async fn get_conids_by_exchange(
        &self,
        request: GetConidsByExchangeRequest,
    ) -> anyhow::Result<GetConidsByExchangeResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("trsrv")
            .push("all-conids");
        let response = self.client.get(url).query(&request.query).send().await?;
        Ok(GetConidsByExchangeRequest::parse_response(response).await?)
    }
    /// Search Futures By Symbol
    ///
    /// Returns a list of non-expired future contracts for given symbol(s)
    ///
    /// * Path: `GET /trsrv/futures`
    pub async fn get_future_by_symbol(
        &self,
        request: GetFutureBySymbolRequest,
    ) -> anyhow::Result<GetFutureBySymbolResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("trsrv")
            .push("futures");
        let response = self.client.get(url).query(&request.query).send().await?;
        Ok(GetFutureBySymbolRequest::parse_response(response).await?)
    }
    /// Instrument Definition Detail
    ///
    /// Returns a list of security definitions for the given conids.
    ///
    /// * Path: `GET /trsrv/secdef`
    pub async fn get_instrument_definition(
        &self,
        request: GetInstrumentDefinitionRequest,
    ) -> anyhow::Result<GetInstrumentDefinitionResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("trsrv")
            .push("secdef");
        let response = self.client.get(url).query(&request.query).send().await?;
        Ok(GetInstrumentDefinitionRequest::parse_response(response).await?)
    }
    /// Trading Schedule By Symbol
    ///
    /// Returns the trading schedule up to a month for the requested contract.
    ///
    /// * Path: `GET /trsrv/secdef/schedule`
    pub async fn get_trading_schedule_get_trsrv_secdef_schedule(
        &self,
        request: GetTradingScheduleGetTrsrvSecdefScheduleRequest,
    ) -> anyhow::Result<GetTradingScheduleGetTrsrvSecdefScheduleResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("trsrv")
            .push("secdef")
            .push("schedule");
        let response = self.client.get(url).query(&request.query).send().await?;
        Ok(GetTradingScheduleGetTrsrvSecdefScheduleRequest::parse_response(response).await?)
    }
    /// Search Stocks By Symbol
    ///
    /// Returns an object contains all stock contracts for given symbol(s)
    ///
    /// * Path: `GET /trsrv/stocks`
    pub async fn get_stock_by_symbol(
        &self,
        request: GetStockBySymbolRequest,
    ) -> anyhow::Result<GetStockBySymbolResponse> {
        request.validate().context("parameter validation")?;
        let mut url = self.base_url.clone();
        url.path_segments_mut()
            .map_err(|()| anyhow::anyhow!("URL cannot be a base"))?
            .push("trsrv")
            .push("stocks");
        let response = self.client.get(url).query(&request.query).send().await?;
        Ok(GetStockBySymbolRequest::parse_response(response).await?)
    }
}