xmes-dingtalk-connectflow-sdk 1.0.0__py3-none-any.whl → 1.0.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- DingtalkConnectflowSDk/__init__.py +3 -3
- DingtalkConnectflowSDk/_table/_types.py +103 -0
- DingtalkConnectflowSDk/_table/table.py +187 -0
- DingtalkConnectflowSDk/_types.py +10 -0
- DingtalkConnectflowSDk/complex_table.py +82 -193
- {xmes_dingtalk_connectflow_sdk-1.0.0.dist-info → xmes_dingtalk_connectflow_sdk-1.0.2.dist-info}/LICENSE +21 -21
- {xmes_dingtalk_connectflow_sdk-1.0.0.dist-info → xmes_dingtalk_connectflow_sdk-1.0.2.dist-info}/METADATA +10 -7
- xmes_dingtalk_connectflow_sdk-1.0.2.dist-info/RECORD +9 -0
- xmes_dingtalk_connectflow_sdk-1.0.0.dist-info/RECORD +0 -6
- {xmes_dingtalk_connectflow_sdk-1.0.0.dist-info → xmes_dingtalk_connectflow_sdk-1.0.2.dist-info}/WHEEL +0 -0
@@ -1,3 +1,3 @@
|
|
1
|
-
__version__ = '1.0.
|
2
|
-
|
3
|
-
from .complex_table import
|
1
|
+
__version__ = '1.0.2'
|
2
|
+
|
3
|
+
from .complex_table import ComplexTable # noqa: F401
|
@@ -0,0 +1,103 @@
|
|
1
|
+
import json
|
2
|
+
from copy import deepcopy
|
3
|
+
from dataclasses import dataclass
|
4
|
+
from typing import Literal
|
5
|
+
|
6
|
+
from .._types import FilteredDataclass
|
7
|
+
|
8
|
+
|
9
|
+
@dataclass
|
10
|
+
class GetterFilter:
|
11
|
+
"""记录筛选器"""
|
12
|
+
|
13
|
+
field: str
|
14
|
+
operator: Literal[
|
15
|
+
'equal', 'notEqual', 'incontain', 'notContain', 'empty', 'notEmpty'
|
16
|
+
]
|
17
|
+
value: list[str] = None
|
18
|
+
|
19
|
+
|
20
|
+
@dataclass
|
21
|
+
class Updater:
|
22
|
+
"""记录更新器"""
|
23
|
+
|
24
|
+
record_id: str
|
25
|
+
fields: dict[str, any]
|
26
|
+
|
27
|
+
def to_dict(self):
|
28
|
+
return self.__dict__
|
29
|
+
|
30
|
+
|
31
|
+
@dataclass
|
32
|
+
class GetterResult(metaclass=FilteredDataclass):
|
33
|
+
"""获取器结果"""
|
34
|
+
|
35
|
+
nextCursor: str = None
|
36
|
+
records: list[dict] = None
|
37
|
+
hasMore: bool = False
|
38
|
+
|
39
|
+
def __post_init__(self):
|
40
|
+
if self.records and isinstance(self.records, list):
|
41
|
+
self.records = self.__records_handle()
|
42
|
+
|
43
|
+
def __records_handle(self):
|
44
|
+
records: list[dict] = []
|
45
|
+
for record in self.records:
|
46
|
+
record_temp = {'id': record.get('id'), 'fields': {}}
|
47
|
+
fields: dict = record.get('fields')
|
48
|
+
|
49
|
+
for field_name, field_value in fields.items():
|
50
|
+
_value = deepcopy(field_value)
|
51
|
+
if isinstance(field_value, dict):
|
52
|
+
if 'link' in field_value:
|
53
|
+
_value = field_value.get('link')
|
54
|
+
elif 'name' in field_value:
|
55
|
+
_value = field_value.get('name')
|
56
|
+
|
57
|
+
record_temp['fields'][field_name] = _value
|
58
|
+
|
59
|
+
records.append(record_temp)
|
60
|
+
|
61
|
+
return records
|
62
|
+
|
63
|
+
def to_file(self, file_path: str):
|
64
|
+
"""
|
65
|
+
将数据写出到本地
|
66
|
+
|
67
|
+
Args:
|
68
|
+
file_path: 用于存储数据的文件路径
|
69
|
+
Returns:
|
70
|
+
格式化后的 json 字符串
|
71
|
+
"""
|
72
|
+
|
73
|
+
if not self.records:
|
74
|
+
raise ValueError('数据记录为空, 无法写出')
|
75
|
+
|
76
|
+
json_str = json.dumps(self.records, ensure_ascii=False, indent=2)
|
77
|
+
with open(file_path, 'w', encoding='utf-8') as f:
|
78
|
+
f.write(json_str)
|
79
|
+
|
80
|
+
return json_str
|
81
|
+
|
82
|
+
|
83
|
+
@dataclass
|
84
|
+
class AdderResult(metaclass=FilteredDataclass):
|
85
|
+
"""新增器结果"""
|
86
|
+
|
87
|
+
result: list[str] = None
|
88
|
+
"""新增的记录id列表"""
|
89
|
+
success: bool = None
|
90
|
+
|
91
|
+
|
92
|
+
@dataclass
|
93
|
+
class UpdaterResult(metaclass=FilteredDataclass):
|
94
|
+
"""更新器结果"""
|
95
|
+
|
96
|
+
success: bool = None
|
97
|
+
|
98
|
+
|
99
|
+
@dataclass
|
100
|
+
class DeletorResult(metaclass=FilteredDataclass):
|
101
|
+
"""删除器结果"""
|
102
|
+
|
103
|
+
success: bool = None
|
@@ -0,0 +1,187 @@
|
|
1
|
+
from typing import Any, Literal
|
2
|
+
|
3
|
+
from requests import post
|
4
|
+
|
5
|
+
from ._types import (
|
6
|
+
AdderResult,
|
7
|
+
DeletorResult,
|
8
|
+
GetterFilter,
|
9
|
+
GetterResult,
|
10
|
+
Updater,
|
11
|
+
UpdaterResult,
|
12
|
+
)
|
13
|
+
|
14
|
+
|
15
|
+
class Table:
|
16
|
+
__HEADERS = {
|
17
|
+
'Content-Type': 'application/json',
|
18
|
+
}
|
19
|
+
|
20
|
+
def __init__(self, flow_url: str, did: str, tid: str):
|
21
|
+
self.flow_url = flow_url
|
22
|
+
self.did = did
|
23
|
+
self.tid = tid
|
24
|
+
self.global_reqdata = {
|
25
|
+
'did': did,
|
26
|
+
'tid': tid,
|
27
|
+
}
|
28
|
+
|
29
|
+
def __verify_records(self, records: list[Any], record_type: object):
|
30
|
+
"""
|
31
|
+
records 参数校验
|
32
|
+
- 校验失败, 抛出 ValueError 异常
|
33
|
+
- 校验成功, 返回清洗后的 records 列表
|
34
|
+
|
35
|
+
Args:
|
36
|
+
records: 记录列表
|
37
|
+
record_type: 记录类型
|
38
|
+
"""
|
39
|
+
|
40
|
+
if not records or not isinstance(records, list):
|
41
|
+
raise ValueError('records 参数需要是列表类型且不能为空')
|
42
|
+
|
43
|
+
records_clean = [
|
44
|
+
record for record in records if record and isinstance(record, record_type)
|
45
|
+
]
|
46
|
+
if not records_clean:
|
47
|
+
record_type_name = record_type.__qualname__
|
48
|
+
raise ValueError(
|
49
|
+
f'records 列表经过判断清洗后, 未在其中找到有效的 {record_type_name}'
|
50
|
+
)
|
51
|
+
|
52
|
+
return records_clean
|
53
|
+
|
54
|
+
def get(
|
55
|
+
self,
|
56
|
+
size=20,
|
57
|
+
cursor: str = '',
|
58
|
+
combination: Literal['and', 'or'] = 'and',
|
59
|
+
filters: list[GetterFilter] | None = None,
|
60
|
+
):
|
61
|
+
"""
|
62
|
+
获取表格数据
|
63
|
+
Args:
|
64
|
+
size: 每页数据条数, 默认为 20
|
65
|
+
cursor: 分页游标, 首次请求可不传, 后续需传入上一次返回的 nextCursor 值
|
66
|
+
combination: 组合方式
|
67
|
+
filters: 过滤条件
|
68
|
+
Returns:
|
69
|
+
GetterResult 对象
|
70
|
+
"""
|
71
|
+
|
72
|
+
reqdata = {
|
73
|
+
**self.global_reqdata,
|
74
|
+
'handle': 'GET',
|
75
|
+
'handle_get': {
|
76
|
+
'size': size,
|
77
|
+
'cursor': cursor,
|
78
|
+
},
|
79
|
+
}
|
80
|
+
|
81
|
+
if combination and combination in ['and', 'or']:
|
82
|
+
filter_field = {}
|
83
|
+
filter_field['combination'] = combination
|
84
|
+
if filters and isinstance(filters, list):
|
85
|
+
conditions = [
|
86
|
+
item.__dict__ for item in filters if isinstance(item, GetterFilter)
|
87
|
+
]
|
88
|
+
filter_field['conditions'] = conditions
|
89
|
+
reqdata['handle_get']['filter'] = filter_field
|
90
|
+
|
91
|
+
resp = post(self.flow_url, json=reqdata, headers=self.__HEADERS)
|
92
|
+
resp_json: dict = resp.json()
|
93
|
+
result: dict = resp_json.get('GET_RESULT')
|
94
|
+
if not result or not isinstance(result, dict):
|
95
|
+
raise ValueError('返回的数据中未找到 GET_RESULT 字段或该字段非字典类型')
|
96
|
+
|
97
|
+
getter_result = GetterResult(**result)
|
98
|
+
|
99
|
+
return getter_result
|
100
|
+
|
101
|
+
def add(self, records: list[dict]):
|
102
|
+
"""
|
103
|
+
新增记录
|
104
|
+
Args:
|
105
|
+
records: 用于新增的记录列表
|
106
|
+
Returns:
|
107
|
+
AdderResult 对象
|
108
|
+
"""
|
109
|
+
|
110
|
+
records_clean = self.__verify_records(records, dict)
|
111
|
+
|
112
|
+
reqdata = {
|
113
|
+
**self.global_reqdata,
|
114
|
+
'handle': 'ADD',
|
115
|
+
'handle_add': {
|
116
|
+
'records': records_clean,
|
117
|
+
},
|
118
|
+
}
|
119
|
+
|
120
|
+
resp = post(self.flow_url, json=reqdata, headers=self.__HEADERS)
|
121
|
+
resp_json: dict = resp.json()
|
122
|
+
result: dict = resp_json.get('ADD_RESULT')
|
123
|
+
if not result or not isinstance(result, dict):
|
124
|
+
raise ValueError('返回的数据中未找到 ADD_RESULT 字段或该字段非字典类型')
|
125
|
+
|
126
|
+
adder_result = AdderResult(**result)
|
127
|
+
|
128
|
+
return adder_result
|
129
|
+
|
130
|
+
def update(self, records: list[Updater]):
|
131
|
+
"""
|
132
|
+
更新记录
|
133
|
+
Args:
|
134
|
+
records: 更新记录列表
|
135
|
+
Returns:
|
136
|
+
UpdaterResult 对象
|
137
|
+
"""
|
138
|
+
|
139
|
+
records_clean: list[Updater] = self.__verify_records(records, Updater)
|
140
|
+
records_clean = [record.to_dict() for record in records_clean]
|
141
|
+
|
142
|
+
reqdata = {
|
143
|
+
**self.global_reqdata,
|
144
|
+
'handle': 'UPDATE',
|
145
|
+
'handle_update': {
|
146
|
+
'records': records_clean,
|
147
|
+
},
|
148
|
+
}
|
149
|
+
|
150
|
+
resp = post(self.flow_url, json=reqdata, headers=self.__HEADERS)
|
151
|
+
resp_json: dict = resp.json()
|
152
|
+
result: dict = resp_json.get('UPDATE_RESULT')
|
153
|
+
if not result or not isinstance(result, dict):
|
154
|
+
raise ValueError('返回的数据中未找到 UPDATE_RESULT 字段或该字段非字典类型')
|
155
|
+
|
156
|
+
updater_result = UpdaterResult(**result)
|
157
|
+
|
158
|
+
return updater_result
|
159
|
+
|
160
|
+
def delete(self, record_ids: list[str]):
|
161
|
+
"""
|
162
|
+
删除记录
|
163
|
+
Args:
|
164
|
+
record_ids: 记录 id 列表
|
165
|
+
Returns:
|
166
|
+
DeletorResult 对象
|
167
|
+
"""
|
168
|
+
|
169
|
+
record_ids_clean = self.__verify_records(record_ids, str)
|
170
|
+
|
171
|
+
reqdata = {
|
172
|
+
**self.global_reqdata,
|
173
|
+
'handle': 'DELETE',
|
174
|
+
'handle_delete': {
|
175
|
+
'record_ids': record_ids_clean,
|
176
|
+
},
|
177
|
+
}
|
178
|
+
|
179
|
+
resp = post(self.flow_url, json=reqdata, headers=self.__HEADERS)
|
180
|
+
resp_json: dict = resp.json()
|
181
|
+
result: dict = resp_json.get('DELETE_RESULT')
|
182
|
+
if not result or not isinstance(result, dict):
|
183
|
+
raise ValueError('返回的数据中未找到 DELETE_RESULT 字段或该字段非字典类型')
|
184
|
+
|
185
|
+
deletor_result = DeletorResult(**result)
|
186
|
+
|
187
|
+
return deletor_result
|
@@ -0,0 +1,10 @@
|
|
1
|
+
from dataclasses import fields
|
2
|
+
|
3
|
+
|
4
|
+
class FilteredDataclass(type):
|
5
|
+
"""过滤kwargs中多余的键"""
|
6
|
+
|
7
|
+
def __call__(cls, *args, **kwargs):
|
8
|
+
valid_fields = {f.name for f in fields(cls)}
|
9
|
+
kwargs = {k: v for k, v in kwargs.items() if k in valid_fields}
|
10
|
+
return super().__call__(*args, **kwargs)
|
@@ -1,193 +1,82 @@
|
|
1
|
-
"""
|
2
|
-
Copyright (c) 2024-now LeslieLiang All rights reserved.
|
3
|
-
Build Date: 2024-12-18
|
4
|
-
Author: LeslieLiang
|
5
|
-
Description: 多维表连接流SDK
|
6
|
-
"""
|
7
|
-
|
8
|
-
from dataclasses import dataclass
|
9
|
-
from
|
10
|
-
|
11
|
-
from
|
12
|
-
|
13
|
-
|
14
|
-
@dataclass
|
15
|
-
class
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
"""
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
def add(self, records: list[dict]):
|
84
|
-
"""
|
85
|
-
新增记录
|
86
|
-
Args:
|
87
|
-
records: 新增记录列表
|
88
|
-
Returns:
|
89
|
-
新增记录结果
|
90
|
-
"""
|
91
|
-
|
92
|
-
if not records or not isinstance(records, list):
|
93
|
-
raise ValueError('records must be a list')
|
94
|
-
|
95
|
-
records_clean = [
|
96
|
-
record for record in records if record and isinstance(record, dict)
|
97
|
-
]
|
98
|
-
if not records_clean:
|
99
|
-
raise ValueError('records must not be empty')
|
100
|
-
|
101
|
-
reqdata = {
|
102
|
-
**self.global_reqdata,
|
103
|
-
'handle': 'ADD',
|
104
|
-
'handle_add': {
|
105
|
-
'records': records_clean,
|
106
|
-
},
|
107
|
-
}
|
108
|
-
|
109
|
-
resp = post(self.flow_url, json=reqdata, headers=self.__HEADERS)
|
110
|
-
return resp.json().get('ADD_RESULT')
|
111
|
-
|
112
|
-
def update(self, records: list[Updater]):
|
113
|
-
"""
|
114
|
-
更新记录
|
115
|
-
Args:
|
116
|
-
records: 更新记录列表
|
117
|
-
Returns:
|
118
|
-
更新记录结果
|
119
|
-
"""
|
120
|
-
|
121
|
-
if not records or not isinstance(records, list):
|
122
|
-
raise ValueError('records must be a list')
|
123
|
-
|
124
|
-
records_clean = [
|
125
|
-
record.__dict__
|
126
|
-
for record in records
|
127
|
-
if record and isinstance(record, Updater)
|
128
|
-
]
|
129
|
-
if not records_clean:
|
130
|
-
raise ValueError('records must not be empty')
|
131
|
-
|
132
|
-
reqdata = {
|
133
|
-
**self.global_reqdata,
|
134
|
-
'handle': 'UPDATE',
|
135
|
-
'handle_update': {
|
136
|
-
'records': records_clean,
|
137
|
-
},
|
138
|
-
}
|
139
|
-
|
140
|
-
resp = post(self.flow_url, json=reqdata, headers=self.__HEADERS)
|
141
|
-
return resp.json().get('UPDATE_RESULT')
|
142
|
-
|
143
|
-
def delete(self, record_ids: list[str]):
|
144
|
-
"""
|
145
|
-
删除记录
|
146
|
-
Args:
|
147
|
-
record_ids: 记录 id 列表
|
148
|
-
Returns:
|
149
|
-
删除记录结果
|
150
|
-
"""
|
151
|
-
|
152
|
-
if not record_ids or not isinstance(record_ids, list):
|
153
|
-
raise ValueError('record_ids must be a list')
|
154
|
-
|
155
|
-
record_ids_clean = [
|
156
|
-
record_id
|
157
|
-
for record_id in record_ids
|
158
|
-
if record_id and isinstance(record_id, str)
|
159
|
-
]
|
160
|
-
|
161
|
-
reqdata = {
|
162
|
-
**self.global_reqdata,
|
163
|
-
'handle': 'DELETE',
|
164
|
-
'handle_delete': {
|
165
|
-
'record_ids': record_ids_clean,
|
166
|
-
},
|
167
|
-
}
|
168
|
-
|
169
|
-
resp = post(self.flow_url, json=reqdata, headers=self.__HEADERS)
|
170
|
-
return resp.json().get('DELETE_RESULT')
|
171
|
-
|
172
|
-
|
173
|
-
class ComplexTable:
|
174
|
-
def __init__(self, flow_url: str):
|
175
|
-
"""
|
176
|
-
初始化 ComplexTable 类
|
177
|
-
Args:
|
178
|
-
flow_url: 连接流 url
|
179
|
-
"""
|
180
|
-
|
181
|
-
self.flow_url = flow_url
|
182
|
-
|
183
|
-
def get_table(self, did: str, tid: str) -> Table:
|
184
|
-
"""
|
185
|
-
获取表格对象
|
186
|
-
Args:
|
187
|
-
did: 文档 id
|
188
|
-
tid: 数据表 id
|
189
|
-
Returns:
|
190
|
-
Table 对象
|
191
|
-
"""
|
192
|
-
|
193
|
-
return Table(self.flow_url, did, tid)
|
1
|
+
"""
|
2
|
+
Copyright (c) 2024-now LeslieLiang All rights reserved.
|
3
|
+
Build Date: 2024-12-18
|
4
|
+
Author: LeslieLiang
|
5
|
+
Description: 多维表连接流SDK
|
6
|
+
"""
|
7
|
+
|
8
|
+
from dataclasses import dataclass
|
9
|
+
from urllib.parse import parse_qs, urlparse
|
10
|
+
|
11
|
+
from ._table.table import Table
|
12
|
+
|
13
|
+
|
14
|
+
@dataclass
|
15
|
+
class ViewUrl:
|
16
|
+
"""视图链接对象"""
|
17
|
+
|
18
|
+
url: str = None
|
19
|
+
did: str = None
|
20
|
+
"""文档id"""
|
21
|
+
tid: str = None
|
22
|
+
"""数据表id"""
|
23
|
+
|
24
|
+
|
25
|
+
class ComplexTable:
|
26
|
+
def __init__(self, flow_url: str):
|
27
|
+
"""
|
28
|
+
初始化 ComplexTable 类
|
29
|
+
Args:
|
30
|
+
flow_url: 连接流 url
|
31
|
+
"""
|
32
|
+
|
33
|
+
self.flow_url = flow_url
|
34
|
+
|
35
|
+
def _parse_view_url(self, view_url: str):
|
36
|
+
"""
|
37
|
+
解析视图链接
|
38
|
+
|
39
|
+
Args:
|
40
|
+
view_url: 视图链接
|
41
|
+
Returns:
|
42
|
+
ViewUrl 对象
|
43
|
+
"""
|
44
|
+
|
45
|
+
if not view_url or not isinstance(view_url, str):
|
46
|
+
raise ValueError('view_url 参数不能为空或非字符串类型')
|
47
|
+
|
48
|
+
parsed_url = urlparse(view_url)
|
49
|
+
url_path_splited = parsed_url.path.split('/')
|
50
|
+
did = url_path_splited[-1]
|
51
|
+
|
52
|
+
query_dict = {k: v[0] for k, v in parse_qs(parsed_url.query).items()}
|
53
|
+
iframeQuery = query_dict.get('iframeQuery')
|
54
|
+
tid = parse_qs(iframeQuery).get('sheetId')[0]
|
55
|
+
|
56
|
+
return ViewUrl(url=view_url, did=did, tid=tid)
|
57
|
+
|
58
|
+
def get_table(self, did: str, tid: str) -> Table:
|
59
|
+
"""
|
60
|
+
获取表格对象
|
61
|
+
Args:
|
62
|
+
did: 文档 id
|
63
|
+
tid: 数据表 id
|
64
|
+
Returns:
|
65
|
+
Table 对象
|
66
|
+
"""
|
67
|
+
|
68
|
+
return Table(self.flow_url, did, tid)
|
69
|
+
|
70
|
+
def get_table_by_view_url(self, url: str):
|
71
|
+
"""
|
72
|
+
通过视图链接获取表格对象
|
73
|
+
- 解析视图链接获取其中的文档id和视图id
|
74
|
+
|
75
|
+
Args:
|
76
|
+
url: 视图链接
|
77
|
+
Returns:
|
78
|
+
Table 对象
|
79
|
+
"""
|
80
|
+
|
81
|
+
view_url = self._parse_view_url(view_url=url)
|
82
|
+
return self.get_table(did=view_url.did, tid=view_url.tid)
|
@@ -1,21 +1,21 @@
|
|
1
|
-
MIT License
|
2
|
-
|
3
|
-
Copyright (c) 2024 Martian Bugs
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
13
|
-
copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
-
SOFTWARE.
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2024 Martian Bugs
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: xmes-dingtalk-connectflow-sdk
|
3
|
-
Version: 1.0.
|
3
|
+
Version: 1.0.2
|
4
4
|
Summary: DingTalk Connection Platform Connection Flow SDK
|
5
5
|
License: MIT
|
6
6
|
Author: leslieliang
|
@@ -16,7 +16,7 @@ Requires-Dist: requests (>=2.32.3,<3.0.0)
|
|
16
16
|
Description-Content-Type: text/markdown
|
17
17
|
|
18
18
|
## 概述
|
19
|
-

|
20
20
|

|
21
21
|
|
22
22
|
`xmes-dingtalk-connectflow-sdk` 是钉钉连接平台自建连接流SDK(向美而生),通过该工具可以方便快捷的调用钉钉的连接流。
|
@@ -33,35 +33,38 @@ pip install xmes-dingtalk-connectflow-sdk
|
|
33
33
|
### ComplexTable
|
34
34
|
该工具提供了连接流 `多维表CURD_241217` 的操作调用工具。
|
35
35
|
```python
|
36
|
-
from DingtalkConnectflowSDK import ComplexTable
|
36
|
+
from DingtalkConnectflowSDK import ComplexTable
|
37
|
+
from DingtalkConnectflowSDk._table._types import GetterFilter, Updater
|
37
38
|
|
38
39
|
# 初始化ComplexTable对象
|
39
40
|
complextable = ComplexTable(flow_url='<连接流的同步协调URL>')
|
40
41
|
|
41
42
|
# 获取 Table 对象
|
42
43
|
table = complextable.get_table(did='<文档ID>', tid='<数据表ID>')
|
44
|
+
# 或者直接传入视图链接
|
45
|
+
# table = complextable.get_table_by_view_url(url='<视图链接>')
|
43
46
|
|
44
47
|
# 查询数据
|
45
48
|
filters = [
|
46
49
|
GetterFilter(field='来源', operator='equal', value=['SDK', 'API'])
|
47
50
|
]
|
48
|
-
|
51
|
+
result = table.get(size=10, fillters=filters)
|
49
52
|
|
50
53
|
# 新增数据
|
51
54
|
records = [
|
52
55
|
{'标题': 'Test Record 1', '来源': 'SDK},
|
53
56
|
{'标题': 'Test Record 2', '来源': 'SDK},
|
54
57
|
]
|
55
|
-
|
58
|
+
result = table.add(records)
|
56
59
|
|
57
60
|
# 更新数据
|
58
61
|
records = [
|
59
62
|
Updater(record_id='<记录ID>', fields={'来源': 'API'}),
|
60
63
|
Updater(record_id='<记录ID>', fields={'来源': 'API'}),
|
61
64
|
]
|
62
|
-
|
65
|
+
result = table.update(records)
|
63
66
|
|
64
67
|
# 删除数据
|
65
68
|
record_ids = ['<记录ID>', '<记录ID>']
|
66
|
-
|
69
|
+
result = table.delete(record_ids)
|
67
70
|
```
|
@@ -0,0 +1,9 @@
|
|
1
|
+
DingtalkConnectflowSDk/__init__.py,sha256=jnOiabDzIV6eXluD6SWo1DpaesB7a-lbg_CGpKAJJDs,77
|
2
|
+
DingtalkConnectflowSDk/_table/_types.py,sha256=HGqKMhOk996fEYyFCq9R4l4pYHods-T_R8uV2hfd4ac,2438
|
3
|
+
DingtalkConnectflowSDk/_table/table.py,sha256=prr7dAzKox8I4CrzWDMjB5Pr3HF4eafzmQXPaZ_wkNM,5568
|
4
|
+
DingtalkConnectflowSDk/_types.py,sha256=TnJI3HHXVObasHWWdqBkX9n-N5E1IENmx7a4k0ehbdk,317
|
5
|
+
DingtalkConnectflowSDk/complex_table.py,sha256=96yQ-bq2FXBt_zxKdHT9y5qn_XXVa9Wg8aH1nxNOeFY,1974
|
6
|
+
xmes_dingtalk_connectflow_sdk-1.0.2.dist-info/LICENSE,sha256=ofcWXcFPprzNE-4OVMRppECrnnvDFvuUHOTtlXR3XhA,1069
|
7
|
+
xmes_dingtalk_connectflow_sdk-1.0.2.dist-info/METADATA,sha256=nfeZ_1tfcfQqoT4TSm_v0GMRcZ4HQ_JTZuth0qxUpBM,2156
|
8
|
+
xmes_dingtalk_connectflow_sdk-1.0.2.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
9
|
+
xmes_dingtalk_connectflow_sdk-1.0.2.dist-info/RECORD,,
|
@@ -1,6 +0,0 @@
|
|
1
|
-
DingtalkConnectflowSDk/__init__.py,sha256=s2BgEZj3tpumNOOqD46MPX5DwUB3NuZnh3BQ3Yqbbac,69
|
2
|
-
DingtalkConnectflowSDk/complex_table.py,sha256=CvqjGcx3OS8KO-tQH1uEOjw6wNCux_LTX7l5t8UjEKo,5203
|
3
|
-
xmes_dingtalk_connectflow_sdk-1.0.0.dist-info/LICENSE,sha256=pLVhl_GNSUPILCWP8DLtqZXytsqXr1lfPp4RwXXypZc,1090
|
4
|
-
xmes_dingtalk_connectflow_sdk-1.0.0.dist-info/METADATA,sha256=PPrsvGWsGdNg4X5OjLmlXxBeQoaFokmdPuyedBVNGl0,2000
|
5
|
-
xmes_dingtalk_connectflow_sdk-1.0.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
6
|
-
xmes_dingtalk_connectflow_sdk-1.0.0.dist-info/RECORD,,
|
File without changes
|