Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreamsorcerer committed Oct 16, 2024
1 parent e791fa8 commit 990d197
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions junction/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,16 +147,6 @@ def status(self) -> t.BookingStatus:
def ticket(self) -> t.Ticket:
return self._ticket

def _update_attrs(self, result: _BookingResult) -> None:
self._fulfillment = tuple(result["fulfillmentInformation"])
booking = result["booking"]
self._id = booking["id"]
self._fare_rules = tuple(booking["fareRules"])
self._passengers = tuple(booking["passengers"])
self._price = (booking["price"]["amount"], booking["price"]["currency"])
self._status = booking["status"]
self._ticket = booking["ticketInformation"]

async def confirm(self, fulfillment: Sequence[t.DeliveryOption]) -> t.BookingPaymentStatus:
if len(fulfillment) != len(self._fulfillment):
raise ValueError("Wrong number of fillment choices")
Expand All @@ -168,7 +158,6 @@ async def confirm(self, fulfillment: Sequence[t.DeliveryOption]) -> t.BookingPay
await raise_error(resp)

result = await resp.json()
self._update_attrs(result)
self._confirmed = True
return result["paymentStatus"]

Expand All @@ -182,8 +171,15 @@ async def refresh(self) -> None:
if not resp.ok:
await raise_error(resp)

result = await resp.json()
self._update_attrs(result)
result: _BookingResult = await resp.json()
self._fulfillment = tuple(result["fulfillmentInformation"])
booking = result["booking"]
self._id = booking["id"]
self._fare_rules = tuple(booking["fareRules"])
self._passengers = tuple(booking["passengers"])
self._price = (booking["price"]["amount"], booking["price"]["currency"])
self._status = booking["status"]
self._ticket = booking["ticketInformation"]


class JunctionClient:
Expand Down

0 comments on commit 990d197

Please sign in to comment.