use crate::client::error::ScabbardClientError;
use super::ReqwestScabbardClient;
#[derive(Default)]
pub struct ReqwestScabbardClientBuilder {
url: Option<String>,
auth: Option<String>,
}
impl ReqwestScabbardClientBuilder {
pub fn new() -> Self {
Self::default()
}
pub fn with_url(mut self, url: &str) -> Self {
self.url = Some(url.into());
self
}
pub fn with_auth(mut self, auth: &str) -> Self {
self.auth = Some(auth.into());
self
}
pub fn build(self) -> Result<ReqwestScabbardClient, ScabbardClientError> {
Ok(ReqwestScabbardClient {
url: self.url.ok_or_else(|| {
ScabbardClientError::new("Failed to build client, url not provided")
})?,
auth: self.auth.ok_or_else(|| {
ScabbardClientError::new("Failed to build client, jwt authorization not provided")
})?,
})
}
}