Skip to main content

binance/wallet/http/
config.rs

1use reqwest::header::HeaderMap;
2
3use crate::SensitiveString;
4
5/// Configuration for [`super::PrivateClient`].
6///
7/// Wallet has no public endpoints (everything under `/sapi/v1/...` requires
8/// an API key + signature). For unauthenticated market data and connectivity,
9/// use [`crate::spot::http::PublicClient`].
10#[derive(Debug, Clone)]
11pub struct PrivateConfig {
12    pub base_url: String,
13    pub api_key: SensitiveString,
14    pub api_secret: SensitiveString,
15    pub headers: Option<HeaderMap>,
16}
17
18impl PrivateConfig {
19    pub fn new(
20        base_url: impl Into<String>,
21        api_key: SensitiveString,
22        api_secret: SensitiveString,
23    ) -> Self {
24        Self {
25            base_url: base_url.into(),
26            api_key,
27            api_secret,
28            headers: None,
29        }
30    }
31
32    pub fn headers(mut self, headers: Option<HeaderMap>) -> Self {
33        if let Some(headers) = headers {
34            self.headers
35                .get_or_insert_with(HeaderMap::new)
36                .extend(headers);
37        }
38        self
39    }
40}