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

Commit

Permalink
Expose OrderChangeOffer client
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesse Claven committed Dec 16, 2021
1 parent 9712166 commit b20d6e7
Show file tree
Hide file tree
Showing 6 changed files with 707 additions and 3 deletions.
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
13 changes: 13 additions & 0 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 Down Expand Up @@ -36,6 +37,7 @@ def __init__(self, **kwargs):
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,6 +96,17 @@ 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"""
Expand Down
310 changes: 310 additions & 0 deletions tests/fixtures/get-order-change-offer-by-id.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,310 @@
{
"data": {
"change_total_amount": "90.80",
"change_total_currency": "GBP",
"created_at": "2020-01-17T10:12:14.545Z",
"expires_at": "2020-01-17T10:42:14.545Z",
"id": "oco_0000A3vUda8dKRtUSQPSXw",
"new_total_amount": "35.50",
"new_total_currency": "GBP",
"order_change_id": "oce_0000A4QasEUIjJ6jHKfhHU",
"penalty_amount": "10.50",
"penalty_currency": "GBP",
"refund_to": "arc_bsp_cash",
"slices": {
"add": [
{
"destination": {
"airports": [
{
"city": {
"iata_code": "NYC",
"iata_country_code": "US",
"id": "cit_nyc_us",
"name": "New York"
},
"city_name": "New York",
"iata_code": "JFK",
"iata_country_code": "US",
"icao_code": "KJFK",
"id": "arp_jfk_us",
"latitude": 40.640556,
"longitude": -73.778519,
"name": "John F. Kennedy International Airport",
"time_zone": "America/New_York"
}
],
"city": {
"iata_code": "NYC",
"iata_country_code": "US",
"id": "cit_nyc_us",
"name": "New York"
},
"city_name": "New York",
"iata_city_code": "NYC",
"iata_code": "JFK",
"iata_country_code": "US",
"icao_code": "KJFK",
"id": "arp_jfk_us",
"latitude": 40.640556,
"longitude": -73.778519,
"name": "John F. Kennedy International Airport",
"time_zone": "America/New_York",
"type": "airport"
},
"destination_type": "airport",
"duration": "PT02H26M",
"id": "sli_00009htYpSCXrwaB9Dn123",
"origin": {
"airports": [
{
"city": {
"iata_code": "LON",
"iata_country_code": "GB",
"id": "cit_lon_gb",
"name": "London"
},
"city_name": "London",
"iata_code": "LHR",
"iata_country_code": "GB",
"icao_code": "EGLL",
"id": "arp_lhr_gb",
"latitude": 64.068865,
"longitude": -141.951519,
"name": "Heathrow",
"time_zone": "Europe/London"
}
],
"city": {
"iata_code": "LON",
"iata_country_code": "GB",
"id": "cit_lon_gb",
"name": "London"
},
"city_name": "London",
"iata_city_code": "LON",
"iata_code": "LHR",
"iata_country_code": "GB",
"icao_code": "EGLL",
"id": "arp_lhr_gb",
"latitude": 64.068865,
"longitude": -141.951519,
"name": "Heathrow",
"time_zone": "Europe/London",
"type": "airport"
},
"origin_type": "airport",
"segments": [
{
"aircraft": {
"iata_code": "380",
"id": "arc_00009UhD4ongolulWd91Ky",
"name": "Airbus Industries A380"
},
"arriving_at": "2020-06-13T16:38:02",
"departing_at": "2020-06-13T16:38:02",
"destination": {
"city": {
"iata_code": "NYC",
"iata_country_code": "US",
"id": "cit_nyc_us",
"name": "New York"
},
"city_name": "New York",
"iata_code": "JFK",
"iata_country_code": "US",
"icao_code": "KJFK",
"id": "arp_jfk_us",
"latitude": 40.640556,
"longitude": -73.778519,
"name": "John F. Kennedy International Airport",
"time_zone": "America/New_York"
},
"destination_terminal": "5",
"distance": "424.2",
"duration": "PT02H26M",
"id": "seg_00009htYpSCXrwaB9Dn456",
"marketing_carrier": {
"iata_code": "BA",
"id": "aln_00001876aqC8c5umZmrRds",
"name": "British Airways"
},
"marketing_carrier_flight_number": "1234",
"operating_carrier": {
"iata_code": "BA",
"id": "aln_00001876aqC8c5umZmrRds",
"name": "British Airways"
},
"operating_carrier_flight_number": "4321",
"origin": {
"city": {
"iata_code": "LON",
"iata_country_code": "GB",
"id": "cit_lon_gb",
"name": "London"
},
"city_name": "London",
"iata_code": "LHR",
"iata_country_code": "GB",
"icao_code": "EGLL",
"id": "arp_lhr_gb",
"latitude": 64.068865,
"longitude": -141.951519,
"name": "Heathrow",
"time_zone": "Europe/London"
},
"origin_terminal": "B"
}
]
}
],
"remove": [
{
"destination": {
"airports": [
{
"city": {
"iata_code": "NYC",
"iata_country_code": "US",
"id": "cit_nyc_us",
"name": "New York"
},
"city_name": "New York",
"iata_code": "JFK",
"iata_country_code": "US",
"icao_code": "KJFK",
"id": "arp_jfk_us",
"latitude": 40.640556,
"longitude": -73.778519,
"name": "John F. Kennedy International Airport",
"time_zone": "America/New_York"
}
],
"city": {
"iata_code": "NYC",
"iata_country_code": "US",
"id": "cit_nyc_us",
"name": "New York"
},
"city_name": "New York",
"iata_city_code": "NYC",
"iata_code": "JFK",
"iata_country_code": "US",
"icao_code": "KJFK",
"id": "arp_jfk_us",
"latitude": 40.640556,
"longitude": -73.778519,
"name": "John F. Kennedy International Airport",
"time_zone": "America/New_York",
"type": "airport"
},
"destination_type": "airport",
"duration": "PT02H26M",
"id": "sli_00009htYpSCXrwaB9Dn123",
"origin": {
"airports": [
{
"city": {
"iata_code": "LON",
"iata_country_code": "GB",
"id": "cit_lon_gb",
"name": "London"
},
"city_name": "London",
"iata_code": "LHR",
"iata_country_code": "GB",
"icao_code": "EGLL",
"id": "arp_lhr_gb",
"latitude": 64.068865,
"longitude": -141.951519,
"name": "Heathrow",
"time_zone": "Europe/London"
}
],
"city": {
"iata_code": "LON",
"iata_country_code": "GB",
"id": "cit_lon_gb",
"name": "London"
},
"city_name": "London",
"iata_city_code": "LON",
"iata_code": "LHR",
"iata_country_code": "GB",
"icao_code": "EGLL",
"id": "arp_lhr_gb",
"latitude": 64.068865,
"longitude": -141.951519,
"name": "Heathrow",
"time_zone": "Europe/London",
"type": "airport"
},
"origin_type": "airport",
"segments": [
{
"aircraft": {
"iata_code": "380",
"id": "arc_00009UhD4ongolulWd91Ky",
"name": "Airbus Industries A380"
},
"arriving_at": "2020-06-13T16:38:02",
"departing_at": "2020-06-13T16:38:02",
"destination": {
"city": {
"iata_code": "NYC",
"iata_country_code": "US",
"id": "cit_nyc_us",
"name": "New York"
},
"city_name": "New York",
"iata_code": "JFK",
"iata_country_code": "US",
"icao_code": "KJFK",
"id": "arp_jfk_us",
"latitude": 40.640556,
"longitude": -73.778519,
"name": "John F. Kennedy International Airport",
"time_zone": "America/New_York"
},
"destination_terminal": "5",
"distance": "424.2",
"duration": "PT02H26M",
"id": "seg_00009htYpSCXrwaB9Dn456",
"marketing_carrier": {
"iata_code": "BA",
"id": "aln_00001876aqC8c5umZmrRds",
"name": "British Airways"
},
"marketing_carrier_flight_number": "1234",
"operating_carrier": {
"iata_code": "BA",
"id": "aln_00001876aqC8c5umZmrRds",
"name": "British Airways"
},
"operating_carrier_flight_number": "4321",
"origin": {
"city": {
"iata_code": "LON",
"iata_country_code": "GB",
"id": "cit_lon_gb",
"name": "London"
},
"city_name": "London",
"iata_code": "LHR",
"iata_country_code": "GB",
"icao_code": "EGLL",
"id": "arp_lhr_gb",
"latitude": 64.068865,
"longitude": -141.951519,
"name": "Heathrow",
"time_zone": "Europe/London"
},
"origin_terminal": "B"
}
]
}
]
},
"updated_at": "2020-01-17T10:12:14.545Z"
}
}
Loading

0 comments on commit b20d6e7

Please sign in to comment.