jpsclient 2.4.1 → 2.7.0
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.
- checksums.yaml +4 -4
- data/lib/jpsclient/api/bug.rb +26 -0
- data/lib/jpsclient/api/category.rb +16 -206
- data/lib/jpsclient/api/lark_task.rb +71 -0
- data/lib/jpsclient/api/material.rb +353 -0
- data/lib/jpsclient/api/project_package.rb +2 -2
- data/lib/jpsclient/auth/auth.rb +194 -579
- data/lib/jpsclient/auth/endpoints.rb +46 -0
- data/lib/jpsclient/auth/token.rb +157 -114
- data/lib/jpsclient/base/client.rb +12 -6
- data/lib/jpsclient/http/http_client.rb +25 -11
- data/lib/jpsclient/upload/upload_client.rb +5 -5
- data/lib/jpsclient/utils/debug.rb +20 -0
- data/lib/jpsclient/utils/logger.rb +1 -1
- data/lib/jpsclient/version.rb +1 -1
- data/lib/jpsclient.rb +3 -0
- metadata +11 -10
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4c96b5ac6d4cc1926b3ed272182eb162381f858180369c2c1c0a119937ce1dc4
|
|
4
|
+
data.tar.gz: 1ff46ef1dbc14c78ebc34eafa722402299d51f5685f4b949256c533690c4883e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b042d80d7475b6d3477ba406a52343899e8557270db0de0845304a4d9c8a88326be30fa2eb61d345401b0746cda2413e19e088806facfceeca7535437f120401
|
|
7
|
+
data.tar.gz: e0ad15a3b46d560381c4b51330dc599eabb2a46b00fa1de50428f0c30458fdedc09bcd2d3d403bf9a26eff14a31e9c56d0480f8b510acadb0f504931ef073d72
|
data/lib/jpsclient/api/bug.rb
CHANGED
|
@@ -81,6 +81,32 @@ module JPSClient
|
|
|
81
81
|
|
|
82
82
|
return request_with_auth(:get, path, params: params)
|
|
83
83
|
end
|
|
84
|
+
|
|
85
|
+
# 下发 bug 列表筛选字段
|
|
86
|
+
#
|
|
87
|
+
# @param params [Hash] 请求参数(FieldsOptionsDto: sourceId, sourceType)
|
|
88
|
+
# @return [Hash] API响应
|
|
89
|
+
def get_filter_options(params: {})
|
|
90
|
+
config = @request_config && @request_config["bug_filter_options"]
|
|
91
|
+
raise JPSClient::ExceptionError, "Missing config for bug_filter_options" unless config && config["url"]
|
|
92
|
+
|
|
93
|
+
path = config["url"]
|
|
94
|
+
|
|
95
|
+
return request_with_auth(:get, path, params: params)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# 个人 bug 统计
|
|
99
|
+
#
|
|
100
|
+
# @param params [Hash] 请求参数(ProjectBugStatisticDto: larkUserIds 等)
|
|
101
|
+
# @return [Hash] API响应
|
|
102
|
+
def get_statistics(params: {})
|
|
103
|
+
config = @request_config && @request_config["bug_statistics"]
|
|
104
|
+
raise JPSClient::ExceptionError, "Missing config for bug_statistics" unless config && config["url"]
|
|
105
|
+
|
|
106
|
+
path = config["url"]
|
|
107
|
+
|
|
108
|
+
return request_with_auth(:get, path, params: params)
|
|
109
|
+
end
|
|
84
110
|
end
|
|
85
111
|
end
|
|
86
112
|
end
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
module JPSClient
|
|
2
2
|
module API
|
|
3
3
|
# Category 相关 API
|
|
4
|
-
#
|
|
4
|
+
# 通用分类管理接口 (/api/category,分类 controller)
|
|
5
5
|
module Category
|
|
6
6
|
|
|
7
|
-
#
|
|
7
|
+
# 分类列表
|
|
8
8
|
#
|
|
9
|
-
# @param params [Hash]
|
|
10
|
-
#
|
|
11
|
-
# - parent_id: 父分类ID(可选)
|
|
12
|
-
# @return [Hash] API响应
|
|
9
|
+
# @param params [Hash] CategoryListDto: type(分类类型), platforms(平台,可多个)
|
|
10
|
+
# @return [Hash] API响应,data: { list: [Category], count }
|
|
13
11
|
def get_category_list(params: {})
|
|
14
12
|
config = @request_config && @request_config["category_list"]
|
|
15
13
|
raise JPSClient::ExceptionError, "Missing config for category_list" unless config && config["url"]
|
|
@@ -19,12 +17,10 @@ module JPSClient
|
|
|
19
17
|
return request_with_auth(:get, path, params: params)
|
|
20
18
|
end
|
|
21
19
|
|
|
22
|
-
#
|
|
20
|
+
# 分类树
|
|
23
21
|
#
|
|
24
|
-
# @param params [Hash]
|
|
25
|
-
#
|
|
26
|
-
# - max_level: 最大层级深度(可选)
|
|
27
|
-
# @return [Hash] API响应,包含树形结构数据
|
|
22
|
+
# @param params [Hash] CategoryListDto: type(分类类型), platforms(平台,可多个)
|
|
23
|
+
# @return [Hash] API响应,data: [CategoryTreeVo]
|
|
28
24
|
def get_category_tree(params: {})
|
|
29
25
|
config = @request_config && @request_config["category_tree"]
|
|
30
26
|
raise JPSClient::ExceptionError, "Missing config for category_tree" unless config && config["url"]
|
|
@@ -36,29 +32,12 @@ module JPSClient
|
|
|
36
32
|
|
|
37
33
|
# 创建分类
|
|
38
34
|
#
|
|
39
|
-
# @param params [Hash]
|
|
40
|
-
#
|
|
41
|
-
# - type: 分类类型(必需)
|
|
42
|
-
# - parent_id: 父分类ID(可选,根分类不需要)
|
|
43
|
-
# - icon: 分类图标(可选)
|
|
44
|
-
# - description: 分类描述(可选)
|
|
45
|
-
# - sort_order: 排序值(可选,默认1)
|
|
46
|
-
# @return [Hash] API响应
|
|
35
|
+
# @param params [Hash] CategoryCreateDto: type*, name*, parentId, priority, description, medias, platform
|
|
36
|
+
# @return [Hash] API响应,data: Category
|
|
47
37
|
def create_category(params: {})
|
|
48
38
|
config = @request_config && @request_config["category_create"]
|
|
49
39
|
raise JPSClient::ExceptionError, "Missing config for category_create" unless config && config["url"]
|
|
50
40
|
|
|
51
|
-
# 参数验证
|
|
52
|
-
required_fields = [:name, :type]
|
|
53
|
-
missing_fields = required_fields.select { |field| params[field].nil? || params[field].to_s.empty? }
|
|
54
|
-
|
|
55
|
-
if missing_fields.any?
|
|
56
|
-
raise JPSClient::ExceptionError, "Missing required fields: #{missing_fields.join(', ')}"
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
# 设置默认值
|
|
60
|
-
params[:sort_order] ||= 1
|
|
61
|
-
|
|
62
41
|
path = config["url"]
|
|
63
42
|
|
|
64
43
|
return request_with_auth(:post, path, body: params)
|
|
@@ -66,21 +45,12 @@ module JPSClient
|
|
|
66
45
|
|
|
67
46
|
# 更新分类
|
|
68
47
|
#
|
|
69
|
-
# @param params [Hash]
|
|
70
|
-
#
|
|
71
|
-
# - name: 分类名称
|
|
72
|
-
# - icon: 分类图标
|
|
73
|
-
# - description: 分类描述
|
|
74
|
-
# - sort_order: 排序值
|
|
75
|
-
# - status: 分类状态(1:启用, 0:停用)
|
|
76
|
-
# @return [Hash] API响应
|
|
48
|
+
# @param params [Hash] CategoryUpdateDto: id*, parentId, priority, name, weight, medias, description
|
|
49
|
+
# @return [Hash] API响应,data: Category
|
|
77
50
|
def update_category(params: {})
|
|
78
51
|
config = @request_config && @request_config["category_update"]
|
|
79
52
|
raise JPSClient::ExceptionError, "Missing config for category_update" unless config && config["url"]
|
|
80
53
|
|
|
81
|
-
# ID 是必需的
|
|
82
|
-
raise JPSClient::ExceptionError, "Missing required field: id" unless params[:id]
|
|
83
|
-
|
|
84
54
|
path = config["url"]
|
|
85
55
|
|
|
86
56
|
return request_with_auth(:post, path, body: params)
|
|
@@ -88,190 +58,30 @@ module JPSClient
|
|
|
88
58
|
|
|
89
59
|
# 删除分类
|
|
90
60
|
#
|
|
91
|
-
# @param
|
|
61
|
+
# @param params [Hash] BaseIdDtoInteger: id*
|
|
92
62
|
# @return [Hash] API响应
|
|
93
|
-
def delete_category(
|
|
63
|
+
def delete_category(params: {})
|
|
94
64
|
config = @request_config && @request_config["category_delete"]
|
|
95
65
|
raise JPSClient::ExceptionError, "Missing config for category_delete" unless config && config["url"]
|
|
96
66
|
|
|
97
67
|
path = config["url"]
|
|
98
68
|
|
|
99
|
-
# POST请求,ID作为body参数
|
|
100
|
-
params = { id: id }
|
|
101
|
-
|
|
102
69
|
return request_with_auth(:post, path, body: params)
|
|
103
70
|
end
|
|
104
71
|
|
|
105
72
|
# 分类排序
|
|
106
73
|
#
|
|
107
|
-
# @param
|
|
108
|
-
# 每个项包含:
|
|
109
|
-
# - id: 分类ID
|
|
110
|
-
# - sort_order: 新的排序值
|
|
74
|
+
# @param params [Array] CategorySortDto 数组,每项: id*, weight*, parentId(前端以裸数组体提交)
|
|
111
75
|
# @return [Hash] API响应
|
|
112
|
-
def sort_categories(
|
|
76
|
+
def sort_categories(params: [])
|
|
113
77
|
config = @request_config && @request_config["category_sort"]
|
|
114
78
|
raise JPSClient::ExceptionError, "Missing config for category_sort" unless config && config["url"]
|
|
115
79
|
|
|
116
|
-
if items.empty?
|
|
117
|
-
raise JPSClient::ExceptionError, "Items array cannot be empty"
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
# 验证每个项都有必需的字段
|
|
121
|
-
items.each_with_index do |item, index|
|
|
122
|
-
unless item[:id] || item["id"]
|
|
123
|
-
raise JPSClient::ExceptionError, "Item at index #{index} missing 'id'"
|
|
124
|
-
end
|
|
125
|
-
unless item[:sort_order] || item["sort_order"]
|
|
126
|
-
raise JPSClient::ExceptionError, "Item at index #{index} missing 'sort_order'"
|
|
127
|
-
end
|
|
128
|
-
end
|
|
129
|
-
|
|
130
80
|
path = config["url"]
|
|
131
|
-
params = { items: items }
|
|
132
81
|
|
|
133
82
|
return request_with_auth(:post, path, body: params)
|
|
134
83
|
end
|
|
135
84
|
|
|
136
|
-
# 按类型获取分类列表(便捷方法)
|
|
137
|
-
#
|
|
138
|
-
# @param type [String] 分类类型
|
|
139
|
-
# - application: 应用分类
|
|
140
|
-
# - resource: 资源分类
|
|
141
|
-
# - asset: 素材分类
|
|
142
|
-
# - requirement: 需求分类
|
|
143
|
-
# - sketch: 画板分类
|
|
144
|
-
# - tool: 工具分类
|
|
145
|
-
# - survey: 调研分类
|
|
146
|
-
# - publisher: 发行商分类
|
|
147
|
-
# - experience: 体验分类
|
|
148
|
-
# @param parent_id [String, Integer, nil] 父分类ID
|
|
149
|
-
# @return [Hash] API响应
|
|
150
|
-
def get_categories_by_type(type:, parent_id: nil)
|
|
151
|
-
params = { type: type }
|
|
152
|
-
params[:parent_id] = parent_id if parent_id
|
|
153
|
-
get_category_list(params: params)
|
|
154
|
-
end
|
|
155
|
-
|
|
156
|
-
# 获取某分类的所有子分类
|
|
157
|
-
#
|
|
158
|
-
# @param parent_id [String, Integer] 父分类ID
|
|
159
|
-
# @return [Hash] API响应
|
|
160
|
-
def get_subcategories(parent_id:)
|
|
161
|
-
get_category_list(params: { parent_id: parent_id })
|
|
162
|
-
end
|
|
163
|
-
|
|
164
|
-
# 获取根分类列表
|
|
165
|
-
#
|
|
166
|
-
# @param type [String, nil] 分类类型(可选)
|
|
167
|
-
# @return [Hash] API响应
|
|
168
|
-
def get_root_categories(type: nil)
|
|
169
|
-
params = { parent_id: 0 } # parent_id 为 0 或 null 表示根分类
|
|
170
|
-
params[:type] = type if type
|
|
171
|
-
get_category_list(params: params)
|
|
172
|
-
end
|
|
173
|
-
|
|
174
|
-
# 批量创建分类
|
|
175
|
-
# 注意:此方法会逐个调用 API,返回结果数组
|
|
176
|
-
#
|
|
177
|
-
# @param categories [Array<Hash>] 分类数组
|
|
178
|
-
# @return [Array<Hash>] 每个请求的响应结果
|
|
179
|
-
def batch_create_categories(categories: [])
|
|
180
|
-
return [] if categories.empty?
|
|
181
|
-
|
|
182
|
-
results = []
|
|
183
|
-
categories.each do |category_params|
|
|
184
|
-
result = create_category(params: category_params)
|
|
185
|
-
results << result
|
|
186
|
-
end
|
|
187
|
-
|
|
188
|
-
results
|
|
189
|
-
end
|
|
190
|
-
|
|
191
|
-
# 移动分类到新的父分类
|
|
192
|
-
#
|
|
193
|
-
# @param category_id [String, Integer] 要移动的分类ID
|
|
194
|
-
# @param new_parent_id [String, Integer, nil] 新的父分类ID(nil表示移到根级)
|
|
195
|
-
# @return [Hash] API响应
|
|
196
|
-
def move_category(category_id:, new_parent_id: nil)
|
|
197
|
-
params = {
|
|
198
|
-
id: category_id,
|
|
199
|
-
parent_id: new_parent_id || 0
|
|
200
|
-
}
|
|
201
|
-
update_category(params: params)
|
|
202
|
-
end
|
|
203
|
-
|
|
204
|
-
# 启用分类
|
|
205
|
-
#
|
|
206
|
-
# @param category_id [String, Integer] 分类ID
|
|
207
|
-
# @return [Hash] API响应
|
|
208
|
-
def enable_category(category_id:)
|
|
209
|
-
update_category(params: { id: category_id, status: 1 })
|
|
210
|
-
end
|
|
211
|
-
|
|
212
|
-
# 停用分类
|
|
213
|
-
#
|
|
214
|
-
# @param category_id [String, Integer] 分类ID
|
|
215
|
-
# @return [Hash] API响应
|
|
216
|
-
def disable_category(category_id:)
|
|
217
|
-
update_category(params: { id: category_id, status: 0 })
|
|
218
|
-
end
|
|
219
|
-
|
|
220
|
-
# 构建分类路径
|
|
221
|
-
# 根据分类ID获取从根到该分类的完整路径
|
|
222
|
-
#
|
|
223
|
-
# @param category_id [String, Integer] 分类ID
|
|
224
|
-
# @return [Array<Hash>] 分类路径数组,从根到目标分类
|
|
225
|
-
def get_category_path(category_id:)
|
|
226
|
-
response = get_category_list
|
|
227
|
-
|
|
228
|
-
# 如果请求失败,返回空数组
|
|
229
|
-
return [] unless response && response['data']
|
|
230
|
-
|
|
231
|
-
categories = response['data']['list'] || response['data'][:list] || []
|
|
232
|
-
path = []
|
|
233
|
-
|
|
234
|
-
current_id = category_id.to_s
|
|
235
|
-
while current_id
|
|
236
|
-
category = categories.find { |c|
|
|
237
|
-
(c['id'] || c[:id]).to_s == current_id
|
|
238
|
-
}
|
|
239
|
-
break unless category
|
|
240
|
-
|
|
241
|
-
path.unshift(category)
|
|
242
|
-
current_id = (category['parent_id'] || category[:parent_id])&.to_s
|
|
243
|
-
break if current_id == "0" || current_id.nil?
|
|
244
|
-
end
|
|
245
|
-
|
|
246
|
-
path
|
|
247
|
-
end
|
|
248
|
-
|
|
249
|
-
# 获取分类统计信息
|
|
250
|
-
# 统计某个分类下的直接子分类数量
|
|
251
|
-
#
|
|
252
|
-
# @param category_id [String, Integer] 分类ID
|
|
253
|
-
# @return [Hash] 包含统计数据的哈希
|
|
254
|
-
def get_category_statistics(category_id:)
|
|
255
|
-
response = get_subcategories(parent_id: category_id)
|
|
256
|
-
|
|
257
|
-
# 如果请求失败,返回空统计
|
|
258
|
-
unless response && response['data']
|
|
259
|
-
return {
|
|
260
|
-
category_id: category_id,
|
|
261
|
-
direct_children_count: 0,
|
|
262
|
-
children: []
|
|
263
|
-
}
|
|
264
|
-
end
|
|
265
|
-
|
|
266
|
-
child_list = response['data']['list'] || response['data'][:list] || []
|
|
267
|
-
|
|
268
|
-
{
|
|
269
|
-
category_id: category_id,
|
|
270
|
-
direct_children_count: child_list.size,
|
|
271
|
-
children: child_list
|
|
272
|
-
}
|
|
273
|
-
end
|
|
274
|
-
|
|
275
85
|
end
|
|
276
86
|
end
|
|
277
|
-
end
|
|
87
|
+
end
|
|
@@ -81,6 +81,77 @@ module JPSClient
|
|
|
81
81
|
|
|
82
82
|
return request_with_auth(:get, path, params: params)
|
|
83
83
|
end
|
|
84
|
+
|
|
85
|
+
# 获取有飞书任务的 app 列表
|
|
86
|
+
#
|
|
87
|
+
# @param params [Hash] 请求参数(LarkTaskAppsDto: keyword, larkUserId)
|
|
88
|
+
# @return [Hash] API响应
|
|
89
|
+
def get_apps(params: {})
|
|
90
|
+
config = @request_config && @request_config["lark_task_apps"]
|
|
91
|
+
raise JPSClient::ExceptionError, "Missing config for lark_task_apps" unless config && config["url"]
|
|
92
|
+
|
|
93
|
+
path = config["url"]
|
|
94
|
+
|
|
95
|
+
return request_with_auth(:get, path, params: params)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# 查询当前用户完成的任务和 Bug
|
|
99
|
+
#
|
|
100
|
+
# spec 标注 startTime / endTime 均为 required(int64 毫秒时间戳)。
|
|
101
|
+
#
|
|
102
|
+
# @return [Hash] API响应
|
|
103
|
+
def get_completed_items(start_time: nil, end_time: nil, params: {})
|
|
104
|
+
config = @request_config && @request_config["lark_task_completed_items"]
|
|
105
|
+
raise JPSClient::ExceptionError, "Missing config for lark_task_completed_items" unless config && config["url"]
|
|
106
|
+
|
|
107
|
+
path = config["url"]
|
|
108
|
+
|
|
109
|
+
# TODO(human): 决定如何把 start_time/end_time 与 params 合并成最终的 query
|
|
110
|
+
# 候选策略见对话中的 Learn by Doing 说明,最终需要返回一个能直接交给
|
|
111
|
+
# request_with_auth(:get, path, params: ...) 的 Hash。
|
|
112
|
+
query = nil
|
|
113
|
+
|
|
114
|
+
return request_with_auth(:get, path, params: query)
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
# 任务字段列表
|
|
118
|
+
#
|
|
119
|
+
# @param params [Hash] 请求参数(spec 未声明字段,预留以保持调用风格统一)
|
|
120
|
+
# @return [Hash] API响应
|
|
121
|
+
def get_fields(params: {})
|
|
122
|
+
config = @request_config && @request_config["lark_task_fields"]
|
|
123
|
+
raise JPSClient::ExceptionError, "Missing config for lark_task_fields" unless config && config["url"]
|
|
124
|
+
|
|
125
|
+
path = config["url"]
|
|
126
|
+
|
|
127
|
+
return request_with_auth(:get, path, params: params)
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
# 下发 task 列表筛选字段
|
|
131
|
+
#
|
|
132
|
+
# @param params [Hash] 请求参数(FieldsOptionsDto: sourceId, sourceType)
|
|
133
|
+
# @return [Hash] API响应
|
|
134
|
+
def get_filter_options(params: {})
|
|
135
|
+
config = @request_config && @request_config["lark_task_filter_options"]
|
|
136
|
+
raise JPSClient::ExceptionError, "Missing config for lark_task_filter_options" unless config && config["url"]
|
|
137
|
+
|
|
138
|
+
path = config["url"]
|
|
139
|
+
|
|
140
|
+
return request_with_auth(:get, path, params: params)
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
# 个人任务统计
|
|
144
|
+
#
|
|
145
|
+
# @param params [Hash] 请求参数(ProjectTaskStatisticDto: larkUserIds 等)
|
|
146
|
+
# @return [Hash] API响应
|
|
147
|
+
def get_statistics(params: {})
|
|
148
|
+
config = @request_config && @request_config["lark_task_statistics"]
|
|
149
|
+
raise JPSClient::ExceptionError, "Missing config for lark_task_statistics" unless config && config["url"]
|
|
150
|
+
|
|
151
|
+
path = config["url"]
|
|
152
|
+
|
|
153
|
+
return request_with_auth(:get, path, params: params)
|
|
154
|
+
end
|
|
84
155
|
end
|
|
85
156
|
end
|
|
86
157
|
end
|