Skip to content

Instantly share code, notes, and snippets.

@mariobittencourt
Created May 27, 2020 20:54
Show Gist options
  • Save mariobittencourt/bca6c8d4510b2b4fd18d247cc4ea9ca5 to your computer and use it in GitHub Desktop.
Save mariobittencourt/bca6c8d4510b2b4fd18d247cc4ea9ca5 to your computer and use it in GitHub Desktop.
Domain event + payment created event
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