use serde::{Deserialize, Serialize};
use super::{customer_id::CustomerId, event_id::EventId, event_type::EventType};
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
#[non_exhaustive]
pub struct AutoTopUpCapReachedEvent {
pub attempted_amount: i64,
pub cap: i64,
pub currency: String,
pub customer_id: CustomerId,
pub period: String,
pub period_end: chrono::DateTime<chrono::Utc>,
pub period_start: chrono::DateTime<chrono::Utc>,
pub id: EventId,
pub timestamp: chrono::DateTime<chrono::Utc>,
pub r#type: EventType,
#[serde(flatten)]
pub extra: serde_json::Map<String, serde_json::Value>,
}
impl AutoTopUpCapReachedEvent {
#[must_use]
pub fn new(
attempted_amount: i64,
cap: i64,
currency: impl Into<String>,
customer_id: impl Into<CustomerId>,
period: impl Into<String>,
period_end: chrono::DateTime<chrono::Utc>,
period_start: chrono::DateTime<chrono::Utc>,
id: impl Into<EventId>,
timestamp: chrono::DateTime<chrono::Utc>,
r#type: EventType,
) -> Self {
Self {
attempted_amount,
cap,
currency: currency.into(),
customer_id: customer_id.into(),
period: period.into(),
period_end,
period_start,
id: id.into(),
timestamp,
r#type,
extra: serde_json::Map::new(),
}
}
}