pub mod check_registry;
pub mod constants;
pub mod customer_registration;
pub struct VersaClient {
client_string: Option<String>,
client_id: String,
client_secret: String,
pub registry_url: String,
}
#[derive(Debug)]
pub struct InvalidSchemaVersion(pub String);
#[derive(Debug)]
pub enum ClientError {
SchemaNotFound(String),
DeserializationError(reqwest::Error),
NetworkError(reqwest::Error),
RegistryError(http::StatusCode, String),
RemoteClientError(http::StatusCode, String),
HmacVerificationError,
}
impl VersaClient {
pub fn new(client_id: String, client_secret: String) -> Self {
let registry_url = constants::REGISTRY_URL.to_string();
Self {
client_string: None,
client_id,
client_secret,
registry_url,
}
}
pub fn with_registry_url(mut self, registry_url: &str) -> Self {
self.registry_url = registry_url.to_string();
self
}
pub fn authorization_header_val(&self) -> String {
format!("Basic {}:{}", self.client_id, self.client_secret)
}
pub fn client_id(&self) -> String {
self.client_id.clone()
}
pub fn with_client_string(mut self, client_string: &str) -> Self {
self.client_string = Some(client_string.to_string());
self
}
pub fn client_string(&self) -> Option<String> {
self.client_string.clone()
}
}