nomy-data-models 0.2.4

Data model definitions for Nomy wallet analysis data processing
Documentation
#![allow(clippy::too_many_arguments, unused_imports, non_camel_case_types)]
//! {model_name} model definition.
//!
//! This file is generated automatically from the Python SQLAlchemy model.
//! Do not edit this file manually.

use serde::{Deserialize, Serialize};

// Standard imports that may be needed
use chrono::{DateTime, Utc};
use rust_decimal::Decimal;
use serde_json::Value as JsonValue;
use uuid::Uuid;

// Additional imports specific to this model
{imports}

/// {model_doc}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct {model_name} {
{fields}
}

impl {model_name} {
    /// Create a new {model_name}.
    pub fn new(
        {constructor_args}
    ) -> Self {
        Self {
{constructor_body}
        }
    }

    /// Convert to a JSON string.
    pub fn to_json(&self) -> Result<String, serde_json::Error> {
        serde_json::to_string(self)
    }

    /// Convert from a JSON string.
    pub fn from_json(json: &str) -> Result<Self, serde_json::Error> {
        serde_json::from_str(json)
    }

    /// Convert to a dictionary-like structure.
    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()
        }
    }
}