nomy_data_models/models/
wallet_state.rs

1#![allow(clippy::too_many_arguments, unused_imports, non_camel_case_types)]
2//! WalletState model definition.
3//!
4//! This file is generated automatically from the Python SQLAlchemy model.
5//! Do not edit this file manually.
6
7use serde::{Deserialize, Serialize};
8
9// Standard imports that may be needed
10use chrono::{DateTime, Utc};
11use rust_decimal::Decimal;
12use serde_json::Value as JsonValue;
13use uuid::Uuid;
14
15// Additional imports specific to this model
16use crate::enums::SyncState;
17
18/// Model for tracking wallet data quality and completeness state.
19#[derive(Debug, Clone, Serialize, Deserialize)]
20pub struct WalletState {
21    pub wallet_address: String,
22    pub chain_id: i32,
23    pub data_states: JsonValue,
24    pub sync_state: String,
25    pub id: Uuid,
26    pub created_at: DateTime<Utc>,
27    pub updated_at: DateTime<Utc>,
28    pub created_by: Option<String>,
29    pub updated_by: Option<String>,
30}
31
32impl WalletState {
33    /// Create a new WalletState.
34    pub fn new(
35        wallet_address: String,
36        chain_id: i32,
37        data_states: JsonValue,
38        sync_state: String,
39        id: Uuid,
40        created_at: DateTime<Utc>,
41        updated_at: DateTime<Utc>,
42        created_by: String,
43        updated_by: String,
44    ) -> Self {
45        Self {
46            wallet_address,
47            chain_id,
48            data_states,
49            sync_state,
50            id,
51            created_at,
52            updated_at,
53            created_by: Some(created_by),
54            updated_by: Some(updated_by),
55        }
56    }
57
58    /// Convert to a JSON string.
59    pub fn to_json(&self) -> Result<String, serde_json::Error> {
60        serde_json::to_string(self)
61    }
62
63    /// Convert from a JSON string.
64    pub fn from_json(json: &str) -> Result<Self, serde_json::Error> {
65        serde_json::from_str(json)
66    }
67
68    /// Convert to a dictionary-like structure.
69    pub fn to_dict(&self) -> serde_json::Map<String, serde_json::Value> {
70        let json = serde_json::to_value(self).unwrap_or(serde_json::Value::Null);
71        if let serde_json::Value::Object(map) = json {
72            map
73        } else {
74            serde_json::Map::new()
75        }
76    }
77}