schwab_api/endpoints/
mod.rs1use crate::client::SchwabClient;
2
3pub mod accounts;
4pub mod orders;
5pub mod transactions;
6pub mod user;
7
8pub use accounts::AccountsApi;
9pub use orders::OrdersApi;
10pub use transactions::TransactionsApi;
11pub use user::UserApi;
12
13#[derive(Debug, Clone)]
15pub struct TraderApi {
16 client: SchwabClient,
17}
18
19impl TraderApi {
20 pub fn new(client: SchwabClient) -> Self {
21 Self { client }
22 }
23
24 pub fn client(&self) -> &SchwabClient {
25 &self.client
26 }
27
28 pub fn accounts(&self) -> AccountsApi<'_> {
29 AccountsApi::new(&self.client)
30 }
31
32 pub fn orders(&self) -> OrdersApi<'_> {
33 OrdersApi::new(&self.client)
34 }
35
36 pub fn transactions(&self) -> TransactionsApi<'_> {
37 TransactionsApi::new(&self.client)
38 }
39
40 pub fn user(&self) -> UserApi<'_> {
41 UserApi::new(&self.client)
42 }
43}
44
45pub(crate) fn opt_query<'a>(key: &'a str, value: Option<&'a str>) -> Vec<(&'a str, &'a str)> {
47 value.map(|v| vec![(key, v)]).unwrap_or_default()
48}
49
50pub(crate) fn merge_queries<'a>(parts: Vec<Vec<(&'a str, &'a str)>>) -> Vec<(&'a str, &'a str)> {
51 parts.into_iter().flatten().collect()
52}