68 lines
2.0 KiB
Python
68 lines
2.0 KiB
Python
import requests
|
|
import jwt
|
|
import time
|
|
from .utils import get_zoom_config
|
|
|
|
|
|
def generate_zoom_jwt():
|
|
"""Generate JWT token using dynamic Zoom configuration"""
|
|
config = get_zoom_config()
|
|
payload = {
|
|
'iss': config['ZOOM_ACCOUNT_ID'],
|
|
'exp': time.time() + 3600
|
|
}
|
|
token = jwt.encode(payload, config['ZOOM_CLIENT_SECRET'], algorithm='HS256')
|
|
return token
|
|
|
|
|
|
def create_zoom_meeting(topic, start_time, duration, host_email):
|
|
"""Create a Zoom meeting using dynamic configuration"""
|
|
jwt_token = generate_zoom_jwt()
|
|
headers = {
|
|
'Authorization': f'Bearer {jwt_token}',
|
|
'Content-Type': 'application/json'
|
|
}
|
|
data = {
|
|
"topic": topic,
|
|
"type": 2,
|
|
"start_time": start_time,
|
|
"duration": duration,
|
|
"schedule_for": host_email,
|
|
"settings": {"join_before_host": True}
|
|
}
|
|
url = f"https://api.zoom.us/v2/users/{host_email}/meetings"
|
|
return requests.post(url, json=data, headers=headers)
|
|
|
|
|
|
def update_zoom_meeting(meeting_id, updated_data):
|
|
"""Update an existing Zoom meeting"""
|
|
jwt_token = generate_zoom_jwt()
|
|
headers = {
|
|
'Authorization': f'Bearer {jwt_token}',
|
|
'Content-Type': 'application/json'
|
|
}
|
|
url = f"https://api.zoom.us/v2/meetings/{meeting_id}"
|
|
return requests.patch(url, json=updated_data, headers=headers)
|
|
|
|
|
|
def delete_zoom_meeting(meeting_id):
|
|
"""Delete a Zoom meeting"""
|
|
jwt_token = generate_zoom_jwt()
|
|
headers = {
|
|
'Authorization': f'Bearer {jwt_token}',
|
|
'Content-Type': 'application/json'
|
|
}
|
|
url = f"https://api.zoom.us/v2/meetings/{meeting_id}"
|
|
return requests.delete(url, headers=headers)
|
|
|
|
|
|
def get_zoom_meeting_details(meeting_id):
|
|
"""Get details of a Zoom meeting"""
|
|
jwt_token = generate_zoom_jwt()
|
|
headers = {
|
|
'Authorization': f'Bearer {jwt_token}',
|
|
'Content-Type': 'application/json'
|
|
}
|
|
url = f"https://api.zoom.us/v2/meetings/{meeting_id}"
|
|
return requests.get(url, headers=headers)
|