aboutsummaryrefslogtreecommitdiffstats
path: root/src/api.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2020-04-10 00:12:40 -0400
committerJesse Luehrs <doy@tozt.net>2020-04-10 00:12:40 -0400
commitb3a04c4a143c34ba92008cf018eed159f87a0c6e (patch)
treed94bdb932079318a094cbfa5ba3e9a7e83a6a468 /src/api.rs
parentc255e08021bf722558988b5a08c8e1427488c618 (diff)
downloadrbw-b3a04c4a143c34ba92008cf018eed159f87a0c6e.tar.gz
rbw-b3a04c4a143c34ba92008cf018eed159f87a0c6e.zip
move some basic stuff into config
Diffstat (limited to 'src/api.rs')
-rw-r--r--src/api.rs30
1 files changed, 7 insertions, 23 deletions
diff --git a/src/api.rs b/src/api.rs
index fc59d25..e70c45b 100644
--- a/src/api.rs
+++ b/src/api.rs
@@ -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)
}
}