refactor: Remove CrossfitBooker class and simplify booking system
This commit is contained in:
@@ -4,8 +4,15 @@ Script to demonstrate how to execute the book_session method from crossfit_booke
|
||||
"""
|
||||
|
||||
import sys
|
||||
import os
|
||||
import logging
|
||||
from crossfit_booker import CrossFitBooker
|
||||
from src.auth import AuthHandler
|
||||
from src.booker import Booker
|
||||
from src.session_notifier import SessionNotifier
|
||||
|
||||
# Load environment variables
|
||||
from dotenv import load_dotenv
|
||||
load_dotenv()
|
||||
|
||||
# Configure logging
|
||||
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
||||
@@ -18,12 +25,40 @@ def main():
|
||||
|
||||
session_id = sys.argv[1]
|
||||
|
||||
# Create an instance of CrossFitBooker
|
||||
booker = CrossFitBooker()
|
||||
# Initialize components
|
||||
auth_handler = AuthHandler(
|
||||
os.environ.get("CROSSFIT_USERNAME"),
|
||||
os.environ.get("CROSSFIT_PASSWORD")
|
||||
)
|
||||
|
||||
# Initialize notification system (minimal for single session booking)
|
||||
email_credentials = {
|
||||
"from": os.environ.get("EMAIL_FROM"),
|
||||
"to": os.environ.get("EMAIL_TO"),
|
||||
"password": os.environ.get("EMAIL_PASSWORD")
|
||||
}
|
||||
|
||||
telegram_credentials = {
|
||||
"token": os.environ.get("TELEGRAM_TOKEN"),
|
||||
"chat_id": os.environ.get("TELEGRAM_CHAT_ID")
|
||||
}
|
||||
|
||||
enable_email = os.environ.get("ENABLE_EMAIL_NOTIFICATIONS", "true").lower() in ("true", "1", "yes")
|
||||
enable_telegram = os.environ.get("ENABLE_TELEGRAM_NOTIFICATIONS", "true").lower() in ("true", "1", "yes")
|
||||
|
||||
notifier = SessionNotifier(
|
||||
email_credentials,
|
||||
telegram_credentials,
|
||||
enable_email=enable_email,
|
||||
enable_telegram=enable_telegram
|
||||
)
|
||||
|
||||
# Create an instance of Booker
|
||||
booker = Booker(auth_handler, notifier)
|
||||
|
||||
# Login to authenticate
|
||||
print("Attempting to authenticate...")
|
||||
if not booker.login():
|
||||
if not auth_handler.login():
|
||||
print("Failed to authenticate. Please check your credentials and try again.")
|
||||
sys.exit(1)
|
||||
print("Authentication successful!")
|
||||
|
||||
Reference in New Issue
Block a user