boreholeio 0.1.0

A library for interacting with borehole.io, a subsurface data management, delivery and visualisation platform
Documentation
use authentication::Authentication;
use errors::ClientError;
use internal_client::InternalWebClient;

pub(crate) mod internal_client;

pub mod authentication;
pub mod endpoints;
pub mod errors;

pub mod prelude;

pub type Result<T> = std::result::Result<T, ClientError>;

pub struct BoreholeIoClient {
    pub(crate) web_client: InternalWebClient,
    pub(crate) base_url: String,
    pub(crate) api_url: String,
}

impl Default for BoreholeIoClient {
    fn default() -> Self {
        Self::new(BoreholeIoClientOptions::default())
    }
}

impl BoreholeIoClient {
    pub fn new(options: BoreholeIoClientOptions) -> Self {
        Self {
            web_client: InternalWebClient::new(options.authentication),
            base_url: options.base_url,
            api_url: options.api_url,
        }
    }
}

pub struct BoreholeIoClientOptions {
    pub base_url: String,
    pub api_url: String,
    pub authentication: Authentication,
}

impl Default for BoreholeIoClientOptions {
    fn default() -> Self {
        Self {
            base_url: "https://borehole.io".to_owned(), // TODO: This should be borehole.io
            api_url: "/api/v1".to_owned(),
            authentication: Default::default(),
        }
    }
}

// Internal functions
impl BoreholeIoClient {
    pub(crate) fn base_url(&self) -> String {
        format!("{}{}", self.base_url, self.api_url)
    }
}