Skip to content

Commit

Permalink
fix some classes
Browse files Browse the repository at this point in the history
  • Loading branch information
loechel committed Apr 28, 2024
1 parent 6802b85 commit a9d3047
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 11 deletions.
4 changes: 3 additions & 1 deletion src/edutap/wallet_google/modelbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ class GoogleWalletObjectModel(GoogleWalletWithIdModel):
rotatingBarcode: RotatingBarcode | None = None


class GoogleWalletObjectWithClassReferenceMixin(GoogleWalletModel):
class GoogleWalletObjectWithClassReferenceMixin(
GoogleWalletModel, GoogleWalletWithIdModel
):
"""
Mixin for all Google Wallet Object with a classReferences attribute, that reflects the whole class data.
"""
Expand Down
2 changes: 1 addition & 1 deletion src/edutap/wallet_google/modelcore.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class GoogleWalletModel(BaseModel):
"""

model_config = ConfigDict(
extra="forbid",
# extra="forbid",
# extra="ignore",
# use_enum_values=True,
)
Expand Down
13 changes: 11 additions & 2 deletions src/edutap/wallet_google/models/generic.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from ..modelbase import GoogleWalletClassModel
from ..modelbase import GoogleWalletMessageableMixin
from ..modelbase import GoogleWalletObjectModel
from ..modelbase import GoogleWalletStyleableClassMixin
from ..modelbase import GoogleWalletStyleableObjectMixin
Expand Down Expand Up @@ -40,14 +41,22 @@ class Notifications(GoogleWalletModel):
@register_model(
"GenericClass", url_part="genericClass", plural="genericClasses", can_disable=False
)
class GenericClass(GoogleWalletClassModel, GoogleWalletStyleableClassMixin):
class GenericClass(
GoogleWalletClassModel,
GoogleWalletStyleableClassMixin,
GoogleWalletMessageableMixin,
):
"""
see: https://developers.google.com/wallet/generic/rest/v1/genericclass
"""


@register_model("GenericObject", url_part="genericObject")
class GenericObject(GoogleWalletObjectModel, GoogleWalletStyleableObjectMixin):
class GenericObject(
GoogleWalletObjectModel,
GoogleWalletStyleableObjectMixin,
GoogleWalletMessageableMixin,
):
"""
see: https://developers.google.com/wallet/generic/rest/v1/genericobject
"""
Expand Down
7 changes: 5 additions & 2 deletions src/edutap/wallet_google/models/primitives/message.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
from ...modelcore import GoogleWalletModel
from ...modelcore import GoogleWalletWithIdModel
from ...modelcore import GoogleWalletWithKindMixin
from .datetime import TimeInterval
from .enums import MessageType
from .localized_string import LocalizedString
from pydantic import Field


class Message(
GoogleWalletWithIdModel,
GoogleWalletModel,
GoogleWalletWithKindMixin,
):
"""
see: https://developers.google.com/wallet/tickets/events/rest/v1/Message
"""

kind: str | None = Field(
description="deprecated",
deprecated=True,
exclude=True,
default="walletobjects#walletObjectMessage",
)
id: str | None = None
messageType: MessageType = MessageType.MESSAGE_TYPE_UNSPECIFIED
displayInterval: TimeInterval | None = None
header: str | None = None
Expand Down
19 changes: 15 additions & 4 deletions src/edutap/wallet_google/models/retail.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from ..modelbase import GoogleWalletObjectWithClassReferenceMixin
from ..modelbase import GoogleWalletStyleableClassMixin
from ..modelbase import GoogleWalletStyleableObjectMixin
from ..modelcore import GoogleWalletModel
from ..modelcore import GoogleWalletWithIdModel
from ..modelcore import GoogleWalletWithKindMixin
from ..registry import register_model
Expand All @@ -30,7 +31,6 @@
from .primitives.money import Money
from .primitives.retail import DiscoverableProgram
from .primitives.review import Review
from pydantic import BaseModel
from pydantic import Field
from pydantic import model_validator

Expand Down Expand Up @@ -105,6 +105,7 @@ class GiftCardObject(
)
class LoyaltyClass(
GoogleWalletClassModel,
GoogleWalletWithKindMixin,
GoogleWalletMessageableMixin,
GoogleWalletStyleableClassMixin,
):
Expand Down Expand Up @@ -170,7 +171,10 @@ class LoyaltyClass(
)


class LoyaltyPointsBalance(BaseModel):
class LoyaltyPointsBalance(
GoogleWalletModel,
GoogleWalletWithKindMixin,
):
"""
data-type,
see: https://developers.google.com/wallet/retail/loyalty-cards/rest/v1/loyaltyobject#LoyaltyPointsBalance
Expand All @@ -195,7 +199,10 @@ def check_one_of(self) -> "LoyaltyPointsBalance":
return self


class LoyaltyPoints(BaseModel):
class LoyaltyPoints(
GoogleWalletModel,
GoogleWalletWithKindMixin,
):
"""
data-type,
see: https://developers.google.com/wallet/retail/loyalty-cards/rest/v1/loyaltyobject#LoyaltyPoints
Expand All @@ -207,7 +214,11 @@ class LoyaltyPoints(BaseModel):


@register_model("LoyaltyObject", url_part="loyaltyObject", plural="loyaltyObjects")
class LoyaltyObject(GoogleWalletObjectModel, GoogleWalletObjectWithClassReferenceMixin):
class LoyaltyObject(
GoogleWalletObjectModel,
GoogleWalletWithKindMixin,
GoogleWalletObjectWithClassReferenceMixin,
):
"""
data-type,
see: https://developers.google.com/wallet/retail/loyalty-cards/rest/v1/loyaltyobject
Expand Down
6 changes: 5 additions & 1 deletion src/edutap/wallet_google/models/tickets_and_transit.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from ..modelbase import GoogleWalletStyleableClassMixin
from ..modelbase import GoogleWalletStyleableObjectMixin
from ..modelcore import GoogleWalletModel
from ..modelcore import GoogleWalletWithIdModel
from ..modelcore import GoogleWalletWithKindMixin
from ..registry import register_model
from .primitives import Image
Expand Down Expand Up @@ -38,7 +39,7 @@
import datetime


class TicketAndTransitClassBaseModel(GoogleWalletClassModel):
class TicketAndTransitClassBaseModel(GoogleWalletClassModel, GoogleWalletWithIdModel):
"""
Common Fields for Classes in this Module
"""
Expand Down Expand Up @@ -120,6 +121,7 @@ class EventReservationInfo(GoogleWalletModel, GoogleWalletWithKindMixin):
)
class EventTicketClass(
TicketAndTransitClassBaseModel,
GoogleWalletWithKindMixin,
GoogleWalletMessageableMixin,
GoogleWalletStyleableClassMixin,
):
Expand All @@ -129,6 +131,7 @@ class EventTicketClass(

kind: str | None = Field(
description="deprecated",
deprecated=True,
exclude=True,
default="walletobjects#eventTicketClass",
)
Expand Down Expand Up @@ -166,6 +169,7 @@ class EventTicketClass(
)
class EventTicketObject(
GoogleWalletObjectModel,
GoogleWalletWithKindMixin,
GoogleWalletObjectWithClassReferenceMixin,
GoogleWalletMessageableMixin,
GoogleWalletStyleableObjectMixin,
Expand Down

0 comments on commit a9d3047

Please sign in to comment.