Skip to content

Commit

Permalink
feat: Rename Paypal class to PayPal
Browse files Browse the repository at this point in the history
  • Loading branch information
davidgrayston-paddle committed Nov 14, 2024
1 parent e123a27 commit 04ff50e
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 20 deletions.
6 changes: 3 additions & 3 deletions paddle_billing/Entities/PaymentMethod.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from paddle_billing.Entities.Entity import Entity
from paddle_billing.Entities.Shared import (
Card,
Paypal,
PayPal,
SavedPaymentMethodOrigin,
SavedPaymentMethodType,
)
Expand All @@ -18,7 +18,7 @@ class PaymentMethod(Entity):
address_id: str
type: SavedPaymentMethodType | None
card: Card | None
paypal: Paypal | None
paypal: PayPal | None
origin: SavedPaymentMethodOrigin
saved_at: datetime
updated_at: datetime
Expand All @@ -31,7 +31,7 @@ def from_dict(data: dict) -> PaymentMethod:
address_id=data["address_id"],
type=SavedPaymentMethodType(data["type"]),
card=Card.from_dict(data["card"]) if data.get("card") else None,
paypal=Paypal.from_dict(data["paypal"]) if data.get("paypal") else None,
paypal=PayPal.from_dict(data["paypal"]) if data.get("paypal") else None,
origin=SavedPaymentMethodOrigin(data["origin"]),
saved_at=datetime.fromisoformat(data["saved_at"]),
updated_at=datetime.fromisoformat(data["updated_at"]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@


@dataclass
class Paypal:
class PayPal:
email: str
reference: str

@staticmethod
def from_dict(data: dict) -> Paypal:
return Paypal(
def from_dict(data: dict) -> PayPal:
return PayPal(
email=data["email"],
reference=data["reference"],
)
2 changes: 1 addition & 1 deletion paddle_billing/Entities/Shared/PaymentMethodType.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ class PaymentMethodType(PaddleStrEnum, metaclass=PaddleStrEnumMeta):
GooglePay: "PaymentMethodType" = "google_pay"
Ideal: "PaymentMethodType" = "ideal"
Offline: "PaymentMethodType" = "offline"
Paypal: "PaymentMethodType" = "paypal"
PayPal: "PaymentMethodType" = "paypal"
Unknown: "PaymentMethodType" = "unknown"
WireTransfer: "PaymentMethodType" = "wire_transfer"
2 changes: 1 addition & 1 deletion paddle_billing/Entities/Shared/SavedPaymentMethodType.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ class SavedPaymentMethodType(PaddleStrEnum, metaclass=PaddleStrEnumMeta):
ApplePay: "SavedPaymentMethodType" = "apple_pay"
Card: "SavedPaymentMethodType" = "card"
GooglePay: "SavedPaymentMethodType" = "google_pay"
Paypal: "SavedPaymentMethodType" = "paypal"
PayPal: "SavedPaymentMethodType" = "paypal"
2 changes: 1 addition & 1 deletion paddle_billing/Entities/Shared/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from paddle_billing.Entities.Shared.PaymentAttemptStatus import PaymentAttemptStatus
from paddle_billing.Entities.Shared.PaymentMethodType import PaymentMethodType
from paddle_billing.Entities.Shared.PayoutTotalsAdjustment import PayoutTotalsAdjustment
from paddle_billing.Entities.Shared.Paypal import Paypal
from paddle_billing.Entities.Shared.PayPal import PayPal
from paddle_billing.Entities.Shared.PriceQuantity import PriceQuantity
from paddle_billing.Entities.Shared.Proration import Proration
from paddle_billing.Entities.Shared.SavedPaymentMethodOrigin import SavedPaymentMethodOrigin
Expand Down
15 changes: 15 additions & 0 deletions paddle_billing/Notifications/Entities/Shared/PayPal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from __future__ import annotations
from dataclasses import dataclass


@dataclass
class PayPal:
email: str
reference: str

@staticmethod
def from_dict(data: dict) -> PayPal:
return PayPal(
email=data["email"],
reference=data["reference"],
)
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class PaymentMethodType(PaddleStrEnum, metaclass=PaddleStrEnumMeta):
GooglePay: "PaymentMethodType" = "google_pay"
Ideal: "PaymentMethodType" = "ideal"
Offline: "PaymentMethodType" = "offline"
Paypal: "PaymentMethodType" = "paypal"
PayPal: "PaymentMethodType" = "paypal"
Unknown: "PaymentMethodType" = "unknown"
WireTransfer: "PaymentMethodType" = "wire_transfer"
Visa: "PaymentMethodType" = "visa"
6 changes: 3 additions & 3 deletions paddle_billing/Notifications/Entities/Shared/Paypal.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@


@dataclass
class Paypal:
class PayPal:
email: str
reference: str

@staticmethod
def from_dict(data: dict) -> Paypal:
return Paypal(
def from_dict(data: dict) -> PayPal:
return PayPal(
email=data["email"],
reference=data["reference"],
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ class SavedPaymentMethodType(PaddleStrEnum, metaclass=PaddleStrEnumMeta):
ApplePay: "SavedPaymentMethodType" = "apple_pay"
Card: "SavedPaymentMethodType" = "card"
GooglePay: "SavedPaymentMethodType" = "google_pay"
Paypal: "SavedPaymentMethodType" = "paypal"
PayPal: "SavedPaymentMethodType" = "paypal"
2 changes: 1 addition & 1 deletion paddle_billing/Notifications/Entities/Shared/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from paddle_billing.Notifications.Entities.Shared.PaymentAttemptStatus import PaymentAttemptStatus
from paddle_billing.Notifications.Entities.Shared.PaymentMethodType import PaymentMethodType
from paddle_billing.Notifications.Entities.Shared.PayoutTotalsAdjustment import PayoutTotalsAdjustment
from paddle_billing.Notifications.Entities.Shared.Paypal import Paypal
from paddle_billing.Notifications.Entities.Shared.PayPal import PayPal
from paddle_billing.Notifications.Entities.Shared.PriceQuantity import PriceQuantity
from paddle_billing.Notifications.Entities.Shared.Proration import Proration
from paddle_billing.Notifications.Entities.Shared.SavedPaymentMethodDeletionReason import (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
ListPaymentMethods,
)

from paddle_billing.Entities.Shared import Card, Paypal, SavedPaymentMethodOrigin, SavedPaymentMethodType
from paddle_billing.Entities.Shared import Card, PayPal, SavedPaymentMethodOrigin, SavedPaymentMethodType

from tests.Utils.ReadsFixture import ReadsFixtures

Expand Down Expand Up @@ -252,13 +252,13 @@ def test_get_payment_methods_returns_expected_paypal_response(
assert response.customer_id == "ctm_01hv6y1jedq4p1n0yqn5ba3ky4"
assert response.address_id == "add_01hv8h6jj90jjz0d71m6hj4r9z"
assert response.card is None
assert response.type == SavedPaymentMethodType.Paypal
assert response.type == SavedPaymentMethodType.PayPal
assert response.origin == SavedPaymentMethodOrigin.SavedDuringPurchase
assert response.saved_at.isoformat() == "2024-05-03T11:50:23.422000+00:00"
assert response.updated_at.isoformat() == "2024-05-04T11:50:23.422000+00:00"

paypal = response.paypal
assert isinstance(paypal, Paypal)
assert isinstance(paypal, PayPal)
assert paypal.email == "[email protected]"
assert paypal.reference == "some-reference"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ def test_get_payment_method_change_transaction_returns_transaction_with_availabl
assert available_payment_methods[4] == PaymentMethodType.GooglePay
assert available_payment_methods[5] == PaymentMethodType.Ideal
assert available_payment_methods[6] == PaymentMethodType.Offline
assert available_payment_methods[7] == PaymentMethodType.Paypal
assert available_payment_methods[7] == PaymentMethodType.PayPal
assert available_payment_methods[8] == PaymentMethodType.Unknown
assert available_payment_methods[9] == PaymentMethodType.WireTransfer

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ def test_get_transaction_returns_transaction_with_available_payment_methods(
assert available_payment_methods[4] == PaymentMethodType.GooglePay
assert available_payment_methods[5] == PaymentMethodType.Ideal
assert available_payment_methods[6] == PaymentMethodType.Offline
assert available_payment_methods[7] == PaymentMethodType.Paypal
assert available_payment_methods[7] == PaymentMethodType.PayPal
assert available_payment_methods[8] == PaymentMethodType.Unknown
assert available_payment_methods[9] == PaymentMethodType.WireTransfer

Expand Down

0 comments on commit 04ff50e

Please sign in to comment.