use crate::client::Client;
use reqwest::Method;
use std::collections::HashMap;
#[derive(Debug, Clone)]
pub struct Locale {
client: Client,
}
impl Locale {
pub fn new(client: &Client) -> Self {
Self {
client: client.clone(),
}
}
pub fn client(&self) -> &Client {
&self.client
}
pub async fn get(&self) -> crate::error::Result<crate::models::Locale> {
let params = HashMap::new();
let mut api_headers = HashMap::new();
api_headers.insert("accept".to_string(), "application/json".to_string());
let path = "/locale".to_string();
self.client
.call(Method::GET, &path, Some(api_headers), Some(params))
.await
}
pub async fn list_codes(&self) -> crate::error::Result<crate::models::LocaleCodeList> {
let params = HashMap::new();
let mut api_headers = HashMap::new();
api_headers.insert("accept".to_string(), "application/json".to_string());
let path = "/locale/codes".to_string();
self.client
.call(Method::GET, &path, Some(api_headers), Some(params))
.await
}
pub async fn list_continents(&self) -> crate::error::Result<crate::models::ContinentList> {
let params = HashMap::new();
let mut api_headers = HashMap::new();
api_headers.insert("accept".to_string(), "application/json".to_string());
let path = "/locale/continents".to_string();
self.client
.call(Method::GET, &path, Some(api_headers), Some(params))
.await
}
pub async fn list_countries(&self) -> crate::error::Result<crate::models::CountryList> {
let params = HashMap::new();
let mut api_headers = HashMap::new();
api_headers.insert("accept".to_string(), "application/json".to_string());
let path = "/locale/countries".to_string();
self.client
.call(Method::GET, &path, Some(api_headers), Some(params))
.await
}
pub async fn list_countries_eu(&self) -> crate::error::Result<crate::models::CountryList> {
let params = HashMap::new();
let mut api_headers = HashMap::new();
api_headers.insert("accept".to_string(), "application/json".to_string());
let path = "/locale/countries/eu".to_string();
self.client
.call(Method::GET, &path, Some(api_headers), Some(params))
.await
}
pub async fn list_countries_phones(&self) -> crate::error::Result<crate::models::PhoneList> {
let params = HashMap::new();
let mut api_headers = HashMap::new();
api_headers.insert("accept".to_string(), "application/json".to_string());
let path = "/locale/countries/phones".to_string();
self.client
.call(Method::GET, &path, Some(api_headers), Some(params))
.await
}
pub async fn list_currencies(&self) -> crate::error::Result<crate::models::CurrencyList> {
let params = HashMap::new();
let mut api_headers = HashMap::new();
api_headers.insert("accept".to_string(), "application/json".to_string());
let path = "/locale/currencies".to_string();
self.client
.call(Method::GET, &path, Some(api_headers), Some(params))
.await
}
pub async fn list_languages(&self) -> crate::error::Result<crate::models::LanguageList> {
let params = HashMap::new();
let mut api_headers = HashMap::new();
api_headers.insert("accept".to_string(), "application/json".to_string());
let path = "/locale/languages".to_string();
self.client
.call(Method::GET, &path, Some(api_headers), Some(params))
.await
}
}
impl crate::services::Service for Locale {
fn client(&self) -> &Client {
&self.client
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_locale_creation() {
let client = Client::new();
let service = Locale::new(&client);
assert!(service.client().endpoint().contains("cloud.appwrite.io/v1"));
}
}