wb_api_client/orders_dbw/apis/
configuration.rs1#[derive(Clone)]
15pub struct SecretString(String);
16
17impl SecretString {
18 pub fn new<S: Into<String>>(value: S) -> Self {
19 SecretString(value.into())
20 }
21
22 pub fn expose_secret(&self) -> &str {
23 &self.0
24 }
25}
26
27impl std::fmt::Debug for SecretString {
28 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
29 f.write_str("<REDACTED>")
30 }
31}
32
33impl std::fmt::Display for SecretString {
34 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
35 f.write_str("<REDACTED>")
36 }
37}
38
39#[derive(Debug, Clone)]
40pub struct Configuration {
41 pub base_path: String,
42 pub user_agent: Option<String>,
43 pub client: reqwest::Client,
44 pub basic_auth: Option<BasicAuth>,
45 pub oauth_access_token: Option<String>,
46 pub bearer_access_token: Option<SecretString>,
47 pub api_key: Option<ApiKey>,
48}
49
50pub type BasicAuth = (String, Option<String>);
51
52#[derive(Debug, Clone)]
53pub struct ApiKey {
54 pub prefix: Option<String>,
55 pub key: String,
56}
57
58impl Configuration {
59 pub fn new() -> Configuration {
60 Configuration::default()
61 }
62
63 pub fn set_access_token(&mut self, token: &str) {
66 self.bearer_access_token = Some(SecretString::new(token));
67 }
68}
69
70impl Default for Configuration {
71 fn default() -> Self {
72 Configuration {
73 base_path: "http://localhost".to_owned(),
74 user_agent: Some("ValeryVerkhoturov/wb-api-client/rust".to_owned()),
75 client: reqwest::Client::new(),
76 basic_auth: None,
77 oauth_access_token: None,
78 bearer_access_token: None,
79 api_key: None,
80 }
81 }
82}