56 lines
1.2 KiB
Python
56 lines
1.2 KiB
Python
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
import logging
|
||
|
|
|
||
|
|
from yuxi.channel.extensions.ringcentral.sdk import AsyncRingCentralClient
|
||
|
|
|
||
|
|
logger = logging.getLogger(__name__)
|
||
|
|
|
||
|
|
|
||
|
|
async def list_notes(
|
||
|
|
client: AsyncRingCentralClient,
|
||
|
|
chat_id: str,
|
||
|
|
) -> dict:
|
||
|
|
return await client.get(f"/restapi/v1.0/glip/chats/{chat_id}/notes")
|
||
|
|
|
||
|
|
|
||
|
|
async def create_note(
|
||
|
|
client: AsyncRingCentralClient,
|
||
|
|
chat_id: str,
|
||
|
|
title: str,
|
||
|
|
body: str,
|
||
|
|
) -> dict:
|
||
|
|
return await client.post(
|
||
|
|
f"/restapi/v1.0/glip/chats/{chat_id}/notes",
|
||
|
|
body={"title": title, "body": body},
|
||
|
|
)
|
||
|
|
|
||
|
|
|
||
|
|
async def get_note(
|
||
|
|
client: AsyncRingCentralClient,
|
||
|
|
note_id: str,
|
||
|
|
) -> dict:
|
||
|
|
return await client.get(f"/restapi/v1.0/glip/notes/{note_id}")
|
||
|
|
|
||
|
|
|
||
|
|
async def update_note(
|
||
|
|
client: AsyncRingCentralClient,
|
||
|
|
note_id: str,
|
||
|
|
*,
|
||
|
|
title: str | None = None,
|
||
|
|
body: str | None = None,
|
||
|
|
) -> dict:
|
||
|
|
payload = {}
|
||
|
|
if title is not None:
|
||
|
|
payload["title"] = title
|
||
|
|
if body is not None:
|
||
|
|
payload["body"] = body
|
||
|
|
return await client.patch(
|
||
|
|
f"/restapi/v1.0/glip/notes/{note_id}",
|
||
|
|
body=payload,
|
||
|
|
)
|
||
|
|
|
||
|
|
|
||
|
|
async def delete_note(client: AsyncRingCentralClient, note_id: str) -> None:
|
||
|
|
await client.delete(f"/restapi/v1.0/glip/notes/{note_id}")
|