forked from mirror/Riven
1
0
Fork 0
Riven/src/riot_api.rs

27 lines
788 B
Rust
Raw Normal View History

2019-10-17 23:00:04 +00:00
use crate::RiotApiConfig;
use crate::consts::Region;
use crate::req::RequesterManager;
pub struct RiotApi<'a> {
requester_manager: RequesterManager<'a>,
}
impl<'a> RiotApi<'a> {
pub fn with_config(config: RiotApiConfig<'a>) -> Self {
Self {
requester_manager: RequesterManager::new(config),
}
}
pub fn with_key(api_key: &'a str) -> Self {
Self::with_config(RiotApiConfig::with_key(api_key))
}
pub async fn get<T: serde::de::DeserializeOwned>(
&'a self, method_id: &'a str, region: &'a Region<'a>, relative_url: &'_ str,
query: &[(&'_ str, &'_ str)]) -> Result<Option<T>, reqwest::Error>
{
self.requester_manager.get(method_id, region, relative_url, query).await
}
}