diff options
author | Jesse Luehrs <doy@tozt.net> | 2020-04-10 00:12:40 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2020-04-10 00:12:40 -0400 |
commit | b3a04c4a143c34ba92008cf018eed159f87a0c6e (patch) | |
tree | d94bdb932079318a094cbfa5ba3e9a7e83a6a468 /src/api.rs | |
parent | c255e08021bf722558988b5a08c8e1427488c618 (diff) | |
download | rbw-b3a04c4a143c34ba92008cf018eed159f87a0c6e.tar.gz rbw-b3a04c4a143c34ba92008cf018eed159f87a0c6e.zip |
move some basic stuff into config
Diffstat (limited to 'src/api.rs')
-rw-r--r-- | src/api.rs | 30 |
1 files changed, 7 insertions, 23 deletions
@@ -72,31 +72,15 @@ pub struct Login { #[derive(Debug)] pub struct Client { - api_url_base: String, - identity_url_base: String, -} - -impl Default for Client { - fn default() -> Self { - Self { - api_url_base: "https://api.bitwarden.com".to_string(), - identity_url_base: "https://identity.bitwarden.com".to_string(), - } - } + base_url: String, + identity_url: String, } impl Client { - #[allow(dead_code)] - #[must_use] - pub fn new() -> Self { - Self::default() - } - - #[must_use] - pub fn new_self_hosted(base_url: &str) -> Self { + pub fn new(base_url: &str, identity_url: &str) -> Self { Self { - api_url_base: format!("{}/api", base_url), - identity_url_base: format!("{}/identity", base_url), + base_url: base_url.to_string(), + identity_url: identity_url.to_string(), } } @@ -167,10 +151,10 @@ impl Client { } fn api_url(&self, path: &str) -> String { - format!("{}{}", self.api_url_base, path) + format!("{}{}", self.base_url, path) } fn identity_url(&self, path: &str) -> String { - format!("{}{}", self.identity_url_base, path) + format!("{}{}", self.identity_url, path) } } |