use crate::models::prelude::*;
use crate::requests::*;
#[derive(Debug)]
pub struct CanvasInformation<'i> {
base_url: &'i str,
token: &'i str,
}
impl<'i> CanvasInformation<'i> {
pub fn new(base_url: &'i str, token: &'i str) -> Self {
Self { base_url, token }
}
pub(crate) fn add_url_prefix(&self, url: &str) -> String {
format!("{}/api/v1/{}", self.base_url, url)
}
#[cfg(not(feature = "blocking"))]
pub(crate) fn get_request(&self, url: String) -> reqwest::RequestBuilder {
reqwest::Client::new().get(&url).bearer_auth(self.token)
}
#[cfg(feature = "blocking")]
pub(crate) fn get_request(&self, url: String) -> reqwest::blocking::RequestBuilder {
reqwest::blocking::Client::new()
.get(&url)
.bearer_auth(self.token)
}
pub(crate) fn get_token(&self) -> &str {
self.token
}
}