Skip to content

Commit

Permalink
Fix google wallet error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
jontyms committed Jan 6, 2025
1 parent 8166c74 commit 64f093e
Showing 1 changed file with 36 additions and 7 deletions.
43 changes: 36 additions & 7 deletions app/routes/wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@

logger = logging.getLogger(__name__)

router = APIRouter(prefix="/wallet", tags=["API", "MobileWallet"], responses=Errors.basic_http())
router = APIRouter(
prefix="/wallet",
tags=["API", "MobileWallet"],
responses=Errors.basic_http(),
)


class GoogleWallet:
Expand Down Expand Up @@ -66,7 +70,7 @@ def create_object(self, issuer_id: str, class_suffix: str, user_data: UserModel)
except HttpError as e:
if e.status_code != 404:
# Something else went wrong...
logger.error("Google Wallet" + e.error_details)
logger.error("Google Wallet" + str(e.error_details))
return f"{issuer_id}.{user_id}"
else:
logger.info(f"Wallet Object {issuer_id}.{user_id} already exists!")
Expand Down Expand Up @@ -97,7 +101,12 @@ def create_object(self, issuer_id: str, class_suffix: str, user_data: UserModel)
}
},
},
"cardTitle": {"defaultValue": {"language": "en-US", "value": "Hack@UCF Membership ID"}},
"cardTitle": {
"defaultValue": {
"language": "en-US",
"value": "Hack@UCF Membership ID",
}
},
"subheader": {"defaultValue": {"language": "en-US", "value": "Name "}},
"header": {
"defaultValue": {
Expand All @@ -120,7 +129,10 @@ def create_object(self, issuer_id: str, class_suffix: str, user_data: UserModel)
"alternateText": user_data.discord.username,
},
"locations": [
{"latitude": 28.60183940476708, "longitude": -81.19807063116282},
{
"latitude": 28.60183940476708,
"longitude": -81.19807063116282,
},
],
"accountId": user_id,
"accountName": str(user_data.first_name) + " " + str(user_data.surname),
Expand Down Expand Up @@ -158,7 +170,12 @@ def create_jwt_existing_objects(self, issuer_id: str, user_id, class_id) -> str:
# Note: Make sure to replace the placeholder class and object suffixes
objects_to_add = {
# Loyalty cards
"genericObjects": [{"id": f"{issuer_id}.{user_id}", "classId": f"{issuer_id}.{class_id}"}],
"genericObjects": [
{
"id": f"{issuer_id}.{user_id}",
"classId": f"{issuer_id}.{class_id}",
}
],
}

# Create the JWT claims
Expand Down Expand Up @@ -206,14 +223,26 @@ def apple_wallet(user_data):

# Add locally stored assets
with open(
os.path.join(os.path.dirname(__file__), "..", "static", "apple_wallet", "icon.png"),
os.path.join(
os.path.dirname(__file__),
"..",
"static",
"apple_wallet",
"icon.png",
),
"rb",
) as file:
ico_data = file.read()
p.add_to_pass_package(("icon.png", ico_data))

with open(
os.path.join(os.path.dirname(__file__), "..", "static", "apple_wallet", "[email protected]"),
os.path.join(
os.path.dirname(__file__),
"..",
"static",
"apple_wallet",
"[email protected]",
),
"rb",
) as file:
ico_data = file.read()
Expand Down

0 comments on commit 64f093e

Please sign in to comment.