import requests
import datetime
from dotenv import load_dotenv
import os

def get_calendar_events():
    token = os.getenv('HAS_TOKEN')
    if not token:
        raise Exception('Missing HAS token')
    
    headers = {"Authorization": f"Bearer {token}"}
    payload = {
        'start': datetime.datetime.now().strftime('%Y-%m-%d'), 
        'end': (datetime.datetime.now() + datetime.timedelta(days=14)).strftime('%Y-%m-%d')}
    response = requests.get('https://has.nozzy.online/api/calendars/calendar.romosborne_gmail_com', 
                            headers=headers,
                            params=payload)
    return response.json()

if __name__ == "__main__":
    load_dotenv()
    events = get_calendar_events()
