#![allow(clippy::too_many_arguments, unused_imports, non_camel_case_types)]
use serde::{Deserialize, Serialize};
use chrono::{DateTime, Utc};
use rust_decimal::Decimal;
use serde_json::Value as JsonValue;
use uuid::Uuid;
{imports}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct {model_name} {
{fields}
}
impl {model_name} {
pub fn new(
{constructor_args}
) -> Self {
Self {
{constructor_body}
}
}
pub fn to_json(&self) -> Result<String, serde_json::Error> {
serde_json::to_string(self)
}
pub fn from_json(json: &str) -> Result<Self, serde_json::Error> {
serde_json::from_str(json)
}
pub fn to_dict(&self) -> serde_json::Map<String, serde_json::Value> {
let json = serde_json::to_value(self).unwrap_or(serde_json::Value::Null);
if let serde_json::Value::Object(map) = json {
map
} else {
serde_json::Map::new()
}
}
}