Skip to content
This repository has been archived by the owner on Sep 12, 2024. It is now read-only.

[FLAPI-2041] Finish order change offers implementation #14

Merged
merged 3 commits into from
Dec 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions duffel_api/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from .booking.offers import OfferClient
from .booking.orders import OrderClient, OrderCreate, OrderUpdate
from .booking.order_cancellations import OrderCancellationClient
from .booking.order_change_offers import OrderChangeOffersClient
from .booking.order_change_offers import OrderChangeOfferClient
from .booking.payments import PaymentClient
from .booking.seat_maps import SeatMapClient
from .duffel_payments.payment_intents import PaymentIntentClient, PaymentIntentCreate
Expand All @@ -18,7 +18,7 @@
OfferRequestClient,
OfferRequestCreate,
OfferClient,
OrderChangeOffersClient,
OrderChangeOfferClient,
OrderClient,
OrderCreate,
OrderUpdate,
Expand Down
2 changes: 1 addition & 1 deletion duffel_api/api/booking/order_change_offers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from ...models import OrderChangeOffer


class OrderChangeOffersClient(HttpClient):
class OrderChangeOfferClient(HttpClient):
"""Client to interact with Order Change Offers"""

def __init__(self, **kwargs):
Expand Down
25 changes: 19 additions & 6 deletions duffel_api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
OfferClient,
OrderCancellationClient,
OrderClient,
OrderChangeOfferClient,
PaymentClient,
PaymentIntentClient,
SeatMapClient,
Expand All @@ -32,10 +33,11 @@ def __init__(self, **kwargs):
self.offer_client = None
self.order_client = None
self.order_cancellation_client = None
self.payment_intents_client = None
self.payments_client = None
self.payment_intent_client = None
self.payment_client = None
self.seat_map_client = None
self.webhook_client = None
self.order_change_offer_client = None

@property
def aircraft(self):
Expand Down Expand Up @@ -94,19 +96,30 @@ def order_cancellations(self):
)
return self.order_cancellation_client

@property
def order_change_offers(self):
"""Order Change Offers API - /air/order_change_offers"""
if isinstance(self.order_change_offer_client, type(None)):
setattr(
self,
"order_change_offer_client",
OrderChangeOfferClient(**self._kwargs),
)
return self.order_change_offer_client

@property
def payment_intents(self):
"""Payment Intents API - /payments/payment_intents"""
if isinstance(self.payment_intents_client, type(None)):
if isinstance(self.payment_intent_client, type(None)):
setattr(self, "payment_intent_client", PaymentIntentClient(**self._kwargs))
return self.payment_intent_client

@property
def payments(self):
"""Payments API - /air/payments"""
if isinstance(self.payments_client, type(None)):
setattr(self, "payments_client", PaymentClient(**self._kwargs))
return self.payments_client
if isinstance(self.payment_client, type(None)):
setattr(self, "payment_client", PaymentClient(**self._kwargs))
return self.payment_client

@property
def seat_maps(self):
Expand Down
9 changes: 7 additions & 2 deletions duffel_api/models/order_change_offer.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,13 @@ class OrderChangeOfferSlices:
"""The slices to be added and/or removed"""

def __init__(self, json):
setattr(self, "add", OrderChangeOfferSlicesAdd(json["add"]))
setattr(self, "remove", OrderChangeOfferSlicesRemove(json["remove"]))
add = list(map(lambda add: OrderChangeOfferSlicesAdd(add), json["add"]))
remove = list(
map(lambda remove: OrderChangeOfferSlicesRemove(remove), json["remove"])
)

setattr(self, "add", add)
setattr(self, "remove", remove)


class OrderChangeOfferSlicesAdd:
Expand Down
Loading