84 lines
2.0 KiB
Python
84 lines
2.0 KiB
Python
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
import logging
|
||
|
|
|
||
|
|
from yuxi.channel.extensions.ringcentral.sdk import AsyncRingCentralClient
|
||
|
|
|
||
|
|
logger = logging.getLogger(__name__)
|
||
|
|
|
||
|
|
|
||
|
|
async def list_events(
|
||
|
|
client: AsyncRingCentralClient,
|
||
|
|
group_id: str,
|
||
|
|
) -> dict:
|
||
|
|
return await client.get(f"/restapi/v1.0/glip/groups/{group_id}/events")
|
||
|
|
|
||
|
|
|
||
|
|
async def create_event(
|
||
|
|
client: AsyncRingCentralClient,
|
||
|
|
group_id: str,
|
||
|
|
title: str,
|
||
|
|
start_time: str,
|
||
|
|
end_time: str,
|
||
|
|
*,
|
||
|
|
description: str = "",
|
||
|
|
location: str = "",
|
||
|
|
all_day: bool = False,
|
||
|
|
recurrence: str | None = None,
|
||
|
|
) -> dict:
|
||
|
|
payload = {
|
||
|
|
"title": title,
|
||
|
|
"startTime": start_time,
|
||
|
|
"endTime": end_time,
|
||
|
|
}
|
||
|
|
if description:
|
||
|
|
payload["description"] = description
|
||
|
|
if location:
|
||
|
|
payload["location"] = location
|
||
|
|
if all_day:
|
||
|
|
payload["allDay"] = all_day
|
||
|
|
if recurrence:
|
||
|
|
payload["recurrence"] = recurrence
|
||
|
|
return await client.post(
|
||
|
|
f"/restapi/v1.0/glip/groups/{group_id}/events",
|
||
|
|
body=payload,
|
||
|
|
)
|
||
|
|
|
||
|
|
|
||
|
|
async def get_event(
|
||
|
|
client: AsyncRingCentralClient,
|
||
|
|
event_id: str,
|
||
|
|
) -> dict:
|
||
|
|
return await client.get(f"/restapi/v1.0/glip/events/{event_id}")
|
||
|
|
|
||
|
|
|
||
|
|
async def update_event(
|
||
|
|
client: AsyncRingCentralClient,
|
||
|
|
event_id: str,
|
||
|
|
*,
|
||
|
|
title: str | None = None,
|
||
|
|
start_time: str | None = None,
|
||
|
|
end_time: str | None = None,
|
||
|
|
description: str | None = None,
|
||
|
|
location: str | None = None,
|
||
|
|
) -> dict:
|
||
|
|
payload = {}
|
||
|
|
if title is not None:
|
||
|
|
payload["title"] = title
|
||
|
|
if start_time is not None:
|
||
|
|
payload["startTime"] = start_time
|
||
|
|
if end_time is not None:
|
||
|
|
payload["endTime"] = end_time
|
||
|
|
if description is not None:
|
||
|
|
payload["description"] = description
|
||
|
|
if location is not None:
|
||
|
|
payload["location"] = location
|
||
|
|
return await client.put(
|
||
|
|
f"/restapi/v1.0/glip/events/{event_id}",
|
||
|
|
body=payload,
|
||
|
|
)
|
||
|
|
|
||
|
|
|
||
|
|
async def delete_event(client: AsyncRingCentralClient, event_id: str) -> None:
|
||
|
|
await client.delete(f"/restapi/v1.0/glip/events/{event_id}")
|