[32788f42] Add Termin-Übersicht feature, dynamic Event-Type selection, and refactor QR cards UI into Job Details
This commit is contained in:
@@ -11,7 +11,38 @@ import logging
|
||||
|
||||
logger = logging.getLogger("qr-card-generator")
|
||||
|
||||
def get_calendly_events_raw(api_token: str, start_time: str, end_time: str, event_type_name: str = None):
|
||||
def get_calendly_event_types(api_token: str):
|
||||
"""
|
||||
Fetches available event types for the current user.
|
||||
"""
|
||||
headers = {
|
||||
'Authorization': f'Bearer {api_token}',
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
|
||||
# 1. Get current user info
|
||||
user_url = "https://api.calendly.com/users/me"
|
||||
user_response = requests.get(user_url, headers=headers)
|
||||
if not user_response.ok:
|
||||
raise Exception(f"Calendly API Error: {user_response.status_code}")
|
||||
|
||||
user_data = user_response.json()
|
||||
user_uri = user_data['resource']['uri']
|
||||
|
||||
# 2. Get event types
|
||||
event_types_url = "https://api.calendly.com/event_types"
|
||||
params = {
|
||||
'user': user_uri
|
||||
}
|
||||
|
||||
types_response = requests.get(event_types_url, headers=headers, params=params)
|
||||
if not types_response.ok:
|
||||
raise Exception(f"Calendly API Error: {types_response.status_code}")
|
||||
|
||||
types_data = types_response.json()
|
||||
return types_data['collection']
|
||||
|
||||
def get_calendly_events_raw(api_token: str, start_time: str = None, end_time: str = None, event_type_name: str = None):
|
||||
"""
|
||||
Debug function to fetch raw Calendly data without formatting.
|
||||
"""
|
||||
@@ -20,6 +51,12 @@ def get_calendly_events_raw(api_token: str, start_time: str, end_time: str, even
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
|
||||
# Defaults: now to +180 days
|
||||
if not start_time:
|
||||
start_time = datetime.datetime.utcnow().isoformat() + "Z"
|
||||
if not end_time:
|
||||
end_time = (datetime.datetime.utcnow() + datetime.timedelta(days=180)).isoformat() + "Z"
|
||||
|
||||
# 1. Get current user info to get the user URI
|
||||
user_url = "https://api.calendly.com/users/me"
|
||||
user_response = requests.get(user_url, headers=headers)
|
||||
@@ -75,7 +112,7 @@ def get_calendly_events_raw(api_token: str, start_time: str, end_time: str, even
|
||||
|
||||
return raw_results
|
||||
|
||||
def get_calendly_events(api_token: str, start_time: str, end_time: str, event_type_name: str = None):
|
||||
def get_calendly_events(api_token: str, start_time: str = None, end_time: str = None, event_type_name: str = None):
|
||||
"""
|
||||
Fetches events from Calendly API for the current user within a time range.
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user