예제 #1
0
KIWI_PARAMS_FLIGHT = {
    "fly_from": "LON",
    "fly_to": "",
    "curr": "GBP",
    "dateFrom": tomorrow.strftime("%d/%m/%Y"),
    "dateTo": six_month_later.strftime("%d/%m/%Y"),
    "nights_in_dst_from": 5,
    "nights_in_dst_to": 7,
    "price_to": "",
    "max_stopovers": 0,
    "limit": 1
}

#notify user by msg
msg_body= ''
for item in sheety_data["prices"]:
    KIWI_PARAMS_FLIGHT["fly_to"] = item["iataCode"]
    KIWI_PARAMS_FLIGHT["price_to"] = item["lowestPrice"]
    kiwi_data = flight_search.get_cheapest_flight(params=KIWI_PARAMS_FLIGHT)
    flight_data = FlightData(kiwi_data, from_city="London", from_code="LCY")
    formatted_msg = flight_data.get_formatted_data(to_city=item["city"], to_city_code=item["iataCode"])
    if formatted_msg is not None:
        msg_body += f'{formatted_msg}\n'


notification_manager = NotificationManager(msg_sid=TWILIO_SID, msg_token=TWILIO_TOKEN, smtp_connection="smtp.gmail.com",
                                           smtp_email="*****@*****.**", email_password="******")

email_list = notification_manager.get_email_list(endpoint=SHEETY_USERS_ENDPOINT, header=SHEETY_HEADER)
notification_manager.send_emails(emails_list=email_list, content=msg_body)