[main] Prod Creds
All checks were successful
Build, Push, and Deploy to Nomad / docker-nomad (push) Successful in 2m8s

This commit is contained in:
Henrik Jess
2025-01-14 17:25:45 +01:00
parent 0129164fd5
commit 5de92fa7a1
17 changed files with 105 additions and 15 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,13 +1,13 @@
import json
from pprint import pprint from pprint import pprint
from amadeus import Client, ResponseError from amadeus import Client, ResponseError
import pandas as pd import pandas as pd
from datetime import datetime, timedelta from datetime import datetime, timedelta
import json from flight_types import *
class FlightFilter: class FlightFilter:
def __init__(self, api_key, api_secret): def __init__(self, api_key, api_secret):
self.amadeus = Client(client_id=api_key, client_secret=api_secret) self.amadeus = Client(client_id=api_key, client_secret=api_secret, hostname="production")
def get_flight_offers(self, request_body): def get_flight_offers(self, request_body):
""" """
@@ -119,8 +119,12 @@ class FlightFilter:
# Usage example # Usage example
if __name__ == "__main__": if __name__ == "__main__":
api_key = "uxDqIh36xPAUvpXnXynwAnH86pGBdIch" #api_key = "uxDqIh36xPAUvpXnXynwAnH86pGBdIch"
api_secret = "xTSLooNZpJWantb5" #api_secret = "xTSLooNZpJWantb5"
# PROD PROD PROD PROD PROD PROD PROD PROD PROD PROD
api_key = "ABRGQv6U7IWAYxwwmjqAOPUDGvuFMSjw"
api_secret = "BcwpSKf3FICJIxaw"
flight_filter = FlightFilter(api_key, api_secret) flight_filter = FlightFilter(api_key, api_secret)
@@ -153,25 +157,57 @@ if __name__ == "__main__":
"sources": ["GDS"], "sources": ["GDS"],
"searchCriteria": { "searchCriteria": {
"excludeAllotments": True, "excludeAllotments": True,
"addOneWayOffers": False, "addOneWayOffers": True,
"maxFlightOffers": 10, "maxFlightOffers": 50,
"allowAlternativeFareOptions": True, "allowAlternativeFareOptions": True,
} }
} }
# Fetch flights # Fetch flights
flights = flight_filter.get_flight_offers(request_body) flights = flight_filter.get_flight_offers(request_body)
print(f"Raw flights data: {flights}") with open("json_data.json", "w") as file:
json.dump(flights, file)
#
#DEBUG
#with open("json_data.json", "r") as file:
# flights = json.load(file)
#print(f"Raw flights data: {flights}")
real_flights = []
for flight in flights:
for x,v in flight.items():
if type(v) == list and "itineraries" in str(x).lower():
for flt, flt2 in flight.items():
if flt == "itineraries":
for itm in flt2:
for seg in itm.get("segments"):
departure = seg.get("departure").get("iataCode")
arrival = seg.get("arrival").get("iataCode")
print(f"{departure} -> {arrival}")
if (departure, arrival) in (("OPO", "CPH"), ("CPH", "OPO")):
print( f"{departure} -> {arrival}" )
# Filter flights from OPO to CPH around 07:00 ± 1 hour # Filter flights from OPO to CPH around 07:00 ± 1 hour
opo_to_cph_flights = flight_filter.filter_flights_by_time( #opo_to_cph_flights = flight_filter.filter_flights_by_time(
flights, origin_filter="OPO", destination_filter="CPH", filter_time_str="06:00", hours=2 # flights, origin_filter="OPO", destination_filter="CPH", filter_time_str="06:00", hours=2
) #)
# Filter flights from CPH to OPO around 18:30 ± 1 hour # Filter flights from CPH to OPO around 18:30 ± 1 hour
cph_to_opo_flights = flight_filter.filter_flights_by_time( #cph_to_opo_flights = flight_filter.filter_flights_by_time(
flights, origin_filter="CPH", destination_filter="OPO", filter_time_str="20:30", hours=2 # flights, origin_filter="CPH", destination_filter="OPO", filter_time_str="20:30", hours=2
) #)
# Save to Excel # Save to Excel
flight_filter.save_to_excel(opo_to_cph_flights, cph_to_opo_flights, "Filtered_Flights_OPO_CPH.xlsx") #flight_filter.save_to_excel(opo_to_cph_flights, cph_to_opo_flights, "Filtered_Flights_OPO_CPH.xlsx")

View File

@@ -0,0 +1,45 @@
from dataclasses import dataclass
from typing import List, Optional
# OopCompanion:suppressRename
@dataclass
class AmenityProvider:
name: str
@dataclass
class Amenity:
description: str
isChargeable: bool
amenityType: str
amenityProvider: AmenityProvider
@dataclass
class IncludedCheckedBags:
quantity: int
@dataclass
class FareDetailsBySegment:
segmentId: str
cabin: str
fareBasis: str
brandedFare: str
brandedFareLabel: str
class_: str # 'class' is a reserved keyword in Python; use 'class_' instead
includedCheckedBags: IncludedCheckedBags
amenities: List[Amenity]
@dataclass
class Price:
currency: str
total: str
base: str
@dataclass
class Traveler:
travelerId: str
fareOption: str
travelerType: str
price: Price
fareDetailsBySegment: List[FareDetailsBySegment]

View File

@@ -0,0 +1 @@
[]

Submodule inspiration/rnh_tax_calculator added at 7877b98884

View File

@@ -1,3 +1,4 @@
amadeus==11.0.0
annotated-types==0.7.0 annotated-types==0.7.0
anyio==4.7.0 anyio==4.7.0
beautifulsoup4==4.12.3 beautifulsoup4==4.12.3
@@ -12,15 +13,21 @@ markdown-it-py==3.0.0
MarkupSafe==3.0.2 MarkupSafe==3.0.2
mdurl==0.1.2 mdurl==0.1.2
mistune==3.0.2 mistune==3.0.2
numpy==2.2.1
pandas==2.2.3
pillow==11.0.0 pillow==11.0.0
pydantic==2.10.3 pydantic==2.10.3
pydantic_core==2.27.1 pydantic_core==2.27.1
python-dateutil==2.9.0.post0
python-dotenv==1.0.1 python-dotenv==1.0.1
pytz==2024.2
PyYAML==6.0.2 PyYAML==6.0.2
six==1.17.0
sniffio==1.3.1 sniffio==1.3.1
soupsieve==2.6 soupsieve==2.6
starlette==0.41.3 starlette==0.41.3
typing_extensions==4.12.2 typing_extensions==4.12.2
tzdata==2024.2
uvicorn==0.32.1 uvicorn==0.32.1
uvloop==0.21.0 uvloop==0.21.0
watchfiles==1.0.0 watchfiles==1.0.0