diff --git a/paddle_billing/Entities/Simulation.py b/paddle_billing/Entities/Simulation.py index a22e0f2..ce9da0d 100644 --- a/paddle_billing/Entities/Simulation.py +++ b/paddle_billing/Entities/Simulation.py @@ -7,7 +7,7 @@ from paddle_billing.Entities.Events import EventTypeName from paddle_billing.Entities.Simulations import SimulationScenarioType, SimulationStatus -from paddle_billing.Notifications.Entities.Entity import Entity as NotificationEntity +from paddle_billing.Notifications.Entities.Simulations.SimulationEntity import SimulationEntity from paddle_billing.Notifications.Entities.UndefinedEntity import UndefinedEntity @@ -18,7 +18,7 @@ class Simulation(Entity, ABC): notification_setting_id: str name: str type: EventTypeName | SimulationScenarioType - payload: NotificationEntity | UndefinedEntity | None + payload: SimulationEntity | UndefinedEntity | None last_run_at: datetime | None created_at: datetime updated_at: datetime @@ -36,7 +36,7 @@ def from_dict(data: dict) -> Simulation: name=data["name"], type=type, payload=( - NotificationEntity.from_dict_for_event_type(data["payload"], type.value) + SimulationEntity.from_dict_for_event_type(data["payload"], type.value) if isinstance(type, EventTypeName) and data.get("payload") else None ), diff --git a/paddle_billing/Notifications/Entities/Entity.py b/paddle_billing/Notifications/Entities/Entity.py index d89134d..d591c9d 100644 --- a/paddle_billing/Notifications/Entities/Entity.py +++ b/paddle_billing/Notifications/Entities/Entity.py @@ -36,7 +36,7 @@ def from_dict_for_event_type(data: dict, event_type: str) -> Entity | UndefinedE return UndefinedEntity(data) if not issubclass(entity_class, Entity): - raise ValueError(f"Event type '{entity_class_name}' is not of NotificationEntity") + raise ValueError(f"Event type '{entity_class_name}' is not of Entity") return instantiated_class diff --git a/paddle_billing/Notifications/Entities/Simulations/Address.py b/paddle_billing/Notifications/Entities/Simulations/Address.py new file mode 100644 index 0000000..8dff5ee --- /dev/null +++ b/paddle_billing/Notifications/Entities/Simulations/Address.py @@ -0,0 +1,52 @@ +from __future__ import annotations +from dataclasses import dataclass +from datetime import datetime + +from paddle_billing.Undefined import Undefined +from paddle_billing.Notifications.Entities.Shared import CountryCode, CustomData, ImportMeta, Status +from paddle_billing.Notifications.Entities.Simulations.SimulationEntity import SimulationEntity + + +@dataclass +class Address(SimulationEntity): + id: str | Undefined = Undefined() + description: str | None | Undefined = Undefined() + first_line: str | None | Undefined = Undefined() + second_line: str | None | Undefined = Undefined() + city: str | None | Undefined = Undefined() + postal_code: str | None | Undefined = Undefined() + region: str | None | Undefined = Undefined() + country_code: CountryCode | Undefined = Undefined() + status: Status | Undefined = Undefined() + created_at: datetime | Undefined = Undefined() + updated_at: datetime | Undefined = Undefined() + custom_data: CustomData | None | Undefined = Undefined() + import_meta: ImportMeta | None | Undefined = Undefined() + customer_id: str | None | Undefined = Undefined() + + @staticmethod + def from_dict(data: dict) -> Address: + return Address( + id=data.get("id", Undefined()), + customer_id=data.get("customer_id", Undefined()), + description=data.get("description", Undefined()), + first_line=data.get("first_line", Undefined()), + second_line=data.get("second_line", Undefined()), + city=data.get("city", Undefined()), + postal_code=data.get("postal_code", Undefined()), + region=data.get("region", Undefined()), + country_code=CountryCode(data["country_code"]) if data.get("country_code") else Undefined(), + status=Status(data["status"]) if data.get("status") else Undefined(), + created_at=datetime.fromisoformat(data["created_at"]) if data.get("created_at") else Undefined(), + updated_at=datetime.fromisoformat(data["updated_at"]) if data.get("updated_at") else Undefined(), + custom_data=( + CustomData(data["custom_data"]) + if isinstance(data.get("custom_data"), dict) + else data.get("custom_data", Undefined()) + ), + import_meta=( + ImportMeta.from_dict(data["import_meta"]) + if isinstance(data.get("import_meta"), dict) + else data.get("import_meta", Undefined()) + ), + ) diff --git a/paddle_billing/Notifications/Entities/Simulations/Adjustment.py b/paddle_billing/Notifications/Entities/Simulations/Adjustment.py new file mode 100644 index 0000000..42272c9 --- /dev/null +++ b/paddle_billing/Notifications/Entities/Simulations/Adjustment.py @@ -0,0 +1,65 @@ +from __future__ import annotations +from dataclasses import dataclass +from datetime import datetime + +from paddle_billing.Undefined import Undefined +from paddle_billing.Notifications.Entities.Adjustments import AdjustmentItem, AdjustmentTaxRatesUsed +from paddle_billing.Notifications.Entities.Shared import ( + Action, + AdjustmentStatus, + CurrencyCode, + PayoutTotalsAdjustment, + AdjustmentTotals, +) +from paddle_billing.Notifications.Entities.Simulations.SimulationEntity import SimulationEntity + + +@dataclass +class Adjustment(SimulationEntity): + id: str | Undefined = Undefined() + action: Action | Undefined = Undefined() + transaction_id: str | Undefined = Undefined() + subscription_id: str | None | Undefined = Undefined() + customer_id: str | Undefined = Undefined() + reason: str | Undefined = Undefined() + credit_applied_to_balance: bool | None | Undefined = Undefined() + currency_code: CurrencyCode | Undefined = Undefined() + status: AdjustmentStatus | Undefined = Undefined() + items: list[AdjustmentItem] | Undefined = Undefined() + totals: AdjustmentTotals | Undefined = Undefined() + payout_totals: PayoutTotalsAdjustment | None | Undefined = Undefined() + created_at: datetime | Undefined = Undefined() + updated_at: datetime | None | Undefined = Undefined() + tax_rates_used: list[AdjustmentTaxRatesUsed] | None | Undefined = Undefined() + + @staticmethod + def from_dict(data: dict) -> Adjustment: + return Adjustment( + id=data.get("id", Undefined()), + action=Action(data["action"]) if data.get("action") else Undefined(), + transaction_id=data.get("transaction_id", Undefined()), + subscription_id=data.get("subscription_id", Undefined()), + customer_id=data.get("customer_id", Undefined()), + reason=data.get("reason", Undefined()), + credit_applied_to_balance=data.get("credit_applied_to_balance", Undefined()), + currency_code=CurrencyCode(data["currency_code"]) if data.get("currency_code") else Undefined(), + status=AdjustmentStatus(data["status"]) if data.get("status") else Undefined(), + totals=AdjustmentTotals.from_dict(data["totals"]) if data.get("totals") else Undefined(), + created_at=datetime.fromisoformat(data["created_at"]) if data.get("created_at") else Undefined(), + items=[AdjustmentItem.from_dict(item) for item in data["items"]] if data.get("items") else Undefined(), + payout_totals=( + PayoutTotalsAdjustment.from_dict(data["payout_totals"]) + if data.get("payout_totals") + else data.get("payout_totals", Undefined()) + ), + updated_at=( + datetime.fromisoformat(data["updated_at"]) + if data.get("updated_at") + else data.get("updated_at", Undefined()) + ), + tax_rates_used=( + [AdjustmentTaxRatesUsed.from_dict(item) for item in data["tax_rates_used"]] + if data.get("tax_rates_used") + else data.get("tax_rates_used", Undefined()) + ), + ) diff --git a/paddle_billing/Notifications/Entities/Simulations/Business.py b/paddle_billing/Notifications/Entities/Simulations/Business.py new file mode 100644 index 0000000..55d48ba --- /dev/null +++ b/paddle_billing/Notifications/Entities/Simulations/Business.py @@ -0,0 +1,51 @@ +from __future__ import annotations +from dataclasses import dataclass +from datetime import datetime + +from paddle_billing.Undefined import Undefined +from paddle_billing.Notifications.Entities.Businesses import BusinessesContacts +from paddle_billing.Notifications.Entities.Shared import CustomData, ImportMeta, Status +from paddle_billing.Notifications.Entities.Simulations.SimulationEntity import SimulationEntity + + +@dataclass +class Business(SimulationEntity): + id: str | Undefined = Undefined() + name: str | Undefined = Undefined() + company_number: str | None | Undefined = Undefined() + tax_identifier: str | None | Undefined = Undefined() + status: Status | Undefined = Undefined() + contacts: list[BusinessesContacts] | Undefined = Undefined() + created_at: datetime | Undefined = Undefined() + updated_at: datetime | Undefined = Undefined() + custom_data: CustomData | None | Undefined = Undefined() + import_meta: ImportMeta | None | Undefined = Undefined() + customer_id: str | None | Undefined = Undefined() + + @staticmethod + def from_dict(data: dict) -> Business: + return Business( + id=data.get("id", Undefined()), + customer_id=data.get("customer_id", Undefined()), + name=data.get("name", Undefined()), + company_number=data.get("company_number", Undefined()), + tax_identifier=data.get("tax_identifier", Undefined()), + status=Status(data["status"]) if data.get("status") else Undefined(), + created_at=datetime.fromisoformat(data["created_at"]) if data.get("created_at") else Undefined(), + updated_at=datetime.fromisoformat(data["updated_at"]) if data.get("updated_at") else Undefined(), + contacts=( + [BusinessesContacts.from_dict(contact) for contact in data["contacts"]] + if data.get("contacts") + else Undefined() + ), + custom_data=( + CustomData(data["custom_data"]) + if isinstance(data.get("custom_data"), dict) + else data.get("custom_data", Undefined()) + ), + import_meta=( + ImportMeta.from_dict(data["import_meta"]) + if isinstance(data.get("import_meta"), dict) + else data.get("import_meta", Undefined()) + ), + ) diff --git a/paddle_billing/Notifications/Entities/Simulations/Customer.py b/paddle_billing/Notifications/Entities/Simulations/Customer.py new file mode 100644 index 0000000..2aae2c4 --- /dev/null +++ b/paddle_billing/Notifications/Entities/Simulations/Customer.py @@ -0,0 +1,44 @@ +from __future__ import annotations +from dataclasses import dataclass +from datetime import datetime + +from paddle_billing.Undefined import Undefined +from paddle_billing.Notifications.Entities.Shared import CustomData, ImportMeta, Status +from paddle_billing.Notifications.Entities.Simulations.SimulationEntity import SimulationEntity + + +@dataclass +class Customer(SimulationEntity): + id: str | Undefined = Undefined() + name: str | None | Undefined = Undefined() + email: str | Undefined = Undefined() + marketing_consent: bool | Undefined = Undefined() + status: Status | Undefined = Undefined() + locale: str | Undefined = Undefined() + created_at: datetime | Undefined = Undefined() + updated_at: datetime | Undefined = Undefined() + custom_data: CustomData | None | Undefined = Undefined() + import_meta: ImportMeta | None | Undefined = Undefined() + + @staticmethod + def from_dict(data: dict) -> Customer: + return Customer( + id=data.get("id", Undefined()), + name=data.get("name", Undefined()), + email=data.get("email", Undefined()), + marketing_consent=data.get("marketing_consent", Undefined()), + status=Status(data["status"]) if data.get("status") else Undefined(), + locale=data.get("locale", Undefined()), + created_at=datetime.fromisoformat(data["created_at"]) if data.get("created_at") else Undefined(), + updated_at=datetime.fromisoformat(data["updated_at"]) if data.get("updated_at") else Undefined(), + custom_data=( + CustomData(data["custom_data"]) + if isinstance(data.get("custom_data"), dict) + else data.get("custom_data", Undefined()) + ), + import_meta=( + ImportMeta.from_dict(data["import_meta"]) + if isinstance(data.get("import_meta"), dict) + else data.get("import_meta", Undefined()) + ), + ) diff --git a/paddle_billing/Notifications/Entities/Simulations/Discount.py b/paddle_billing/Notifications/Entities/Simulations/Discount.py new file mode 100644 index 0000000..1e2ad52 --- /dev/null +++ b/paddle_billing/Notifications/Entities/Simulations/Discount.py @@ -0,0 +1,67 @@ +from __future__ import annotations +from dataclasses import dataclass +from datetime import datetime + +from paddle_billing.Undefined import Undefined +from paddle_billing.Notifications.Entities.Discounts import DiscountStatus, DiscountType +from paddle_billing.Notifications.Entities.Shared import CurrencyCode, CustomData, ImportMeta +from paddle_billing.Notifications.Entities.Simulations.SimulationEntity import SimulationEntity + + +@dataclass +class Discount(SimulationEntity): + amount: str | Undefined = Undefined() + created_at: datetime | Undefined = Undefined() + description: str | Undefined = Undefined() + enabled_for_checkout: bool | Undefined = Undefined() + id: str | Undefined = Undefined() + recur: bool | Undefined = Undefined() + status: DiscountStatus | Undefined = Undefined() + type: DiscountType | Undefined = Undefined() + updated_at: datetime | Undefined = Undefined() + code: str | None | Undefined = Undefined() + currency_code: CurrencyCode | None | Undefined = Undefined() + custom_data: CustomData | None | Undefined = Undefined() + expires_at: datetime | None | Undefined = Undefined() + import_meta: ImportMeta | None | Undefined = Undefined() + maximum_recurring_intervals: int | None | Undefined = Undefined() + restrict_to: list | None | Undefined = Undefined() + usage_limit: int | None | Undefined = Undefined() + + @staticmethod + def from_dict(data: dict) -> Discount: + return Discount( + amount=data.get("amount", Undefined()), + code=data.get("code", Undefined()), + created_at=datetime.fromisoformat(data["created_at"]) if data.get("created_at") else Undefined(), + description=data.get("description", Undefined()), + enabled_for_checkout=data.get("enabled_for_checkout", Undefined()), + id=data.get("id", Undefined()), + maximum_recurring_intervals=data.get("maximum_recurring_intervals", Undefined()), + usage_limit=data.get("usage_limit", Undefined()), + recur=data.get("recur", Undefined()), + restrict_to=data.get("restrict_to", Undefined()), + status=DiscountStatus(data["status"]) if data.get("status") else Undefined(), + type=DiscountType(data["type"]) if data.get("type") else Undefined(), + updated_at=datetime.fromisoformat(data["updated_at"]) if data.get("updated_at") else Undefined(), + currency_code=( + CurrencyCode(data["currency_code"]) + if data.get("currency_code") + else data.get("currency_code", Undefined()) + ), + custom_data=( + CustomData(data["custom_data"]) + if isinstance(data.get("custom_data"), dict) + else data.get("custom_data", Undefined()) + ), + expires_at=( + datetime.fromisoformat(data["expires_at"]) + if data.get("expires_at") + else data.get("expires_at", Undefined()) + ), + import_meta=( + ImportMeta.from_dict(data["import_meta"]) + if isinstance(data.get("import_meta"), dict) + else data.get("import_meta", Undefined()) + ), + ) diff --git a/paddle_billing/Notifications/Entities/Simulations/PaymentMethod.py b/paddle_billing/Notifications/Entities/Simulations/PaymentMethod.py new file mode 100644 index 0000000..7561ae3 --- /dev/null +++ b/paddle_billing/Notifications/Entities/Simulations/PaymentMethod.py @@ -0,0 +1,33 @@ +from __future__ import annotations +from dataclasses import dataclass +from datetime import datetime + +from paddle_billing.Undefined import Undefined +from paddle_billing.Notifications.Entities.Shared import ( + SavedPaymentMethodOrigin, + SavedPaymentMethodType, +) +from paddle_billing.Notifications.Entities.Simulations.SimulationEntity import SimulationEntity + + +@dataclass +class PaymentMethod(SimulationEntity): + id: str | Undefined = Undefined() + customer_id: str | Undefined = Undefined() + address_id: str | Undefined = Undefined() + type: SavedPaymentMethodType | Undefined = Undefined() + origin: SavedPaymentMethodOrigin | Undefined = Undefined() + saved_at: datetime | Undefined = Undefined() + updated_at: datetime | Undefined = Undefined() + + @staticmethod + def from_dict(data: dict) -> PaymentMethod: + return PaymentMethod( + id=data.get("id", Undefined()), + customer_id=data.get("customer_id", Undefined()), + address_id=data.get("address_id", Undefined()), + type=SavedPaymentMethodType(data["type"]) if data.get("type") else Undefined(), + origin=SavedPaymentMethodOrigin(data["origin"]) if data.get("origin") else Undefined(), + saved_at=datetime.fromisoformat(data["saved_at"]) if data.get("saved_at") else Undefined(), + updated_at=datetime.fromisoformat(data["updated_at"]) if data.get("updated_at") else Undefined(), + ) diff --git a/paddle_billing/Notifications/Entities/Simulations/PaymentMethodDeleted.py b/paddle_billing/Notifications/Entities/Simulations/PaymentMethodDeleted.py new file mode 100644 index 0000000..be37bf9 --- /dev/null +++ b/paddle_billing/Notifications/Entities/Simulations/PaymentMethodDeleted.py @@ -0,0 +1,40 @@ +from __future__ import annotations +from dataclasses import dataclass +from datetime import datetime + +from paddle_billing.Undefined import Undefined +from paddle_billing.Notifications.Entities.Shared import ( + SavedPaymentMethodDeletionReason, + SavedPaymentMethodOrigin, + SavedPaymentMethodType, +) +from paddle_billing.Notifications.Entities.Simulations.SimulationEntity import SimulationEntity + + +@dataclass +class PaymentMethodDeleted(SimulationEntity): + id: str | Undefined = Undefined() + customer_id: str | Undefined = Undefined() + address_id: str | Undefined = Undefined() + type: SavedPaymentMethodType | Undefined = Undefined() + origin: SavedPaymentMethodOrigin | Undefined = Undefined() + saved_at: datetime | Undefined = Undefined() + updated_at: datetime | Undefined = Undefined() + deletion_reason: SavedPaymentMethodDeletionReason | Undefined = Undefined() + + @staticmethod + def from_dict(data: dict) -> PaymentMethodDeleted: + return PaymentMethodDeleted( + id=data.get("id", Undefined()), + customer_id=data.get("customer_id", Undefined()), + address_id=data.get("address_id", Undefined()), + type=SavedPaymentMethodType(data["type"]) if data.get("type") else Undefined(), + origin=SavedPaymentMethodOrigin(data["origin"]) if data.get("origin") else Undefined(), + saved_at=datetime.fromisoformat(data["saved_at"]) if data.get("saved_at") else Undefined(), + updated_at=datetime.fromisoformat(data["updated_at"]) if data.get("updated_at") else Undefined(), + deletion_reason=( + SavedPaymentMethodDeletionReason(data["deletion_reason"]) + if data.get("deletion_reason") + else Undefined() + ), + ) diff --git a/paddle_billing/Notifications/Entities/Simulations/Payout.py b/paddle_billing/Notifications/Entities/Simulations/Payout.py new file mode 100644 index 0000000..7ade3c2 --- /dev/null +++ b/paddle_billing/Notifications/Entities/Simulations/Payout.py @@ -0,0 +1,24 @@ +from __future__ import annotations +from dataclasses import dataclass + +from paddle_billing.Undefined import Undefined +from paddle_billing.Notifications.Entities.Payouts import PayoutStatus +from paddle_billing.Notifications.Entities.Shared import CurrencyCodePayouts +from paddle_billing.Notifications.Entities.Simulations.SimulationEntity import SimulationEntity + + +@dataclass +class Payout(SimulationEntity): + amount: str | Undefined = Undefined() + currency_code: CurrencyCodePayouts | Undefined = Undefined() + id: str | Undefined = Undefined() + status: PayoutStatus | Undefined = Undefined() + + @staticmethod + def from_dict(data: dict) -> Payout: + return Payout( + amount=data.get("amount", Undefined()), + id=data.get("id", Undefined()), + status=PayoutStatus(data["status"]) if data.get("status") else Undefined(), + currency_code=CurrencyCodePayouts(data["currency_code"]) if data.get("currency_code") else Undefined(), + ) diff --git a/paddle_billing/Notifications/Entities/Simulations/Price.py b/paddle_billing/Notifications/Entities/Simulations/Price.py new file mode 100644 index 0000000..6d94bbe --- /dev/null +++ b/paddle_billing/Notifications/Entities/Simulations/Price.py @@ -0,0 +1,86 @@ +from __future__ import annotations +from dataclasses import dataclass +from datetime import datetime + +from paddle_billing.Undefined import Undefined +from paddle_billing.Notifications.Entities.Shared import ( + CatalogType, + CustomData, + Duration, + ImportMeta, + Money, + PriceQuantity, + Status, + TaxMode, + UnitPriceOverride, +) +from paddle_billing.Notifications.Entities.Simulations.SimulationEntity import SimulationEntity + + +@dataclass +class Price(SimulationEntity): + id: str | Undefined = Undefined() + product_id: str | Undefined = Undefined() + name: str | None | Undefined = Undefined() + description: str | Undefined = Undefined() + type: CatalogType | None | Undefined = Undefined() + billing_cycle: Duration | None | Undefined = Undefined() + trial_period: Duration | None | Undefined = Undefined() + tax_mode: TaxMode | Undefined = Undefined() + unit_price: Money | Undefined = Undefined() + unit_price_overrides: list[UnitPriceOverride] | Undefined = Undefined() + quantity: PriceQuantity | Undefined = Undefined() + status: Status | Undefined = Undefined() + custom_data: CustomData | None | Undefined = Undefined() + import_meta: ImportMeta | None | Undefined = Undefined() + created_at: datetime | None | Undefined = Undefined() + updated_at: datetime | None | Undefined = Undefined() + + @classmethod + def from_dict(cls, data: dict) -> Price: + return Price( + id=data.get("id", Undefined()), + product_id=data.get("product_id", Undefined()), + name=data.get("name", Undefined()), + description=data.get("description", Undefined()), + unit_price=Money.from_dict(data["unit_price"]) if data.get("unit_price") else Undefined(), + quantity=PriceQuantity.from_dict(data["quantity"]) if data.get("quantity") else Undefined(), + status=Status(data["status"]) if data.get("status") else Undefined(), + tax_mode=TaxMode(data.get("tax_mode")) if data.get("tax_mode") else Undefined(), + unit_price_overrides=( + [UnitPriceOverride.from_dict(override) for override in data.get("unit_price_overrides", [])] + if isinstance(data.get("unit_price_overrides"), list) + else Undefined() + ), + type=CatalogType(data.get("type")) if data.get("type") else data.get("type", Undefined()), + billing_cycle=( + Duration.from_dict(data["billing_cycle"]) + if data.get("billing_cycle") + else data.get("billing_cycle", Undefined()) + ), + trial_period=( + Duration.from_dict(data["trial_period"]) + if data.get("trial_period") + else data.get("trial_period", Undefined()) + ), + custom_data=( + CustomData(data["custom_data"]) + if isinstance(data.get("custom_data"), dict) + else data.get("custom_data", Undefined()) + ), + import_meta=( + ImportMeta.from_dict(data["import_meta"]) + if isinstance(data.get("import_meta"), dict) + else data.get("import_meta", Undefined()) + ), + created_at=( + datetime.fromisoformat(data["created_at"]) + if data.get("created_at") + else data.get("created_at", Undefined()) + ), + updated_at=( + datetime.fromisoformat(data["updated_at"]) + if data.get("updated_at") + else data.get("updated_at", Undefined()) + ), + ) diff --git a/paddle_billing/Notifications/Entities/Simulations/Product.py b/paddle_billing/Notifications/Entities/Simulations/Product.py new file mode 100644 index 0000000..d731cb0 --- /dev/null +++ b/paddle_billing/Notifications/Entities/Simulations/Product.py @@ -0,0 +1,54 @@ +from __future__ import annotations +from dataclasses import dataclass +from datetime import datetime + +from paddle_billing.Undefined import Undefined +from paddle_billing.Notifications.Entities.Shared import CatalogType, CustomData, ImportMeta, Status, TaxCategory +from paddle_billing.Notifications.Entities.Simulations.SimulationEntity import SimulationEntity + + +@dataclass +class Product(SimulationEntity): + id: str | Undefined = Undefined() + name: str | Undefined = Undefined() + status: Status | Undefined = Undefined() + tax_category: TaxCategory | Undefined = Undefined() + description: str | None | Undefined = Undefined() + image_url: str | None | Undefined = Undefined() + custom_data: CustomData | None | Undefined = Undefined() + import_meta: ImportMeta | None | Undefined = Undefined() + type: CatalogType | None | Undefined = Undefined() + created_at: datetime | None | Undefined = Undefined() + updated_at: datetime | None | Undefined = Undefined() + + @staticmethod + def from_dict(data: dict) -> Product: + return Product( + description=data.get("description", Undefined()), + id=data.get("id", Undefined()), + image_url=data.get("image_url", Undefined()), + name=data.get("name", Undefined()), + status=Status(data["status"]) if data.get("status") else Undefined(), + tax_category=TaxCategory(data["tax_category"]) if data.get("tax_category") else Undefined(), + type=CatalogType(data["type"]) if data.get("type") else data.get("type", Undefined()), + custom_data=( + CustomData(data["custom_data"]) + if isinstance(data.get("custom_data"), dict) + else data.get("custom_data", Undefined()) + ), + import_meta=( + ImportMeta.from_dict(data["import_meta"]) + if isinstance(data.get("import_meta"), dict) + else data.get("import_meta", Undefined()) + ), + created_at=( + datetime.fromisoformat(data["created_at"]) + if data.get("created_at") + else data.get("created_at", Undefined()) + ), + updated_at=( + datetime.fromisoformat(data["updated_at"]) + if data.get("updated_at") + else data.get("updated_at", Undefined()) + ), + ) diff --git a/paddle_billing/Notifications/Entities/Simulations/Report.py b/paddle_billing/Notifications/Entities/Simulations/Report.py new file mode 100644 index 0000000..571662f --- /dev/null +++ b/paddle_billing/Notifications/Entities/Simulations/Report.py @@ -0,0 +1,48 @@ +from __future__ import annotations +from dataclasses import dataclass +from datetime import datetime + +from paddle_billing.Undefined import Undefined +from paddle_billing.Notifications.Entities.Reports import ReportFilter, ReportStatus, ReportType +from paddle_billing.Notifications.Entities.Simulations.SimulationEntity import SimulationEntity + + +@dataclass +class Report(SimulationEntity): + id: str | Undefined = Undefined() + status: ReportStatus | Undefined = Undefined() + rows: int | None | Undefined = Undefined() + type: ReportType | Undefined = Undefined() + filters: list[ReportFilter] | Undefined = Undefined() + expires_at: datetime | None | Undefined = Undefined() + created_at: datetime | Undefined = Undefined() + updated_at: datetime | Undefined = Undefined() + + @staticmethod + def from_dict(data: dict) -> Report: + return Report( + id=data.get("id", Undefined()), + status=ReportStatus(data["status"]) if data.get("status") else Undefined(), + rows=data.get("rows", Undefined()), + type=ReportType(data["type"]) if data.get("type") else Undefined(), + filters=( + [ReportFilter.from_dict(a_filter) for a_filter in data.get("filters", [])] + if data.get("filters") is not None + else data.get("filters", Undefined()) + ), + expires_at=( + datetime.fromisoformat(data["expires_at"]) + if data.get("expires_at") + else data.get("expires_at", Undefined()) + ), + created_at=( + datetime.fromisoformat(data["created_at"]) + if data.get("created_at") + else data.get("created_at", Undefined()) + ), + updated_at=( + datetime.fromisoformat(data["updated_at"]) + if data.get("updated_at") + else data.get("updated_at", Undefined()) + ), + ) diff --git a/paddle_billing/Notifications/Entities/Simulations/SimulationEntity.py b/paddle_billing/Notifications/Entities/Simulations/SimulationEntity.py new file mode 100644 index 0000000..eee6117 --- /dev/null +++ b/paddle_billing/Notifications/Entities/Simulations/SimulationEntity.py @@ -0,0 +1,43 @@ +from __future__ import annotations +from dataclasses import dataclass +from abc import ABC +from paddle_billing.Notifications.Entities.UndefinedEntity import UndefinedEntity +from importlib import import_module + + +@dataclass +class SimulationEntity(ABC): + @staticmethod + def from_dict_for_event_type(data: dict, event_type: str) -> SimulationEntity | UndefinedEntity: + entity_class_name = SimulationEntity._resolve_event_class_name(event_type) + + entity_class = None + instantiated_class = None + entity_module_path = "paddle_billing.Notifications.Entities.Simulations" + + try: + imported_module = import_module(f"{entity_module_path}.{entity_class_name}") + entity_class = getattr(imported_module, entity_class_name) + + instantiated_class = entity_class.from_dict(data) + except Exception as error: + print(f"Error dynamically instantiating a '{entity_module_path}.{entity_class_name}' object: {error}") + + if not instantiated_class: + return UndefinedEntity(data) + + if not issubclass(entity_class, SimulationEntity): + raise ValueError(f"Event type '{entity_class_name}' is not of SimulationEntity") + + return instantiated_class + + @staticmethod + def _resolve_event_class_name(event_type) -> str: + if event_type == "subscription.created": + return "SubscriptionCreated" + if event_type == "payment_method.deleted": + return "PaymentMethodDeleted" + + event_entity = event_type.split(".")[0] or "" + + return event_entity.lower().title().replace("_", "") diff --git a/paddle_billing/Notifications/Entities/Simulations/Subscription.py b/paddle_billing/Notifications/Entities/Simulations/Subscription.py new file mode 100644 index 0000000..dc7ce56 --- /dev/null +++ b/paddle_billing/Notifications/Entities/Simulations/Subscription.py @@ -0,0 +1,124 @@ +from __future__ import annotations +from dataclasses import dataclass +from datetime import datetime + +from paddle_billing.Undefined import Undefined +from paddle_billing.Notifications.Entities.Shared import ( + BillingDetails, + CollectionMode, + CurrencyCode, + CustomData, + Duration, + ImportMeta, + TimePeriod, +) +from paddle_billing.Notifications.Entities.Subscriptions import ( + SubscriptionDiscount, + SubscriptionItem, + SubscriptionScheduledChange, + SubscriptionStatus, +) +from paddle_billing.Notifications.Entities.Simulations.SimulationEntity import SimulationEntity + + +@dataclass +class Subscription(SimulationEntity): + address_id: str | Undefined = Undefined() + billing_cycle: Duration | Undefined = Undefined() + collection_mode: CollectionMode | Undefined = Undefined() + created_at: datetime | Undefined = Undefined() + currency_code: CurrencyCode | Undefined = Undefined() + customer_id: str | Undefined = Undefined() + id: str | Undefined = Undefined() + items: list[SubscriptionItem] | Undefined = Undefined() + status: SubscriptionStatus | Undefined = Undefined() + updated_at: datetime | Undefined = Undefined() + billing_details: BillingDetails | None | Undefined = Undefined() + business_id: str | None | Undefined = Undefined() + canceled_at: datetime | None | Undefined = Undefined() + current_billing_period: TimePeriod | None | Undefined = Undefined() + custom_data: CustomData | None | Undefined = Undefined() + discount: SubscriptionDiscount | None | Undefined = Undefined() + import_meta: ImportMeta | None | Undefined = Undefined() + first_billed_at: datetime | None | Undefined = Undefined() + next_billed_at: datetime | None | Undefined = Undefined() + paused_at: datetime | None | Undefined = Undefined() + scheduled_change: SubscriptionScheduledChange | None | Undefined = Undefined() + started_at: datetime | None | Undefined = Undefined() + + @staticmethod + def from_dict(data: dict) -> Subscription: + return Subscription( + id=data.get("id", Undefined()), + status=SubscriptionStatus(data["status"]) if data.get("status") else Undefined(), + customer_id=data.get("customer_id", Undefined()), + address_id=data.get("address_id", Undefined()), + business_id=data.get("business_id", Undefined()), + currency_code=CurrencyCode(data["currency_code"]) if data.get("currency_code") else Undefined(), + created_at=datetime.fromisoformat(data["created_at"]) if data.get("created_at") else Undefined(), + updated_at=datetime.fromisoformat(data["updated_at"]) if data.get("updated_at") else Undefined(), + collection_mode=CollectionMode(data["collection_mode"]) if data.get("collection_mode") else Undefined(), + billing_cycle=Duration.from_dict(data["billing_cycle"]) if data.get("billing_cycle") else Undefined(), + items=( + [SubscriptionItem.from_dict(item) for item in data["items"]] + if isinstance(data.get("items"), list) + else Undefined() + ), + billing_details=( + BillingDetails.from_dict(data["billing_details"]) + if data.get("billing_details") + else data.get("billing_details", Undefined()) + ), + canceled_at=( + datetime.fromisoformat(data["canceled_at"]) + if data.get("canceled_at") + else data.get("canceled_at", Undefined()) + ), + custom_data=( + CustomData(data["custom_data"]) + if isinstance(data.get("custom_data"), dict) + else data.get("custom_data", Undefined()) + ), + discount=( + SubscriptionDiscount.from_dict(data["discount"]) + if data.get("discount") + else data.get("discount", Undefined()) + ), + first_billed_at=( + datetime.fromisoformat(data["first_billed_at"]) + if data.get("first_billed_at") + else data.get("first_billed_at", Undefined()) + ), + import_meta=( + ImportMeta.from_dict(data["import_meta"]) + if isinstance(data.get("import_meta"), dict) + else data.get("import_meta", Undefined()) + ), + next_billed_at=( + datetime.fromisoformat(data["next_billed_at"]) + if data.get("next_billed_at") + else data.get("next_billed_at", Undefined()) + ), + paused_at=( + datetime.fromisoformat(data["paused_at"]) + if data.get("paused_at") + else data.get("paused_at", Undefined()) + ), + started_at=( + datetime.fromisoformat(data["started_at"]) + if data.get("started_at") + else data.get("started_at", Undefined()) + ), + current_billing_period=( + ( + TimePeriod.from_dict(data["current_billing_period"]) + if data.get("current_billing_period") + else data.get("current_billing_period", Undefined()) + ) + ), + scheduled_change=( + SubscriptionScheduledChange.from_dict(data["scheduled_change"]) + if data.get("scheduled_change") + else data.get("scheduled_change", Undefined()) + ), + ) diff --git a/paddle_billing/Notifications/Entities/Simulations/SubscriptionCreated.py b/paddle_billing/Notifications/Entities/Simulations/SubscriptionCreated.py new file mode 100644 index 0000000..f6dac30 --- /dev/null +++ b/paddle_billing/Notifications/Entities/Simulations/SubscriptionCreated.py @@ -0,0 +1,126 @@ +from __future__ import annotations +from dataclasses import dataclass +from datetime import datetime + +from paddle_billing.Undefined import Undefined +from paddle_billing.Notifications.Entities.Shared import ( + BillingDetails, + CollectionMode, + CurrencyCode, + CustomData, + Duration, + ImportMeta, + TimePeriod, +) +from paddle_billing.Notifications.Entities.Subscriptions import ( + SubscriptionDiscount, + SubscriptionItem, + SubscriptionScheduledChange, + SubscriptionStatus, +) +from paddle_billing.Notifications.Entities.Simulations.SimulationEntity import SimulationEntity + + +@dataclass +class SubscriptionCreated(SimulationEntity): + address_id: str | Undefined = Undefined() + billing_cycle: Duration | Undefined = Undefined() + collection_mode: CollectionMode | Undefined = Undefined() + created_at: datetime | Undefined = Undefined() + currency_code: CurrencyCode | Undefined = Undefined() + customer_id: str | Undefined = Undefined() + id: str | Undefined = Undefined() + items: list[SubscriptionItem] | Undefined = Undefined() + status: SubscriptionStatus | Undefined = Undefined() + updated_at: datetime | Undefined = Undefined() + billing_details: BillingDetails | None | Undefined = Undefined() + business_id: str | None | Undefined = Undefined() + canceled_at: datetime | None | Undefined = Undefined() + current_billing_period: TimePeriod | None | Undefined = Undefined() + custom_data: CustomData | None | Undefined = Undefined() + discount: SubscriptionDiscount | None | Undefined = Undefined() + import_meta: ImportMeta | None | Undefined = Undefined() + first_billed_at: datetime | None | Undefined = Undefined() + next_billed_at: datetime | None | Undefined = Undefined() + paused_at: datetime | None | Undefined = Undefined() + scheduled_change: SubscriptionScheduledChange | None | Undefined = Undefined() + started_at: datetime | None | Undefined = Undefined() + transaction_id: str | None | Undefined = Undefined() + + @staticmethod + def from_dict(data: dict) -> SubscriptionCreated: + return SubscriptionCreated( + id=data.get("id", Undefined()), + transaction_id=data.get("transaction_id", Undefined()), + status=SubscriptionStatus(data["status"]) if data.get("status") else Undefined(), + customer_id=data.get("customer_id", Undefined()), + address_id=data.get("address_id", Undefined()), + business_id=data.get("business_id", Undefined()), + currency_code=CurrencyCode(data["currency_code"]) if data.get("currency_code") else Undefined(), + created_at=datetime.fromisoformat(data["created_at"]) if data.get("created_at") else Undefined(), + updated_at=datetime.fromisoformat(data["updated_at"]) if data.get("updated_at") else Undefined(), + collection_mode=CollectionMode(data["collection_mode"]) if data.get("collection_mode") else Undefined(), + billing_cycle=Duration.from_dict(data["billing_cycle"]) if data.get("billing_cycle") else Undefined(), + items=( + [SubscriptionItem.from_dict(item) for item in data["items"]] + if isinstance(data.get("items"), list) + else Undefined() + ), + billing_details=( + BillingDetails.from_dict(data["billing_details"]) + if data.get("billing_details") + else data.get("billing_details", Undefined()) + ), + canceled_at=( + datetime.fromisoformat(data["canceled_at"]) + if data.get("canceled_at") + else data.get("canceled_at", Undefined()) + ), + custom_data=( + CustomData(data["custom_data"]) + if isinstance(data.get("custom_data"), dict) + else data.get("custom_data", Undefined()) + ), + discount=( + SubscriptionDiscount.from_dict(data["discount"]) + if data.get("discount") + else data.get("discount", Undefined()) + ), + first_billed_at=( + datetime.fromisoformat(data["first_billed_at"]) + if data.get("first_billed_at") + else data.get("first_billed_at", Undefined()) + ), + import_meta=( + ImportMeta.from_dict(data["import_meta"]) + if isinstance(data.get("import_meta"), dict) + else data.get("import_meta", Undefined()) + ), + next_billed_at=( + datetime.fromisoformat(data["next_billed_at"]) + if data.get("next_billed_at") + else data.get("next_billed_at", Undefined()) + ), + paused_at=( + datetime.fromisoformat(data["paused_at"]) + if data.get("paused_at") + else data.get("paused_at", Undefined()) + ), + started_at=( + datetime.fromisoformat(data["started_at"]) + if data.get("started_at") + else data.get("started_at", Undefined()) + ), + current_billing_period=( + ( + TimePeriod.from_dict(data["current_billing_period"]) + if data.get("current_billing_period") + else data.get("current_billing_period", Undefined()) + ) + ), + scheduled_change=( + SubscriptionScheduledChange.from_dict(data["scheduled_change"]) + if data.get("scheduled_change") + else data.get("scheduled_change", Undefined()) + ), + ) diff --git a/paddle_billing/Notifications/Entities/Simulations/Transaction.py b/paddle_billing/Notifications/Entities/Simulations/Transaction.py new file mode 100644 index 0000000..63dca02 --- /dev/null +++ b/paddle_billing/Notifications/Entities/Simulations/Transaction.py @@ -0,0 +1,99 @@ +from __future__ import annotations +from dataclasses import dataclass +from datetime import datetime + +from paddle_billing.Undefined import Undefined +from paddle_billing.Notifications.Entities.Shared import ( + BillingDetails, + Checkout, + CollectionMode, + CurrencyCode, + CustomData, + TimePeriod, + TransactionOrigin, + TransactionPaymentAttempt, + TransactionStatus, +) + +from paddle_billing.Notifications.Entities.Transactions.TransactionDetails import TransactionDetails +from paddle_billing.Notifications.Entities.Transactions.TransactionItem import TransactionItem +from paddle_billing.Notifications.Entities.Simulations.SimulationEntity import SimulationEntity + + +@dataclass +class Transaction(SimulationEntity): + id: str | Undefined = Undefined() + status: TransactionStatus | Undefined = Undefined() + customer_id: str | None | Undefined = Undefined() + address_id: str | None | Undefined = Undefined() + business_id: str | None | Undefined = Undefined() + custom_data: CustomData | None | Undefined = Undefined() + currency_code: CurrencyCode | Undefined = Undefined() + origin: TransactionOrigin | Undefined = Undefined() + subscription_id: str | None | Undefined = Undefined() + invoice_id: str | None | Undefined = Undefined() + invoice_number: str | None | Undefined = Undefined() + collection_mode: CollectionMode | Undefined = Undefined() + discount_id: str | None | Undefined = Undefined() + billing_details: BillingDetails | None | Undefined = Undefined() + billing_period: TimePeriod | None | Undefined = Undefined() + items: list[TransactionItem] | Undefined = Undefined() + details: TransactionDetails | Undefined = Undefined() + payments: list[TransactionPaymentAttempt] | Undefined = Undefined() + checkout: Checkout | None | Undefined = Undefined() + created_at: datetime | Undefined = Undefined() + updated_at: datetime | Undefined = Undefined() + billed_at: datetime | None | Undefined = Undefined() + + @staticmethod + def from_dict(data: dict) -> Transaction: + return Transaction( + address_id=data.get("address_id", Undefined()), + business_id=data.get("business_id", Undefined()), + collection_mode=CollectionMode(data["collection_mode"]) if data.get("collection_mode") else Undefined(), + created_at=datetime.fromisoformat(data["created_at"]) if data.get("created_at") else Undefined(), + currency_code=CurrencyCode(data["currency_code"]) if data.get("currency_code") else Undefined(), + customer_id=data.get("customer_id", Undefined()), + details=TransactionDetails.from_dict(data["details"]) if data.get("details") else Undefined(), + discount_id=data.get("discount_id", Undefined()), + id=data.get("id", Undefined()), + invoice_id=data.get("invoice_id", Undefined()), + invoice_number=data.get("invoice_number", Undefined()), + origin=TransactionOrigin(data["origin"]) if data.get("origin") else Undefined(), + status=TransactionStatus(data["status"]) if data.get("status") else Undefined(), + subscription_id=data.get("subscription_id", Undefined()), + updated_at=datetime.fromisoformat(data["updated_at"]) if data.get("updated_at") else Undefined(), + items=( + [TransactionItem.from_dict(item) for item in data["items"]] + if isinstance(data.get("items"), list) + else Undefined() + ), + payments=( + [TransactionPaymentAttempt.from_dict(item) for item in data["payments"]] + if isinstance(data.get("payments"), list) + else Undefined() + ), + billed_at=( + datetime.fromisoformat(data["billed_at"]) + if data.get("billed_at") + else data.get("billed_at", Undefined()) + ), + billing_details=( + BillingDetails.from_dict(data["billing_details"]) + if data.get("billing_details") + else data.get("billing_details", Undefined()) + ), + billing_period=( + TimePeriod.from_dict(data["billing_period"]) + if data.get("billing_period") + else data.get("billing_period", Undefined()) + ), + custom_data=( + CustomData(data["custom_data"]) + if isinstance(data.get("custom_data"), dict) + else data.get("custom_data", Undefined()) + ), + checkout=( + Checkout.from_dict(data["checkout"]) if data.get("checkout") else data.get("checkout", Undefined()) + ), + ) diff --git a/paddle_billing/Notifications/Entities/Simulations/__init__.py b/paddle_billing/Notifications/Entities/Simulations/__init__.py new file mode 100644 index 0000000..d4a03f9 --- /dev/null +++ b/paddle_billing/Notifications/Entities/Simulations/__init__.py @@ -0,0 +1,14 @@ +from paddle_billing.Notifications.Entities.Simulations.Address import Address +from paddle_billing.Notifications.Entities.Simulations.Adjustment import Adjustment +from paddle_billing.Notifications.Entities.Simulations.Business import Business +from paddle_billing.Notifications.Entities.Simulations.Customer import Customer +from paddle_billing.Notifications.Entities.Simulations.Discount import Discount +from paddle_billing.Notifications.Entities.Simulations.PaymentMethod import PaymentMethod +from paddle_billing.Notifications.Entities.Simulations.PaymentMethodDeleted import PaymentMethodDeleted +from paddle_billing.Notifications.Entities.Simulations.Payout import Payout +from paddle_billing.Notifications.Entities.Simulations.Price import Price +from paddle_billing.Notifications.Entities.Simulations.Product import Product +from paddle_billing.Notifications.Entities.Simulations.Report import Report +from paddle_billing.Notifications.Entities.Simulations.Subscription import Subscription +from paddle_billing.Notifications.Entities.Simulations.SubscriptionCreated import SubscriptionCreated +from paddle_billing.Notifications.Entities.Simulations.Transaction import Transaction diff --git a/paddle_billing/Resources/Simulations/Operations/CreateSimulation.py b/paddle_billing/Resources/Simulations/Operations/CreateSimulation.py index f72503b..1cd28d1 100644 --- a/paddle_billing/Resources/Simulations/Operations/CreateSimulation.py +++ b/paddle_billing/Resources/Simulations/Operations/CreateSimulation.py @@ -6,7 +6,7 @@ from paddle_billing.Entities.Events import EventTypeName from paddle_billing.Entities.Simulations import SimulationScenarioType -from paddle_billing.Notifications.Entities.Entity import Entity as NotificationEntity +from paddle_billing.Notifications.Entities.Simulations.SimulationEntity import SimulationEntity @dataclass @@ -14,4 +14,4 @@ class CreateSimulation(Operation): notification_setting_id: str type: EventTypeName | SimulationScenarioType name: str - payload: NotificationEntity | None | Undefined = Undefined() + payload: SimulationEntity | None | Undefined = Undefined() diff --git a/paddle_billing/Resources/Simulations/Operations/UpdateSimulation.py b/paddle_billing/Resources/Simulations/Operations/UpdateSimulation.py index 0e9bcbd..7d7443a 100644 --- a/paddle_billing/Resources/Simulations/Operations/UpdateSimulation.py +++ b/paddle_billing/Resources/Simulations/Operations/UpdateSimulation.py @@ -6,7 +6,7 @@ from paddle_billing.Entities.Events import EventTypeName from paddle_billing.Entities.Simulations import SimulationScenarioType, SimulationStatus -from paddle_billing.Notifications.Entities.Entity import Entity as NotificationEntity +from paddle_billing.Notifications.Entities.Simulations.SimulationEntity import SimulationEntity @dataclass @@ -15,4 +15,4 @@ class UpdateSimulation(Operation): type: EventTypeName | SimulationScenarioType | Undefined = Undefined() name: str | Undefined = Undefined() status: SimulationStatus | Undefined = Undefined() - payload: NotificationEntity | Undefined = Undefined() + payload: SimulationEntity | Undefined = Undefined() diff --git a/tests/Functional/Resources/Simulations/_fixtures/request/create_full.json b/tests/Functional/Resources/Simulations/_fixtures/request/create_full.json index 6577e27..37a83e8 100644 --- a/tests/Functional/Resources/Simulations/_fixtures/request/create_full.json +++ b/tests/Functional/Resources/Simulations/_fixtures/request/create_full.json @@ -10,12 +10,17 @@ "created_at": "2024-04-12T06:42:58.785000Z", "first_line": "4050 Jefferson Plaza, 41st Floor", "updated_at": "2024-04-12T06:42:58.785000Z", - "custom_data": null, "customer_id": "ctm_01hv6y1jedq4p1n0yqn5ba3ky4", "description": "Head Office", - "import_meta": null, "postal_code": "10021", "second_line": null, - "country_code": "US" + "country_code": "US", + "custom_data": { + "some": "data" + }, + "import_meta": { + "external_id": "some-external-id", + "imported_from": "some-source" + } } -} \ No newline at end of file +} diff --git a/tests/Functional/Resources/Simulations/test_SimulationsClient.py b/tests/Functional/Resources/Simulations/test_SimulationsClient.py index df68a6b..a4b4edf 100644 --- a/tests/Functional/Resources/Simulations/test_SimulationsClient.py +++ b/tests/Functional/Resources/Simulations/test_SimulationsClient.py @@ -5,12 +5,14 @@ from paddle_billing.Entities.Collections import SimulationCollection from paddle_billing.Entities.Simulation import Simulation, SimulationScenarioType, SimulationStatus -from paddle_billing.Notifications.Entities.Address import Address -from paddle_billing.Notifications.Entities.Entity import Entity +from paddle_billing.Notifications.Entities.Simulations import Address +from paddle_billing.Notifications.Entities.Simulations.SimulationEntity import SimulationEntity from paddle_billing.Notifications.Entities.Adjustment import Adjustment from paddle_billing.Entities.Events import EventTypeName from paddle_billing.Entities.Shared import ( CountryCode, + CustomData, + ImportMeta, Status, ) @@ -42,6 +44,15 @@ class TestSimulationsClient: country_code=CountryCode.US, created_at=datetime.fromisoformat("2024-04-12T06:42:58.785000Z"), updated_at=datetime.fromisoformat("2024-04-12T06:42:58.785000Z"), + custom_data=CustomData( + { + "some": "data", + } + ), + import_meta=ImportMeta( + external_id="some-external-id", + imported_from="some-source", + ), ), ), ReadsFixtures.read_raw_json_fixture("request/create_full"), @@ -214,7 +225,7 @@ def test_create_simulation_uses_expected_entity_payload( entity_name, ): entity_data = ReadsFixtures.read_json_fixture(f"payload/{event_type}") - payload = Entity.from_dict_for_event_type(entity_data, event_type) + payload = SimulationEntity.from_dict_for_event_type(entity_data, event_type) operation = CreateSimulation( notification_setting_id="ntfset_01j82d983j814ypzx7m1fw2jpz",