From 2f3a092b531795fb9a6e4585930c1bc9167faf16 Mon Sep 17 00:00:00 2001 From: Samuel Vasco Date: Tue, 26 Aug 2025 08:17:41 -0400 Subject: [PATCH] feat: add application approved event --- unit/models/codecs.py | 3 +++ unit/models/event.py | 12 +++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/unit/models/codecs.py b/unit/models/codecs.py index aed24b2..2796c5c 100644 --- a/unit/models/codecs.py +++ b/unit/models/codecs.py @@ -226,6 +226,9 @@ "account.frozen": lambda _id, _type, attributes, relationships: AccountFrozenEvent.from_json_api(_id, _type, attributes, relationships), + "application.approved": lambda _id, _type, attributes, relationships: + ApplicationApprovedEvent.from_json_api(_id, _type, attributes, relationships), + "application.awaitingDocuments": lambda _id, _type, attributes, relationships: ApplicationAwaitingDocumentsEvent.from_json_api(_id, _type, attributes, relationships), diff --git a/unit/models/event.py b/unit/models/event.py index a9d2e28..2c4c975 100644 --- a/unit/models/event.py +++ b/unit/models/event.py @@ -38,7 +38,17 @@ def __init__(self, id: str, created_at: datetime, freeze_reason: str, tags: Opti def from_json_api(_id, _type, attributes, relationships): return AccountFrozenEvent(_id, date_utils.to_datetime(attributes["createdAt"]), attributes["freezeReason"], attributes.get("tags"), relationships) + +class ApplicationApprovedEvent(BaseEvent): + def __init__(self, id: str, created_at: datetime, tags: Optional[Dict[str, str]], + relationships: Optional[Dict[str, Relationship]]): + BaseEvent.__init__(self, id, created_at, tags, relationships) + self.type = 'application.approved' + @staticmethod + def from_json_api(_id, _type, attributes, relationships): + return ApplicationApprovedEvent(_id, date_utils.to_datetime(attributes["createdAt"]), attributes.get("tags"), + relationships) class ApplicationDeniedEvent(BaseEvent): def __init__(self, id: str, created_at: datetime, tags: Optional[Dict[str, str]], @@ -895,7 +905,7 @@ def from_json_api(_id, _type, attributes, relationships): EventDTO = Union[ - AccountClosedEvent, AccountFrozenEvent, ApplicationDeniedEvent, ApplicationAwaitingDocumentsEvent, + AccountClosedEvent, AccountFrozenEvent, ApplicationApprovedEvent, ApplicationDeniedEvent, ApplicationAwaitingDocumentsEvent, ApplicationPendingReviewEvent, CardActivatedEvent, CardStatusChangedEvent, CardFraudCaseCreatedEvent, CardFraudCaseActivatedEvent, CardFraudCaseExpiredEvent, CardFraudCaseFraudEvent, CardFraudCaseNoFraudEvent,