54 lines
1.4 KiB
Python
54 lines
1.4 KiB
Python
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
import logging
|
||
|
|
|
||
|
|
from yuxi.channel.extensions.ringcentral.sdk import AsyncRingCentralClient
|
||
|
|
|
||
|
|
logger = logging.getLogger(__name__)
|
||
|
|
|
||
|
|
|
||
|
|
async def create_team(
|
||
|
|
client: AsyncRingCentralClient,
|
||
|
|
name: str,
|
||
|
|
description: str = "",
|
||
|
|
members: list[str] | None = None,
|
||
|
|
) -> dict:
|
||
|
|
body = {"name": name}
|
||
|
|
if description:
|
||
|
|
body["description"] = description
|
||
|
|
if members:
|
||
|
|
body["members"] = [{"id": m} for m in members]
|
||
|
|
return await client.post("/restapi/v1.0/glip/teams", body=body)
|
||
|
|
|
||
|
|
|
||
|
|
async def update_team(
|
||
|
|
client: AsyncRingCentralClient,
|
||
|
|
team_id: str,
|
||
|
|
*,
|
||
|
|
name: str | None = None,
|
||
|
|
description: str | None = None,
|
||
|
|
) -> dict:
|
||
|
|
body = {}
|
||
|
|
if name is not None:
|
||
|
|
body["name"] = name
|
||
|
|
if description is not None:
|
||
|
|
body["description"] = description
|
||
|
|
return await client.patch(f"/restapi/v1.0/glip/teams/{team_id}", body=body)
|
||
|
|
|
||
|
|
|
||
|
|
async def delete_team(client: AsyncRingCentralClient, team_id: str) -> None:
|
||
|
|
await client.delete(f"/restapi/v1.0/glip/teams/{team_id}")
|
||
|
|
|
||
|
|
|
||
|
|
async def add_team_members(
|
||
|
|
client: AsyncRingCentralClient,
|
||
|
|
chat_id: str,
|
||
|
|
members: list[str],
|
||
|
|
) -> dict:
|
||
|
|
body = {"members": [{"id": m} for m in members]}
|
||
|
|
return await client.post(f"/restapi/v1.0/glip/teams/{chat_id}/add", body=body)
|
||
|
|
|
||
|
|
|
||
|
|
async def archive_team(client: AsyncRingCentralClient, chat_id: str) -> None:
|
||
|
|
await client.post(f"/restapi/v1.0/glip/teams/{chat_id}/archive")
|