use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(test, derive(Default))]
pub struct Locale {
#[serde(rename = "ip")]
pub ip: String,
#[serde(rename = "countryCode")]
pub country_code: String,
#[serde(rename = "country")]
pub country: String,
#[serde(rename = "continentCode")]
pub continent_code: String,
#[serde(rename = "continent")]
pub continent: String,
#[serde(rename = "eu")]
pub eu: bool,
#[serde(rename = "currency")]
pub currency: String,
}
impl Locale {
pub fn ip(&self) -> &String {
&self.ip
}
pub fn country_code(&self) -> &String {
&self.country_code
}
pub fn country(&self) -> &String {
&self.country
}
pub fn continent_code(&self) -> &String {
&self.continent_code
}
pub fn continent(&self) -> &String {
&self.continent
}
pub fn eu(&self) -> &bool {
&self.eu
}
pub fn currency(&self) -> &String {
&self.currency
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_locale_creation() {
let _model = <Locale as Default>::default();
let _ = _model.ip();
let _ = _model.country_code();
let _ = _model.country();
let _ = _model.continent_code();
let _ = _model.continent();
let _ = _model.eu();
let _ = _model.currency();
}
#[test]
fn test_locale_serialization() {
let model = <Locale as Default>::default();
let json = serde_json::to_string(&model);
assert!(json.is_ok());
let deserialized: Result<Locale, _> = serde_json::from_str(&json.unwrap());
assert!(deserialized.is_ok());
}
}