Created
May 27, 2020 20:54
-
-
Save mariobittencourt/bca6c8d4510b2b4fd18d247cc4ea9ca5 to your computer and use it in GitHub Desktop.
Domain event + payment created event
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime | |
from abc import ABC, ABCMeta, abstractmethod | |
class DomainEvent(ABC, metaclass=ABCMeta): | |
@abstractmethod | |
def __init__(self, aggregate_id: str, occurred_at: str): | |
self.type = self.__class__.__name__ | |
self.aggregate_id = aggregate_id | |
self.occurred_at = occurred_at | |
class PaymentCreated(DomainEvent): | |
def __init__(self, aggregate_id: str, amount_due: float, occurred_at: str = datetime.utcnow().isoformat()): | |
super().__init__(aggregate_id, occurred_at) | |
self.amount_due = amount_due |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment