Skip to content

Commit

Permalink
cleanup models
Browse files Browse the repository at this point in the history
  • Loading branch information
loechel committed Apr 27, 2024
1 parent 8f73896 commit 6802b85
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/edutap/wallet_google/modelcore.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class GoogleWalletModel(BaseModel):
)


class GoogleWalletWithKindMixin(GoogleWalletModel):
class GoogleWalletWithKindMixin(BaseModel):
"""
Mixin Class for Google Wallet Models with an deprecated kind identifier.
Explicit kind value should be provided by the inheriting concret class.
Expand All @@ -32,7 +32,7 @@ class GoogleWalletWithKindMixin(GoogleWalletModel):
)


class GoogleWalletWithIdModel(GoogleWalletWithKindMixin):
class GoogleWalletWithIdModel(BaseModel):
"""
Model for Google Wallet models with an identifier.
"""
Expand Down
6 changes: 4 additions & 2 deletions src/edutap/wallet_google/models/generic.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from ..modelbase import GoogleWalletClassModel
from ..modelbase import GoogleWalletObjectModel
from ..modelbase import GoogleWalletStyleableClassMixin
from ..modelbase import GoogleWalletStyleableObjectMixin
from ..modelcore import GoogleWalletModel
from ..registry import register_model
from .primitives.data import AppLinkData
Expand Down Expand Up @@ -38,14 +40,14 @@ class Notifications(GoogleWalletModel):
@register_model(
"GenericClass", url_part="genericClass", plural="genericClasses", can_disable=False
)
class GenericClass(GoogleWalletClassModel):
class GenericClass(GoogleWalletClassModel, GoogleWalletStyleableClassMixin):
"""
see: https://developers.google.com/wallet/generic/rest/v1/genericclass
"""


@register_model("GenericObject", url_part="genericObject")
class GenericObject(GoogleWalletObjectModel):
class GenericObject(GoogleWalletObjectModel, GoogleWalletStyleableObjectMixin):
"""
see: https://developers.google.com/wallet/generic/rest/v1/genericobject
"""
Expand Down
11 changes: 10 additions & 1 deletion src/edutap/wallet_google/models/primitives/datetime.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from ...modelcore import GoogleWalletModel
from ...modelcore import GoogleWalletWithKindMixin
from pydantic import Field

import datetime

Expand All @@ -11,10 +13,17 @@ class DateTime(GoogleWalletModel):
date: datetime.datetime


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

kind: str | None = Field(
description="deprecated",
deprecated=True,
exclude=True,
default="walletobjects#timeInterval",
)

start: DateTime | None = None
end: DateTime | None = None
8 changes: 8 additions & 0 deletions src/edutap/wallet_google/models/retail.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from ..modelbase import GoogleWalletObjectWithClassReferenceMixin
from ..modelbase import GoogleWalletStyleableClassMixin
from ..modelbase import GoogleWalletStyleableObjectMixin
from ..modelcore import GoogleWalletWithIdModel
from ..modelcore import GoogleWalletWithKindMixin
from ..registry import register_model
from .primitives import GroupingInfo
from .primitives import Image
Expand Down Expand Up @@ -72,6 +74,8 @@ class GiftCardClass(
@register_model("GiftCardObject", url_part="giftCardObject")
class GiftCardObject(
GoogleWalletObjectModel,
GoogleWalletWithIdModel,
GoogleWalletWithKindMixin,
GoogleWalletMessageableMixin,
GoogleWalletStyleableObjectMixin,
):
Expand Down Expand Up @@ -142,21 +146,25 @@ class LoyaltyClass(
# deprecated
version: str | None = Field(
description="deprecated",
deprecated=True,
exclude=True,
default=None,
) # int64
allowMultipleUsersPerObject: bool = Field(
description="deprecated",
deprecated=True,
exclude=True,
default=True,
)
infoModuleData: InfoModuleData | None = Field(
description="deprecated",
deprecated=True,
exclude=True,
default=None,
)
wordMark: Image | None = Field(
description="deprecated",
deprecated=True,
exclude=True,
default=None,
)
Expand Down
31 changes: 26 additions & 5 deletions src/edutap/wallet_google/models/tickets_and_transit.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
from .primitives.location import LatLongPoint
from .primitives.money import Money
from .primitives.review import Review
from pydantic import BaseModel
from pydantic import Field

import datetime
Expand All @@ -49,27 +48,29 @@ class TicketAndTransitClassBaseModel(GoogleWalletClassModel):
homepageUri: Uri | None = None


class EventVenue(GoogleWalletWithKindMixin):
class EventVenue(GoogleWalletModel, GoogleWalletWithKindMixin):
"""
see: https://developers.google.com/wallet/tickets/events/rest/v1/eventticketclass#eventvenue
"""

kind: str | None = Field(
description="deprecated",
deprecated=True,
exclude=True,
default="walletobjects#eventDateTime",
)
name: LocalizedString | None = None
address: LocalizedString | None = None


class EventDateTime(GoogleWalletWithKindMixin):
class EventDateTime(GoogleWalletModel, GoogleWalletWithKindMixin):
"""
see: https://developers.google.com/wallet/tickets/events/rest/v1/eventticketclass#eventdatetime
"""

kind: str | None = Field(
description="deprecated",
deprecated=True,
exclude=True,
default="walletobjects#eventDateTime",
)
Expand All @@ -80,14 +81,34 @@ class EventDateTime(GoogleWalletWithKindMixin):
customDoorsOpenLabel: LocalizedString | None = None


class EventSeat(BaseModel):
class EventSeat(GoogleWalletModel, GoogleWalletWithKindMixin):
"""
see: https://developers.google.com/wallet/reference/rest/v1/eventticketobject#eventseat
"""

kind: str | None = Field(
description="deprecated",
deprecated=True,
exclude=True,
default="walletobjects#eventSeat",
)
seat: LocalizedString | None = None
row: LocalizedString | None = None
section: LocalizedString | None = None
gate: LocalizedString | None = None


class EventReservationInfo(BaseModel):
class EventReservationInfo(GoogleWalletModel, GoogleWalletWithKindMixin):
"""
see: https://developers.google.com/wallet/reference/rest/v1/eventticketobject#eventreservationinfo
"""

kind: str | None = Field(
description="deprecated",
deprecated=True,
exclude=True,
default="walletobjects#eventReservationInfo",
)
confirmationCode: str | None = None


Expand Down

0 comments on commit 6802b85

Please sign in to comment.