From 01c24034bdd5a4888c003916f1e0a78aa48719e4 Mon Sep 17 00:00:00 2001 From: axshani Date: Wed, 3 Apr 2024 08:44:46 +0300 Subject: [PATCH 1/8] check payment - new events --- unit/models/event.py | 69 +++++++++++++++++++++++++++++--------------- 1 file changed, 45 insertions(+), 24 deletions(-) diff --git a/unit/models/event.py b/unit/models/event.py index 1eeaf28c..6265aa69 100644 --- a/unit/models/event.py +++ b/unit/models/event.py @@ -197,43 +197,60 @@ class CheckPaymentPendingEvent(BaseEvent): def from_json_api(_id, _type, attributes, relationships): return CheckPaymentPendingEvent(_id, _type, attributes, relationships) -class CheckPaymentProcessedEvent(BaseEvent): + +class CheckPaymentRejectedEvent(BaseEvent): @staticmethod def from_json_api(_id, _type, attributes, relationships): - return CheckPaymentProcessedEvent(_id, _type, attributes, relationships) + return CheckPaymentRejectedEvent(_id, _type, attributes, relationships) -class CheckPaymentReturnedEvent(BaseEvent): +class CheckPaymentInProductionEvent(BaseEvent): @staticmethod def from_json_api(_id, _type, attributes, relationships): - return CheckPaymentReturnedEvent(_id, _type, attributes, relationships) + return CheckPaymentInProductionEvent(_id, _type, attributes, relationships) -class CheckPaymentPendingEvent(BaseEvent): +class CheckPaymentInDeliveryEvent(BaseEvent): @staticmethod def from_json_api(_id, _type, attributes, relationships): - return CheckPaymentPendingEvent(_id, _type, attributes, relationships) + return CheckPaymentInDeliveryEvent(_id, _type, attributes, relationships) -EventDTO = Union[AccountClosedEvent, AccountFrozenEvent, ApplicationDeniedEvent, ApplicationPendingReviewEvent, - ApplicationAwaitingDocumentsEvent, AuthorizationCreatedEvent, AuthorizationRequestApprovedEvent, - AuthorizationRequestDeclinedEvent, AuthorizationRequestPendingEvent, CardActivatedEvent, - CardStatusChangedEvent, CheckDepositCreatedEvent, CheckDepositClearingEvent, CheckDepositSentEvent, - CheckDepositReturnedEvent, CustomerCreatedEvent, DocumentApprovedEvent, DocumentRejectedEvent, - PaymentClearingEvent, PaymentSentEvent, PaymentReturnedEvent, StatementsCreatedEvent, - TransactionCreatedEvent, AccountReopenedEvent, CheckPaymentCreatedEvent, - CheckPaymentMarkedForReturnEvent, CheckPaymentProcessedEvent, CheckPaymentReturnedEvent, - CheckPaymentPendingEvent] +class CheckPaymentDeliveredEvent(BaseEvent): + @staticmethod + def from_json_api(_id, _type, attributes, relationships): + return CheckPaymentDeliveredEvent(_id, _type, attributes, relationships) -def events_mapper(_id, _type, attributes, relationships): - c = globals() - dot = _type.index(".") - c_name = _type[0].upper() + _type[1:dot] + _type[dot+1].upper() + _type[dot+2:] + "Event" - if c_name in c.keys(): - return c[c_name].from_json_api(_id, _type, attributes, relationships) - else: - return RawUnitObject(_id, _type, attributes, relationships) +class CheckPaymentReturnToSenderEvent(BaseEvent): + @staticmethod + def from_json_api(_id, _type, attributes, relationships): + return CheckPaymentReturnToSenderEvent(_id, _type, attributes, relationships) + + +class CheckPaymentCanceledEvent(BaseEvent): + @staticmethod + def from_json_api(_id, _type, attributes, relationships): + return CheckPaymentCanceledEvent(_id, _type, attributes, relationships) + + +class CheckPaymentDeliveryStatusChangedEvent(BaseEvent): + @staticmethod + def from_json_api(_id, _type, attributes, relationships): + return CheckPaymentDeliveryStatusChangedEvent(_id, _type, attributes, relationships) + + +class CheckPaymentAdditionalVerificationRequiredEvent(BaseEvent): + @staticmethod + def from_json_api(_id, _type, attributes, relationships): + return CheckPaymentAdditionalVerificationRequiredEvent(_id, _type, attributes, relationships) + + +class CheckPaymentAdditionalVerificationApprovedRequiredEvent(BaseEvent): + @staticmethod + def from_json_api(_id, _type, attributes, relationships): + return CheckPaymentAdditionalVerificationApprovedRequiredEvent(_id, _type, attributes, relationships) + class TaxFormCreatedEvent(BaseEvent): @staticmethod @@ -255,7 +272,11 @@ def from_json_api(_id, _type, attributes, relationships): PaymentClearingEvent, PaymentSentEvent, PaymentReturnedEvent, StatementsCreatedEvent, TransactionCreatedEvent, AccountReopenedEvent, CheckPaymentCreatedEvent, CheckPaymentMarkedForReturnEvent, CheckPaymentProcessedEvent, CheckPaymentReturnedEvent, - CheckPaymentPendingEvent, TaxFormCreatedEvent, TaxFormUpdatedEvent] + CheckPaymentRejectedEvent, CheckPaymentInProductionEvent, CheckPaymentInDeliveryEvent, + CheckPaymentDeliveredEvent, CheckPaymentReturnToSenderEvent, CheckPaymentCanceledEvent, + CheckPaymentDeliveryStatusChangedEvent, CheckPaymentAdditionalVerificationRequiredEvent, + CheckPaymentAdditionalVerificationApprovedRequiredEvent, CheckPaymentPendingEvent, + TaxFormCreatedEvent, TaxFormUpdatedEvent] def events_mapper(_id, _type, attributes, relationships): From 725095e51cddd82fdcfba14ece9402079b70c447 Mon Sep 17 00:00:00 2001 From: axshani Date: Wed, 3 Apr 2024 11:51:32 +0300 Subject: [PATCH 2/8] CreditApplication events --- unit/models/event.py | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/unit/models/event.py b/unit/models/event.py index 6265aa69..6d83c720 100644 --- a/unit/models/event.py +++ b/unit/models/event.py @@ -264,6 +264,36 @@ def from_json_api(_id, _type, attributes, relationships): return TaxFormUpdatedEvent(_id, _type, attributes, relationships) +class CreditApplicationCreatedEvent(BaseEvent): + @staticmethod + def from_json_api(_id, _type, attributes, relationships): + return CreditApplicationCreatedEvent(_id, _type, attributes, relationships) + + +class CreditApplicationPendingEvent(BaseEvent): + @staticmethod + def from_json_api(_id, _type, attributes, relationships): + return CreditApplicationPendingEvent(_id, _type, attributes, relationships) + + +class CreditApplicationApprovedEvent(BaseEvent): + @staticmethod + def from_json_api(_id, _type, attributes, relationships): + return CreditApplicationApprovedEvent(_id, _type, attributes, relationships) + + +class CreditApplicationDeniedEvent(BaseEvent): + @staticmethod + def from_json_api(_id, _type, attributes, relationships): + return CreditApplicationDeniedEvent(_id, _type, attributes, relationships) + + +class CreditApplicationCanceledEvent(BaseEvent): + @staticmethod + def from_json_api(_id, _type, attributes, relationships): + return CreditApplicationCanceledEvent(_id, _type, attributes, relationships) + + EventDTO = Union[AccountClosedEvent, AccountFrozenEvent, ApplicationDeniedEvent, ApplicationPendingReviewEvent, ApplicationAwaitingDocumentsEvent, AuthorizationCreatedEvent, AuthorizationRequestApprovedEvent, AuthorizationRequestDeclinedEvent, AuthorizationRequestPendingEvent, CardActivatedEvent, @@ -276,7 +306,9 @@ def from_json_api(_id, _type, attributes, relationships): CheckPaymentDeliveredEvent, CheckPaymentReturnToSenderEvent, CheckPaymentCanceledEvent, CheckPaymentDeliveryStatusChangedEvent, CheckPaymentAdditionalVerificationRequiredEvent, CheckPaymentAdditionalVerificationApprovedRequiredEvent, CheckPaymentPendingEvent, - TaxFormCreatedEvent, TaxFormUpdatedEvent] + TaxFormCreatedEvent, TaxFormUpdatedEvent, CreditApplicationCreatedEvent, + CreditApplicationCanceledEvent, CreditApplicationDeniedEvent, CreditApplicationPendingEvent, + CreditApplicationApprovedEvent] def events_mapper(_id, _type, attributes, relationships): From 46439ace79871c8c1fc80cbe3d64599bc296b44d Mon Sep 17 00:00:00 2001 From: axshani Date: Wed, 3 Apr 2024 12:36:03 +0300 Subject: [PATCH 3/8] Repayment Events --- unit/models/event.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/unit/models/event.py b/unit/models/event.py index 6d83c720..0d57f0dd 100644 --- a/unit/models/event.py +++ b/unit/models/event.py @@ -294,6 +294,18 @@ def from_json_api(_id, _type, attributes, relationships): return CreditApplicationCanceledEvent(_id, _type, attributes, relationships) +class RepaymentStatusChangedEvent(BaseEvent): + @staticmethod + def from_json_api(_id, _type, attributes, relationships): + return RepaymentStatusChangedEvent(_id, _type, attributes, relationships) + + +class RepaymentCreatedEvent(BaseEvent): + @staticmethod + def from_json_api(_id, _type, attributes, relationships): + return RepaymentCreatedEvent(_id, _type, attributes, relationships) + + EventDTO = Union[AccountClosedEvent, AccountFrozenEvent, ApplicationDeniedEvent, ApplicationPendingReviewEvent, ApplicationAwaitingDocumentsEvent, AuthorizationCreatedEvent, AuthorizationRequestApprovedEvent, AuthorizationRequestDeclinedEvent, AuthorizationRequestPendingEvent, CardActivatedEvent, @@ -308,7 +320,7 @@ def from_json_api(_id, _type, attributes, relationships): CheckPaymentAdditionalVerificationApprovedRequiredEvent, CheckPaymentPendingEvent, TaxFormCreatedEvent, TaxFormUpdatedEvent, CreditApplicationCreatedEvent, CreditApplicationCanceledEvent, CreditApplicationDeniedEvent, CreditApplicationPendingEvent, - CreditApplicationApprovedEvent] + CreditApplicationApprovedEvent, RepaymentStatusChangedEvent, RepaymentCreatedEvent] def events_mapper(_id, _type, attributes, relationships): From 1f6e3b92dc5fb9809496685f14f8dd618d008b72 Mon Sep 17 00:00:00 2001 From: axshani Date: Wed, 3 Apr 2024 12:47:17 +0300 Subject: [PATCH 4/8] ReceivedPayment Events --- unit/models/event.py | 47 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/unit/models/event.py b/unit/models/event.py index 0d57f0dd..76e8bb86 100644 --- a/unit/models/event.py +++ b/unit/models/event.py @@ -306,6 +306,48 @@ def from_json_api(_id, _type, attributes, relationships): return RepaymentCreatedEvent(_id, _type, attributes, relationships) +class ReceivedPaymentCreatedEvent(BaseEvent): + @staticmethod + def from_json_api(_id, _type, attributes, relationships): + return ReceivedPaymentCreatedEvent(_id, _type, attributes, relationships) + + +class ReceivedPaymentAdvancedEvent(BaseEvent): + @staticmethod + def from_json_api(_id, _type, attributes, relationships): + return ReceivedPaymentAdvancedEvent(_id, _type, attributes, relationships) + + +class ReceivedPaymentPendingReviewEvent(BaseEvent): + @staticmethod + def from_json_api(_id, _type, attributes, relationships): + return ReceivedPaymentPendingReviewEvent(_id, _type, attributes, relationships) + + +class ReceivedPaymentPendingEvent(BaseEvent): + @staticmethod + def from_json_api(_id, _type, attributes, relationships): + return ReceivedPaymentPendingEvent(_id, _type, attributes, relationships) + + +class ReceivedPaymentMarkedForReturnEvent(BaseEvent): + @staticmethod + def from_json_api(_id, _type, attributes, relationships): + return ReceivedPaymentMarkedForReturnEvent(_id, _type, attributes, relationships) + + +class ReceivedPaymentCompletedEvent(BaseEvent): + @staticmethod + def from_json_api(_id, _type, attributes, relationships): + return ReceivedPaymentCompletedEvent(_id, _type, attributes, relationships) + + +class ReceivedPaymentReturnedEvent(BaseEvent): + @staticmethod + def from_json_api(_id, _type, attributes, relationships): + return ReceivedPaymentReturnedEvent(_id, _type, attributes, relationships) + + EventDTO = Union[AccountClosedEvent, AccountFrozenEvent, ApplicationDeniedEvent, ApplicationPendingReviewEvent, ApplicationAwaitingDocumentsEvent, AuthorizationCreatedEvent, AuthorizationRequestApprovedEvent, AuthorizationRequestDeclinedEvent, AuthorizationRequestPendingEvent, CardActivatedEvent, @@ -320,7 +362,10 @@ def from_json_api(_id, _type, attributes, relationships): CheckPaymentAdditionalVerificationApprovedRequiredEvent, CheckPaymentPendingEvent, TaxFormCreatedEvent, TaxFormUpdatedEvent, CreditApplicationCreatedEvent, CreditApplicationCanceledEvent, CreditApplicationDeniedEvent, CreditApplicationPendingEvent, - CreditApplicationApprovedEvent, RepaymentStatusChangedEvent, RepaymentCreatedEvent] + CreditApplicationApprovedEvent, RepaymentStatusChangedEvent, RepaymentCreatedEvent, + ReceivedPaymentCreatedEvent, ReceivedPaymentReturnedEvent, ReceivedPaymentCompletedEvent, + ReceivedPaymentAdvancedEvent, ReceivedPaymentPendingEvent, ReceivedPaymentPendingReviewEvent, + ReceivedPaymentMarkedForReturnEvent] def events_mapper(_id, _type, attributes, relationships): From a8e9635ff84a1365ae7b4ded5e401484ec466ee4 Mon Sep 17 00:00:00 2001 From: axshani Date: Wed, 3 Apr 2024 12:52:28 +0300 Subject: [PATCH 5/8] Reward and Chargeback Events --- unit/models/event.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/unit/models/event.py b/unit/models/event.py index 76e8bb86..206ba856 100644 --- a/unit/models/event.py +++ b/unit/models/event.py @@ -348,6 +348,24 @@ def from_json_api(_id, _type, attributes, relationships): return ReceivedPaymentReturnedEvent(_id, _type, attributes, relationships) +class RewardSentEvent(BaseEvent): + @staticmethod + def from_json_api(_id, _type, attributes, relationships): + return RewardSentEvent(_id, _type, attributes, relationships) + + +class RewardRejectedEvent(BaseEvent): + @staticmethod + def from_json_api(_id, _type, attributes, relationships): + return RewardRejectedEvent(_id, _type, attributes, relationships) + + +class ChargebackCreatedEvent(BaseEvent): + @staticmethod + def from_json_api(_id, _type, attributes, relationships): + return ChargebackCreatedEvent(_id, _type, attributes, relationships) + + EventDTO = Union[AccountClosedEvent, AccountFrozenEvent, ApplicationDeniedEvent, ApplicationPendingReviewEvent, ApplicationAwaitingDocumentsEvent, AuthorizationCreatedEvent, AuthorizationRequestApprovedEvent, AuthorizationRequestDeclinedEvent, AuthorizationRequestPendingEvent, CardActivatedEvent, @@ -365,7 +383,7 @@ def from_json_api(_id, _type, attributes, relationships): CreditApplicationApprovedEvent, RepaymentStatusChangedEvent, RepaymentCreatedEvent, ReceivedPaymentCreatedEvent, ReceivedPaymentReturnedEvent, ReceivedPaymentCompletedEvent, ReceivedPaymentAdvancedEvent, ReceivedPaymentPendingEvent, ReceivedPaymentPendingReviewEvent, - ReceivedPaymentMarkedForReturnEvent] + ReceivedPaymentMarkedForReturnEvent, RewardSentEvent, RewardRejectedEvent, ChargebackCreatedEvent] def events_mapper(_id, _type, attributes, relationships): From 95ac09cd06bb7f5934b877af05accccacd15219a Mon Sep 17 00:00:00 2001 From: axshani Date: Wed, 3 Apr 2024 13:36:46 +0300 Subject: [PATCH 6/8] StatementCreatedEvent --- unit/models/event.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/unit/models/event.py b/unit/models/event.py index 206ba856..5a9c735e 100644 --- a/unit/models/event.py +++ b/unit/models/event.py @@ -366,6 +366,12 @@ def from_json_api(_id, _type, attributes, relationships): return ChargebackCreatedEvent(_id, _type, attributes, relationships) +class StatementCreatedEvent(BaseEvent): + @staticmethod + def from_json_api(_id, _type, attributes, relationships): + return StatementCreatedEvent(_id, _type, attributes, relationships) + + EventDTO = Union[AccountClosedEvent, AccountFrozenEvent, ApplicationDeniedEvent, ApplicationPendingReviewEvent, ApplicationAwaitingDocumentsEvent, AuthorizationCreatedEvent, AuthorizationRequestApprovedEvent, AuthorizationRequestDeclinedEvent, AuthorizationRequestPendingEvent, CardActivatedEvent, @@ -383,7 +389,8 @@ def from_json_api(_id, _type, attributes, relationships): CreditApplicationApprovedEvent, RepaymentStatusChangedEvent, RepaymentCreatedEvent, ReceivedPaymentCreatedEvent, ReceivedPaymentReturnedEvent, ReceivedPaymentCompletedEvent, ReceivedPaymentAdvancedEvent, ReceivedPaymentPendingEvent, ReceivedPaymentPendingReviewEvent, - ReceivedPaymentMarkedForReturnEvent, RewardSentEvent, RewardRejectedEvent, ChargebackCreatedEvent] + ReceivedPaymentMarkedForReturnEvent, RewardSentEvent, RewardRejectedEvent, ChargebackCreatedEvent, + StatementCreatedEvent] def events_mapper(_id, _type, attributes, relationships): From 8665d4f64bb592c25363dc81cba541e61e8cf961 Mon Sep 17 00:00:00 2001 From: axshani Date: Wed, 3 Apr 2024 13:58:17 +0300 Subject: [PATCH 7/8] Payments Events - update --- unit/models/event.py | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/unit/models/event.py b/unit/models/event.py index 5a9c735e..1daf79ef 100644 --- a/unit/models/event.py +++ b/unit/models/event.py @@ -144,12 +144,36 @@ def from_json_api(_id, _type, attributes, relationships): return PaymentSentEvent(_id, _type, attributes, relationships) +class PaymentCreatedEvent(BaseEvent): + @staticmethod + def from_json_api(_id, _type, attributes, relationships): + return PaymentCreatedEvent(_id, _type, attributes, relationships) + + class PaymentReturnedEvent(BaseEvent): @staticmethod def from_json_api(_id, _type, attributes, relationships): return PaymentReturnedEvent(_id, _type, attributes, relationships) +class PaymentRejectedEvent(BaseEvent): + @staticmethod + def from_json_api(_id, _type, attributes, relationships): + return PaymentRejectedEvent(_id, _type, attributes, relationships) + + +class PaymentCanceledEvent(BaseEvent): + @staticmethod + def from_json_api(_id, _type, attributes, relationships): + return PaymentCanceledEvent(_id, _type, attributes, relationships) + + +class PaymentPendingReviewEvent(BaseEvent): + @staticmethod + def from_json_api(_id, _type, attributes, relationships): + return PaymentPendingReviewEvent(_id, _type, attributes, relationships) + + class StatementsCreatedEvent(BaseEvent): @staticmethod def from_json_api(_id, _type, attributes, relationships): @@ -390,7 +414,8 @@ def from_json_api(_id, _type, attributes, relationships): ReceivedPaymentCreatedEvent, ReceivedPaymentReturnedEvent, ReceivedPaymentCompletedEvent, ReceivedPaymentAdvancedEvent, ReceivedPaymentPendingEvent, ReceivedPaymentPendingReviewEvent, ReceivedPaymentMarkedForReturnEvent, RewardSentEvent, RewardRejectedEvent, ChargebackCreatedEvent, - StatementCreatedEvent] + StatementCreatedEvent, PaymentCreatedEvent, PaymentCanceledEvent, PaymentPendingReviewEvent, + PaymentRejectedEvent] def events_mapper(_id, _type, attributes, relationships): From 099797f227381e3ed23f8ec0cdd782f292daee57 Mon Sep 17 00:00:00 2001 From: axshani Date: Wed, 3 Apr 2024 14:12:44 +0300 Subject: [PATCH 8/8] Customer - New Events --- unit/models/event.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/unit/models/event.py b/unit/models/event.py index 1daf79ef..70c1de14 100644 --- a/unit/models/event.py +++ b/unit/models/event.py @@ -120,6 +120,18 @@ def from_json_api(_id, _type, attributes, relationships): return CustomerCreatedEvent(_id, _type, attributes, relationships) +class CustomerUpdatedEvent(BaseEvent): + @staticmethod + def from_json_api(_id, _type, attributes, relationships): + return CustomerUpdatedEvent(_id, _type, attributes, relationships) + + +class CustomerArchivedEvent(BaseEvent): + @staticmethod + def from_json_api(_id, _type, attributes, relationships): + return CustomerArchivedEvent(_id, _type, attributes, relationships) + + class DocumentApprovedEvent(BaseEvent): @staticmethod def from_json_api(_id, _type, attributes, relationships): @@ -415,7 +427,7 @@ def from_json_api(_id, _type, attributes, relationships): ReceivedPaymentAdvancedEvent, ReceivedPaymentPendingEvent, ReceivedPaymentPendingReviewEvent, ReceivedPaymentMarkedForReturnEvent, RewardSentEvent, RewardRejectedEvent, ChargebackCreatedEvent, StatementCreatedEvent, PaymentCreatedEvent, PaymentCanceledEvent, PaymentPendingReviewEvent, - PaymentRejectedEvent] + PaymentRejectedEvent, CustomerUpdatedEvent, CustomerArchivedEvent] def events_mapper(_id, _type, attributes, relationships):