From 7e8e34a51157da2ec214cf75b7423cca3a33ae62 Mon Sep 17 00:00:00 2001 From: Alex Happy <1223408988@qq.com> Date: Sat, 11 Mar 2023 12:30:30 +0800 Subject: [PATCH 1/3] add comment apis --- manual/python/base.md | 26 ++++++++ manual/python/comment.md | 130 +++++++++++++++++++++++++++++++++++++++ mkdocs.yml | 1 + 3 files changed, 157 insertions(+) create mode 100644 manual/python/comment.md diff --git a/manual/python/base.md b/manual/python/base.md index 6a6ad56b..cfeb9021 100644 --- a/manual/python/base.md +++ b/manual/python/base.md @@ -20,6 +20,32 @@ base = Base(api_token, server_url) base.auth() ``` +## 以用户身份获取权限 + +使用表格的 API Token 和用户的登录信息获取一个 base 的访问权限 + +有一些 API 需要以用户身份使用,例如评论相关 API + +* 邮箱和密码 +* 手机号和密码 +* login id 和密码 +* 用户名和密码 + +##### 例子 + +```python +from seatable_api import Base, context + +server_url = context.server_url or 'https://cloud.seatable.cn' +api_token = context.api_token or 'c3c75dca2c369849455a39f4436147639cf02b2d' + +login = 'xxx' +password = 'yyy' + +base = Base(api_token, server_url) +base.auth_as_user(login, password) +``` + ## Metadata #### Get metadata diff --git a/manual/python/comment.md b/manual/python/comment.md new file mode 100644 index 00000000..c680191b --- /dev/null +++ b/manual/python/comment.md @@ -0,0 +1,130 @@ +# 行评论 + +以下的方法可以对 Base 内评论进行操作 + +**使用评论相关 API 时请先调用 Base.auth_as_user(login, password) 方法进行用户登录** + +#### Add a comment + +对某行评论 + +```python +base.add_comment(table_id, row_id, comment) +``` + +##### 例子 + +```python +table_id = '0000' +row_id = 'IN6FfRQLR9GAYX-6VHPvvA' +comment = 'comment from seatable-api' + +base.add_comment(table_id, row_id, comment) +``` + +返回 + +```Python +{'success': True} +``` + +#### Get the count number of a row's comments + +获取某行评论数量 + +```python +base.get_comments_count(row_id) +``` + +返回为一个数字 + +#### Get comments of a row + +获取某行评论,支持分页 + +```Python +base.get_comments(row_id, page=1, per_page=25) +``` + +返回 + +```Python +[ + { + 'id': 1, + 'author': '27e19630f2044e1abe9e86e17e4c8418@auth.local', + 'comment': 'comment content', + 'created_at': '2023-03-10T16:09:30+00:00', + 'updated_at': '2023-03-10T16:09:30+00:00', + 'dtable_uuid': '281bb8dc19fb4257ad5feabccc8a9333', + 'row_id': 'R6anZyjkRJK-HGrqkLvVsA', + 'detail': None, + 'resolved': False + } +] +``` + +#### Resolve a comment + +将评论置为已解决 + +```Python +base.resolve_comment(comment_id) +``` + +返回 + +```Python +{'success': True} +``` + +#### Delete a comment + +删除评论 + +```Python +base.delete_comment(comment_id) +``` + +返回 + +```Python +{'success': True} +``` + +#### Get comments of a base within days + +获取 Base 几天内的评论,不止某一行 + +```Python +base.get_comments_within_days(days) +``` + +返回 + +```Python +[ + { + 'id': 1, + 'author': '27e19630f2044e1abe9e86e17e4c8418@auth.local', + 'comment': 'comment content', + 'created_at': '2023-03-10T16:09:30+00:00', + 'updated_at': '2023-03-10T16:09:30+00:00', + 'dtable_uuid': '281bb8dc19fb4257ad5feabccc8a9333', + 'row_id': 'R6anZyjkRJK-HGrqkLvVsA', + 'detail': None, + 'resolved': False + }, + { + 'id': 3, + 'author': '27e19630f2044e1abe9e86e17e4c8418@auth.local', + 'comment': 'comment content on another row', + 'created_at': '2023-03-10T16:09:30+00:00', + 'updated_at': '2023-03-10T16:09:30+00:00', + 'dtable_uuid': '281bb8dc19fb4257ad5feabccc8a9333', + 'row_id': 'Vwnx6xEFS6qjgbhZAUNM7Q', + 'detail': None, + 'resolved': True + } +] +``` diff --git a/mkdocs.yml b/mkdocs.yml index 47b98624..2ca9d992 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -75,6 +75,7 @@ nav: - Constants: python/constants.md - Context: python/context.md - Workflow: python/workflow.md + - Comments: python/comment.md - 日期操作: python/dateutils.md - 云端环境下支持的库: python/libs.md - 消息通知: python/notifications.md From 005e07455f791a2a3b55e0a703ca6e6d41aa1b8e Mon Sep 17 00:00:00 2001 From: AlexCXC <1223408988@qq.com> Date: Mon, 13 Mar 2023 15:44:14 +0800 Subject: [PATCH 2/3] fix getComments sample --- manual/python/comment.md | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/manual/python/comment.md b/manual/python/comment.md index c680191b..b1833e62 100644 --- a/manual/python/comment.md +++ b/manual/python/comment.md @@ -49,19 +49,22 @@ base.get_comments(row_id, page=1, per_page=25) 返回 ```Python -[ - { - 'id': 1, - 'author': '27e19630f2044e1abe9e86e17e4c8418@auth.local', - 'comment': 'comment content', - 'created_at': '2023-03-10T16:09:30+00:00', - 'updated_at': '2023-03-10T16:09:30+00:00', - 'dtable_uuid': '281bb8dc19fb4257ad5feabccc8a9333', - 'row_id': 'R6anZyjkRJK-HGrqkLvVsA', - 'detail': None, - 'resolved': False - } -] +{ + "comment_list": [ + { + 'id': 1, + 'author': '27e19630f2044e1abe9e86e17e4c8418@auth.local', + 'comment': 'comment content', + 'created_at': '2023-03-10T16:09:30+00:00', + 'updated_at': '2023-03-10T16:09:30+00:00', + 'dtable_uuid': '281bb8dc19fb4257ad5feabccc8a9333', + 'row_id': 'R6anZyjkRJK-HGrqkLvVsA', + 'detail': None, + 'resolved': False + } + ], + "count": 1 +} ``` #### Resolve a comment From bb0a0972c03aad191bb953110d5e8d159d072e27 Mon Sep 17 00:00:00 2001 From: AlexCXC <1223408988@qq.com> Date: Mon, 3 Apr 2023 18:30:04 +0800 Subject: [PATCH 3/3] remove add/delete comment apis --- manual/python/base.md | 26 -------------------------- manual/python/comment.md | 40 ---------------------------------------- 2 files changed, 66 deletions(-) diff --git a/manual/python/base.md b/manual/python/base.md index cfeb9021..6a6ad56b 100644 --- a/manual/python/base.md +++ b/manual/python/base.md @@ -20,32 +20,6 @@ base = Base(api_token, server_url) base.auth() ``` -## 以用户身份获取权限 - -使用表格的 API Token 和用户的登录信息获取一个 base 的访问权限 - -有一些 API 需要以用户身份使用,例如评论相关 API - -* 邮箱和密码 -* 手机号和密码 -* login id 和密码 -* 用户名和密码 - -##### 例子 - -```python -from seatable_api import Base, context - -server_url = context.server_url or 'https://cloud.seatable.cn' -api_token = context.api_token or 'c3c75dca2c369849455a39f4436147639cf02b2d' - -login = 'xxx' -password = 'yyy' - -base = Base(api_token, server_url) -base.auth_as_user(login, password) -``` - ## Metadata #### Get metadata diff --git a/manual/python/comment.md b/manual/python/comment.md index b1833e62..d6abc1d1 100644 --- a/manual/python/comment.md +++ b/manual/python/comment.md @@ -2,32 +2,6 @@ 以下的方法可以对 Base 内评论进行操作 -**使用评论相关 API 时请先调用 Base.auth_as_user(login, password) 方法进行用户登录** - -#### Add a comment - -对某行评论 - -```python -base.add_comment(table_id, row_id, comment) -``` - -##### 例子 - -```python -table_id = '0000' -row_id = 'IN6FfRQLR9GAYX-6VHPvvA' -comment = 'comment from seatable-api' - -base.add_comment(table_id, row_id, comment) -``` - -返回 - -```Python -{'success': True} -``` - #### Get the count number of a row's comments 获取某行评论数量 @@ -81,20 +55,6 @@ base.resolve_comment(comment_id) {'success': True} ``` -#### Delete a comment - -删除评论 - -```Python -base.delete_comment(comment_id) -``` - -返回 - -```Python -{'success': True} -``` - #### Get comments of a base within days 获取 Base 几天内的评论,不止某一行