use std::rc::Rc;
use error_stack::{IntoReport, Result};
use reqwest::Url;
use reqwest::{Client, IntoUrl};
use serde::{Deserialize, Serialize};
mod builder;
pub mod error;
pub mod file;
mod helpers;
pub mod job;
pub mod printer;
pub mod server;
pub use builder::OctoClientBuilder;
pub struct OctoClient {
client: Client,
base_url: Url,
auth_credentials: Rc<AuthenticationMethod>,
}
#[derive(Debug, Serialize, Deserialize)]
pub enum AuthenticationMethod {
Bearer(String),
Basic { username: String, password: String },
}
impl OctoClient {
#[allow(clippy::new_ret_no_self)]
pub fn new<U: IntoUrl>(url: U) -> Result<OctoClientBuilder, reqwest::Error> {
OctoClientBuilder::new(url)
}
fn append_path_to_base_url(&self, path: &str) -> Result<Url, url::ParseError> {
self.base_url.join(path).into_report()
}
}