2024-07-13 19:37:30 +05:30
|
|
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
|
|
|
|
use cqrs_es::DomainEvent;
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
|
2024-07-15 17:47:50 +05:30
|
|
|
use super::{
|
|
|
|
category_added_event::*, product_added_event::ProductAddedEvent,
|
|
|
|
store_added_event::StoreAddedEvent,
|
|
|
|
};
|
2024-07-13 19:37:30 +05:30
|
|
|
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd)]
|
|
|
|
pub enum InventoryEvent {
|
2024-07-13 21:29:43 +05:30
|
|
|
CategoryAdded(CategoryAddedEvent),
|
2024-07-13 19:37:30 +05:30
|
|
|
StoreAdded(StoreAddedEvent),
|
2024-07-15 17:47:50 +05:30
|
|
|
ProductAdded(ProductAddedEvent),
|
2024-07-13 19:37:30 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
impl DomainEvent for InventoryEvent {
|
|
|
|
fn event_version(&self) -> String {
|
|
|
|
"1.0".to_string()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn event_type(&self) -> String {
|
|
|
|
let e: &str = match self {
|
2024-07-13 21:29:43 +05:30
|
|
|
InventoryEvent::CategoryAdded { .. } => "InventoryCategoryAdded",
|
2024-07-15 17:47:50 +05:30
|
|
|
InventoryEvent::StoreAdded { .. } => "InventoryStoreAdded",
|
|
|
|
InventoryEvent::ProductAdded { .. } => "InventoryProductAdded",
|
2024-07-13 19:37:30 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
e.to_string()
|
|
|
|
}
|
|
|
|
}
|