use crate::{Client, LTAError, LTAResult};
#[derive(Debug, Clone)]
pub struct LTAClient {
api_key: String,
client: reqwest::Client,
}
impl Client for LTAClient {
type InternalClient = reqwest::Client;
type RB = reqwest::RequestBuilder;
fn new(api_key: impl Into<String>, client: Self::InternalClient) -> LTAClient {
let api_key = api_key.into();
LTAClient { api_key, client }
}
fn with_api_key(api_key: impl Into<String>) -> LTAResult<Self> {
let api_key = api_key.into();
if api_key.is_empty() {
return Err(LTAError::InvalidAPIKey);
}
let client = reqwest::Client::new();
Ok(LTAClient { api_key, client })
}
fn req_builder(&self, url: &str) -> Self::RB {
self.client
.get(url)
.header("AccountKey", self.api_key.as_str())
}
}