use crate::{by_id, from_json};
use serde::{Deserialize, Serialize};
use serde_with::skip_serializing_none;
const PLACEHOLDER_JSON_USERS: &str = include_str!("users.json");
#[skip_serializing_none]
#[derive(Deserialize, Serialize)]
pub struct Geo {
pub lat: String,
pub lng: String,
}
#[skip_serializing_none]
#[derive(Deserialize, Serialize)]
pub struct Address {
pub street: String,
pub suite: String,
pub city: String,
pub zipcode: String,
pub geo: Geo,
}
#[skip_serializing_none]
#[derive(Deserialize, Serialize)]
pub struct Company {
pub name: String,
#[serde(rename = "catchPhrase")]
pub catch_phrase: String,
pub bs: String,
}
#[skip_serializing_none]
#[derive(Deserialize, Serialize)]
pub struct User {
pub id: Option<i32>,
pub name: String,
pub username: String,
pub email: String,
pub address: Address,
pub phone: String,
pub website: String,
pub company: Company,
}
pub fn get_all() -> Vec<User> {
from_json!(PLACEHOLDER_JSON_USERS)
}
pub fn get(id: i32) -> User {
by_id!(id)
}