fids/subscription-domain/subscription-manager/src/api/utils/messages.py

37 lines
1.5 KiB
Python

from src.api.schemas.subscription import FlightData
def get_update_message(flight: FlightData):
msg = f"Your flight {flight.flight_code} from {flight.origin} to {flight.destination} has been updated."
if flight.status is not None:
msg += f"\nNew status: {flight.status}"
if flight.departure_time is not None:
msg += f"\nNew departure time: {flight.departure_time}"
if flight.arrival_time is not None:
msg += f"\nNew arrival time: {flight.arrival_time}"
if flight.gate is not None:
msg += f"\nNew gate: {flight.gate}"
return f"{msg}\n\nIf you want to see the full flight data, write `/flight {flight.id}`."
def get_flight_message(flight: dict):
return (
f"Here is the full data for your flight {flight['flight_code']} (ID: {flight['id']}):"
f"\n\nStatus: {flight['status'] if flight['status'] else 'Not available'}"
f"\nOrigin: {flight['origin']}"
f"\nDestination: {flight['destination']}"
f"\nDeparture Time: {flight['departure_time'] if flight['departure_time'] else 'Not available'}"
f"\nArrival Time: {flight['arrival_time'] if flight['arrival_time'] else 'Not available'}"
f"\nGate: {flight['gate'] if flight['gate'] else 'Not available'}"
f"\n\nThank you for using our flight update service!"
)
def get_invalid_message():
return (
"Invalid option!\nPlease use:\n"
"\n/flights NUMBER (e.g., /flights 1) for flight details"
"\n/start to start receiving messages"
"\n/stop to manage updates."
)