use super::seg;
use crate::error::Result;
use crate::http::HttpClient;
use crate::models::{Carrier, Country, CountryRules, Route};
#[derive(Debug, Clone)]
pub struct Countries {
http: HttpClient,
}
impl Countries {
pub(crate) fn new(http: HttpClient) -> Self {
Self { http }
}
pub async fn list(&self) -> Result<Vec<Country>> {
self.http.get("/v1/countries").await
}
pub async fn carriers(&self, iso2: &str) -> Result<Vec<Carrier>> {
self.http
.get(&format!("/v1/countries/{}/carriers", seg(iso2, "iso2")?))
.await
}
pub async fn routes(&self, iso2: &str) -> Result<Vec<Route>> {
self.http
.get(&format!("/v1/countries/{}/routes", seg(iso2, "iso2")?))
.await
}
pub async fn compliance(&self, iso2: &str) -> Result<CountryRules> {
self.http
.get(&format!("/v1/countries/{}/compliance", seg(iso2, "iso2")?))
.await
}
}