Skip to content

Commit

Permalink
Merge branch 'main' of github.com:edutap-eu/edutap.wallet_google
Browse files Browse the repository at this point in the history
  • Loading branch information
rnixx committed Dec 11, 2024
2 parents 28f44be + e37e81b commit 0ad4239
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 116 deletions.
33 changes: 2 additions & 31 deletions src/edutap/wallet_google/api.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from .models.bases import Model
from .models.datatypes.enums import State
from .models.datatypes.general import Pagination
from .models.message import AddMessageRequest
from .models.message import Message
from .models.datatypes.message import Message
from .models.misc import AddMessageRequest
from .models.passes.bases import ObjectWithClassReference
from .registry import lookup_metadata
from .registry import lookup_model
Expand Down Expand Up @@ -184,34 +183,6 @@ def update(
return model.model_validate_json(response.content)


def disable(
name: str,
resource_id: str,
) -> Model:
"""
Disables a Google Wallet Class or Object. `D` in CRUD.
Generic Implementation of the CRUD --> (D) usually delete,
but here disable since delete is not supported at Google Wallets.
Technically, there is no disable method in the Google Wallet API,
but a state can be set to expired to indicate disabled objects -
which is done here.
:param name: Registered name of the model to use
:param resource_id: Identifier of the resource to read from the Google RESTful API
:raises LookupError: When the resource was not found (404)
:raises Exception: When the response status code is not 200 or 404
:return: The created model based on the data returned by the Restful API
"""
raise_when_operation_not_allowed(name, "disable")
model_metadata = lookup_metadata(name)
data = {
model_metadata["resource_id"]: resource_id,
"state": str(State.EXPIRED.value),
}
return update(name, data)


def message(
name: str,
resource_id: str,
Expand Down
72 changes: 0 additions & 72 deletions src/edutap/wallet_google/models/issuer.py

This file was deleted.

13 changes: 0 additions & 13 deletions src/edutap/wallet_google/models/message.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,96 @@
"""
This module contains models that are not directly related to passes but to other Google Wallet APIs
"""

from ..registry import register_model
from .bases import Model
from .bases import WithIdModel
from .datatypes.general import CallbackOptions
from .datatypes.message import Message
from .datatypes.smarttap import IssuerContactInfo
from .datatypes.smarttap import IssuerToUserInfo
from .datatypes.smarttap import Permission
from .datatypes.smarttap import SmartTapMerchantData
from .passes import generic
from .passes import retail
from .passes import tickets_and_transit


@register_model(
"SmartTap",
url_part="smartTap",
can_read=False,
can_update=False,
can_disable=False,
can_list=False,
can_message=False,
)
class SmartTap(WithIdModel):
"""
see: https://developers.google.com/wallet/generic/rest/v1/smarttap#resource:-smarttap
"""

# Attribute order as in Google's documentation to make future updates easier!
# last check: 2024-11-29

# inherits id
merchantId: str
infos: list[IssuerToUserInfo] | None = None


@register_model(
"Issuer",
url_part="issuer",
resource_id="issuerId",
can_message=False,
)
class Issuer(Model):
"""
see: https://developers.google.com/wallet/generic/rest/v1/issuer
"""

# Attribute order as in Google's documentation to make future updates easier!
# last check: 2024-11-29

issuerId: str
name: str
contactInfo: IssuerContactInfo | None = None
homepageUrl: str | None = None
smartTapMerchantData: SmartTapMerchantData | None = None
callbackOptions: CallbackOptions | None = None


@register_model(
"Permissions",
url_part="permissions",
resource_id="issuerId",
can_disable=False,
can_list=False,
can_message=False,
)
class Permissions(Model):
"""
see: https://developers.google.com/wallet/generic/rest/v1/permissions
"""

# Attribute order as in Google's documentation to make future updates easier!
# last check: 2024-11-29

issuerId: str | None = None
permissions: list[Permission] = []


class AddMessageRequest(Model):
"""
see: https://developers.google.com/wallet/tickets/events/rest/v1/AddMessageRequest
"""

# Attribute order as in Google's documentation to make future updates easier!
# last check: 2024-11-29

message: Message | None = None


@register_model(
"Jwt",
url_part="jwt",
Expand Down

0 comments on commit 0ad4239

Please sign in to comment.