jpsclient 2.2.0 → 2.3.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/android_jks.rb +7 -70
- data/lib/jpsclient/api/app_level.rb +6 -60
- data/lib/jpsclient/api/app_resource.rb +7 -70
- data/lib/jpsclient/api/apple_account.rb +6 -60
- data/lib/jpsclient/api/apple_bundle_id.rb +1 -11
- data/lib/jpsclient/api/apple_cert.rb +1 -11
- data/lib/jpsclient/api/apple_profile.rb +1 -11
- data/lib/jpsclient/api/application.rb +12 -121
- data/lib/jpsclient/api/application_income.rb +2 -20
- data/lib/jpsclient/api/application_sales.rb +2 -20
- data/lib/jpsclient/api/application_version.rb +3 -30
- data/lib/jpsclient/api/archived_outdated/app_resource_version.rb +2 -20
- data/lib/jpsclient/api/archived_outdated/application_category.rb +5 -50
- data/lib/jpsclient/api/archived_outdated/application_design.rb +5 -50
- data/lib/jpsclient/api/archived_outdated/assets_category.rb +5 -50
- data/lib/jpsclient/api/archived_outdated/experience.rb +6 -60
- data/lib/jpsclient/api/archived_outdated/experience_category.rb +4 -40
- data/lib/jpsclient/api/archived_outdated/icon_and_snapshot.rb +2 -20
- data/lib/jpsclient/api/archived_outdated/publisher_category.rb +6 -60
- data/lib/jpsclient/api/archived_outdated/publisher_group_category.rb +5 -50
- data/lib/jpsclient/api/archived_outdated/requirements_category.rb +4 -40
- data/lib/jpsclient/api/archived_outdated/resource_category.rb +5 -50
- data/lib/jpsclient/api/archived_outdated/sketch_category.rb +4 -40
- data/lib/jpsclient/api/archived_outdated/survey_category.rb +4 -40
- data/lib/jpsclient/api/archived_outdated/tool_category.rb +5 -50
- data/lib/jpsclient/api/bug.rb +6 -60
- data/lib/jpsclient/api/category.rb +6 -60
- data/lib/jpsclient/api/cert.rb +1 -12
- data/lib/jpsclient/api/collect.rb +2 -20
- data/lib/jpsclient/api/collection.rb +7 -70
- data/lib/jpsclient/api/commit_log.rb +5 -52
- data/lib/jpsclient/api/creative.rb +2 -20
- data/lib/jpsclient/api/custom_application.rb +10 -100
- data/lib/jpsclient/api/custom_application_web.rb +2 -20
- data/lib/jpsclient/api/design.rb +5 -50
- data/lib/jpsclient/api/document_text.rb +1 -10
- data/lib/jpsclient/api/fgui_export.rb +2 -20
- data/lib/jpsclient/api/file.rb +4 -41
- data/lib/jpsclient/api/game_assets.rb +6 -60
- data/lib/jpsclient/api/healthy.rb +1 -10
- data/lib/jpsclient/api/idea.rb +5 -50
- data/lib/jpsclient/api/image_search.rb +2 -20
- data/lib/jpsclient/api/js_sdk.rb +1 -10
- data/lib/jpsclient/api/lark_bitable.rb +1 -10
- data/lib/jpsclient/api/lark_card_message.rb +1 -10
- data/lib/jpsclient/api/lark_chat_group.rb +1 -10
- data/lib/jpsclient/api/lark_comment.rb +5 -50
- data/lib/jpsclient/api/lark_department.rb +1 -10
- data/lib/jpsclient/api/lark_file.rb +1 -10
- data/lib/jpsclient/api/lark_leave_approval.rb +1 -10
- data/lib/jpsclient/api/lark_message.rb +1 -10
- data/lib/jpsclient/api/lark_task.rb +6 -60
- data/lib/jpsclient/api/lark_task_list.rb +5 -50
- data/lib/jpsclient/api/lark_task_section.rb +3 -30
- data/lib/jpsclient/api/lark_user.rb +1 -10
- data/lib/jpsclient/api/lark_wiki_node.rb +1 -10
- data/lib/jpsclient/api/lark_wiki_space.rb +1 -10
- data/lib/jpsclient/api/lazy_client.rb +39 -39
- data/lib/jpsclient/api/login.rb +4 -40
- data/lib/jpsclient/api/m3u8.rb +1 -10
- data/lib/jpsclient/api/menu.rb +6 -60
- data/lib/jpsclient/api/modular_client.rb +38 -38
- data/lib/jpsclient/api/nuget.rb +1 -10
- data/lib/jpsclient/api/permission.rb +5 -50
- data/lib/jpsclient/api/project.rb +2 -22
- data/lib/jpsclient/api/project_package.rb +9 -121
- data/lib/jpsclient/api/publisher.rb +7 -70
- data/lib/jpsclient/api/publisher_group.rb +5 -50
- data/lib/jpsclient/api/requirements.rb +6 -60
- data/lib/jpsclient/api/role.rb +7 -70
- data/lib/jpsclient/api/simple_search.rb +7 -70
- data/lib/jpsclient/api/sketch.rb +3 -30
- data/lib/jpsclient/api/sov.rb +1 -10
- data/lib/jpsclient/api/statistics.rb +1 -10
- data/lib/jpsclient/api/store.rb +1 -10
- data/lib/jpsclient/api/survey.rb +6 -60
- data/lib/jpsclient/api/tag.rb +6 -60
- data/lib/jpsclient/api/template.rb +5 -50
- data/lib/jpsclient/api/tool.rb +5 -50
- data/lib/jpsclient/api/trending.rb +1 -10
- data/lib/jpsclient/api/ud_id.rb +5 -50
- data/lib/jpsclient/api/user.rb +4 -40
- data/lib/jpsclient/api/util.rb +1 -10
- data/lib/jpsclient/api/video_cover.rb +1 -10
- data/lib/jpsclient/api/webhook.rb +5 -50
- data/lib/jpsclient/api/workflow.rb +5 -50
- data/lib/jpsclient/auth/auth.rb +21 -31
- data/lib/jpsclient/auth/token.rb +49 -95
- data/lib/jpsclient/base/client.rb +43 -38
- data/lib/jpsclient/http/http_client.rb +18 -2
- data/lib/jpsclient/version.rb +1 -1
- metadata +15 -1
data/lib/jpsclient/api/login.rb
CHANGED
|
@@ -14,16 +14,7 @@ module JPSClient
|
|
|
14
14
|
|
|
15
15
|
path = config["url"]
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
result = JPSClient::Response.new(response)
|
|
19
|
-
|
|
20
|
-
if result.need_login?
|
|
21
|
-
do_login(force_login: true)
|
|
22
|
-
response = @http_client.post(path, body: params)
|
|
23
|
-
result = JPSClient::Response.new(response)
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
return result.to_h
|
|
17
|
+
return request_with_auth(:post, path, body: params)
|
|
27
18
|
end
|
|
28
19
|
|
|
29
20
|
# Create Lark Login
|
|
@@ -36,16 +27,7 @@ module JPSClient
|
|
|
36
27
|
|
|
37
28
|
path = config["url"]
|
|
38
29
|
|
|
39
|
-
|
|
40
|
-
result = JPSClient::Response.new(response)
|
|
41
|
-
|
|
42
|
-
if result.need_login?
|
|
43
|
-
do_login(force_login: true)
|
|
44
|
-
response = @http_client.post(path, body: params)
|
|
45
|
-
result = JPSClient::Response.new(response)
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
return result.to_h
|
|
30
|
+
return request_with_auth(:post, path, body: params)
|
|
49
31
|
end
|
|
50
32
|
|
|
51
33
|
# Get Swagger Lark Login
|
|
@@ -58,16 +40,7 @@ module JPSClient
|
|
|
58
40
|
|
|
59
41
|
path = config["url"]
|
|
60
42
|
|
|
61
|
-
|
|
62
|
-
result = JPSClient::Response.new(response)
|
|
63
|
-
|
|
64
|
-
if result.need_login?
|
|
65
|
-
do_login(force_login: true)
|
|
66
|
-
response = @http_client.get(path, params: params)
|
|
67
|
-
result = JPSClient::Response.new(response)
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
return result.to_h
|
|
43
|
+
return request_with_auth(:get, path, params: params)
|
|
71
44
|
end
|
|
72
45
|
|
|
73
46
|
# Get Get User By Uuid
|
|
@@ -80,16 +53,7 @@ module JPSClient
|
|
|
80
53
|
|
|
81
54
|
path = config["url"]
|
|
82
55
|
|
|
83
|
-
|
|
84
|
-
result = JPSClient::Response.new(response)
|
|
85
|
-
|
|
86
|
-
if result.need_login?
|
|
87
|
-
do_login(force_login: true)
|
|
88
|
-
response = @http_client.get(path, params: params)
|
|
89
|
-
result = JPSClient::Response.new(response)
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
return result.to_h
|
|
56
|
+
return request_with_auth(:get, path, params: params)
|
|
93
57
|
end
|
|
94
58
|
end
|
|
95
59
|
end
|
data/lib/jpsclient/api/m3u8.rb
CHANGED
|
@@ -14,16 +14,7 @@ module JPSClient
|
|
|
14
14
|
|
|
15
15
|
path = config["url"]
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
result = JPSClient::Response.new(response)
|
|
19
|
-
|
|
20
|
-
if result.need_login?
|
|
21
|
-
do_login(force_login: true)
|
|
22
|
-
response = @http_client.get(path, params: params)
|
|
23
|
-
result = JPSClient::Response.new(response)
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
return result.to_h
|
|
17
|
+
return request_with_auth(:get, path, params: params)
|
|
27
18
|
end
|
|
28
19
|
end
|
|
29
20
|
end
|
data/lib/jpsclient/api/menu.rb
CHANGED
|
@@ -15,16 +15,7 @@ module JPSClient
|
|
|
15
15
|
path = config["url"]
|
|
16
16
|
path = path.gsub("{menuId}", menuId.to_s)
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
result = JPSClient::Response.new(response)
|
|
20
|
-
|
|
21
|
-
if result.need_login?
|
|
22
|
-
do_login(force_login: true)
|
|
23
|
-
response = @http_client.get(path, params: params)
|
|
24
|
-
result = JPSClient::Response.new(response)
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
return result.to_h
|
|
18
|
+
return request_with_auth(:get, path, params: params)
|
|
28
19
|
end
|
|
29
20
|
|
|
30
21
|
# Update Menu
|
|
@@ -38,16 +29,7 @@ module JPSClient
|
|
|
38
29
|
path = config["url"]
|
|
39
30
|
path = path.gsub("{menuId}", menuId.to_s)
|
|
40
31
|
|
|
41
|
-
|
|
42
|
-
result = JPSClient::Response.new(response)
|
|
43
|
-
|
|
44
|
-
if result.need_login?
|
|
45
|
-
do_login(force_login: true)
|
|
46
|
-
response = @http_client.put(path, body: params)
|
|
47
|
-
result = JPSClient::Response.new(response)
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
return result.to_h
|
|
32
|
+
return request_with_auth(:put, path, body: params)
|
|
51
33
|
end
|
|
52
34
|
|
|
53
35
|
# Delete Menu
|
|
@@ -61,16 +43,7 @@ module JPSClient
|
|
|
61
43
|
path = config["url"]
|
|
62
44
|
path = path.gsub("{menuId}", menuId.to_s)
|
|
63
45
|
|
|
64
|
-
|
|
65
|
-
result = JPSClient::Response.new(response)
|
|
66
|
-
|
|
67
|
-
if result.need_login?
|
|
68
|
-
do_login(force_login: true)
|
|
69
|
-
response = @http_client.delete(path)
|
|
70
|
-
result = JPSClient::Response.new(response)
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
return result.to_h
|
|
46
|
+
return request_with_auth(:delete, path)
|
|
74
47
|
end
|
|
75
48
|
|
|
76
49
|
# Create Menu
|
|
@@ -83,16 +56,7 @@ module JPSClient
|
|
|
83
56
|
|
|
84
57
|
path = config["url"]
|
|
85
58
|
|
|
86
|
-
|
|
87
|
-
result = JPSClient::Response.new(response)
|
|
88
|
-
|
|
89
|
-
if result.need_login?
|
|
90
|
-
do_login(force_login: true)
|
|
91
|
-
response = @http_client.post(path, body: params)
|
|
92
|
-
result = JPSClient::Response.new(response)
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
return result.to_h
|
|
59
|
+
return request_with_auth(:post, path, body: params)
|
|
96
60
|
end
|
|
97
61
|
|
|
98
62
|
# Get Menus
|
|
@@ -105,16 +69,7 @@ module JPSClient
|
|
|
105
69
|
|
|
106
70
|
path = config["url"]
|
|
107
71
|
|
|
108
|
-
|
|
109
|
-
result = JPSClient::Response.new(response)
|
|
110
|
-
|
|
111
|
-
if result.need_login?
|
|
112
|
-
do_login(force_login: true)
|
|
113
|
-
response = @http_client.get(path, params: params)
|
|
114
|
-
result = JPSClient::Response.new(response)
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
return result.to_h
|
|
72
|
+
return request_with_auth(:get, path, params: params)
|
|
118
73
|
end
|
|
119
74
|
|
|
120
75
|
# Get Role
|
|
@@ -127,16 +82,7 @@ module JPSClient
|
|
|
127
82
|
|
|
128
83
|
path = config["url"]
|
|
129
84
|
|
|
130
|
-
|
|
131
|
-
result = JPSClient::Response.new(response)
|
|
132
|
-
|
|
133
|
-
if result.need_login?
|
|
134
|
-
do_login(force_login: true)
|
|
135
|
-
response = @http_client.get(path, params: params)
|
|
136
|
-
result = JPSClient::Response.new(response)
|
|
137
|
-
end
|
|
138
|
-
|
|
139
|
-
return result.to_h
|
|
85
|
+
return request_with_auth(:get, path, params: params)
|
|
140
86
|
end
|
|
141
87
|
end
|
|
142
88
|
end
|
|
@@ -87,7 +87,7 @@ module JPSClient
|
|
|
87
87
|
@token_manager = Token.new(@jps_config)
|
|
88
88
|
|
|
89
89
|
# 尝试加载已保存的 token
|
|
90
|
-
if @token_manager.load && @token_manager.
|
|
90
|
+
if @token_manager.load && @token_manager.loaded?
|
|
91
91
|
@token = @token_manager.to_h
|
|
92
92
|
end
|
|
93
93
|
|
|
@@ -171,50 +171,50 @@ module JPSClient
|
|
|
171
171
|
end
|
|
172
172
|
|
|
173
173
|
# 核心登录功能
|
|
174
|
+
# token 有效性由服务端 401 响应判断,本地不做过期检查
|
|
174
175
|
def do_login(force_login: false)
|
|
175
|
-
# 使用 token 管理器统一处理
|
|
176
176
|
if force_login
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
if result == :user_cancelled
|
|
183
|
-
Logger.instance.fancyinfo_error("用户取消了登录操作")
|
|
184
|
-
return false
|
|
185
|
-
elsif result == true
|
|
186
|
-
# 保存新 token
|
|
187
|
-
@token_manager.save(auth.access_token, auth.username, auth.expires_at)
|
|
188
|
-
update_token_everywhere()
|
|
177
|
+
@token_manager.clear
|
|
178
|
+
else
|
|
179
|
+
# 本地存在 token,直接使用
|
|
180
|
+
if @token_manager.load && @token_manager.loaded?
|
|
181
|
+
update_token_everywhere
|
|
189
182
|
return true
|
|
190
|
-
else
|
|
191
|
-
Logger.instance.fancyinfo_error("登录失败,未能获取有效token")
|
|
192
|
-
return false
|
|
193
183
|
end
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
# 需要重新登录
|
|
187
|
+
auth = Auth.new(@jps_config)
|
|
188
|
+
result = auth.login
|
|
189
|
+
|
|
190
|
+
if result == :user_cancelled
|
|
191
|
+
Logger.instance.fancyinfo_error("用户取消了登录操作")
|
|
192
|
+
return false
|
|
193
|
+
elsif result == true
|
|
194
|
+
unless @token_manager.save(auth.get_token_data)
|
|
195
|
+
Logger.instance.fancyinfo_error("Token 保存失败,下次启动需要重新登录")
|
|
196
|
+
end
|
|
197
|
+
update_token_everywhere
|
|
198
|
+
return true
|
|
194
199
|
else
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
@token_manager.save(auth.access_token, auth.username, auth.expires_at)
|
|
210
|
-
update_token_everywhere()
|
|
211
|
-
return true
|
|
212
|
-
else
|
|
213
|
-
Logger.instance.fancyinfo_error("登录失败,未能获取有效token")
|
|
214
|
-
return false
|
|
215
|
-
end
|
|
200
|
+
Logger.instance.fancyinfo_error("登录失败,未能获取有效token")
|
|
201
|
+
return false
|
|
202
|
+
end
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
# 带 401 重试的统一请求方法
|
|
206
|
+
def request_with_auth(method, path, **opts)
|
|
207
|
+
response = @http_client.send(method, path, **opts)
|
|
208
|
+
result = JPSClient::Response.new(response)
|
|
209
|
+
|
|
210
|
+
if result.need_login?
|
|
211
|
+
if do_login(force_login: true)
|
|
212
|
+
response = @http_client.send(method, path, **opts)
|
|
213
|
+
result = JPSClient::Response.new(response)
|
|
216
214
|
end
|
|
217
215
|
end
|
|
216
|
+
|
|
217
|
+
result.to_h
|
|
218
218
|
end
|
|
219
219
|
|
|
220
220
|
private
|
data/lib/jpsclient/api/nuget.rb
CHANGED
|
@@ -13,16 +13,7 @@ module JPSClient
|
|
|
13
13
|
|
|
14
14
|
path = config["url"]
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
result = JPSClient::Response.new(response)
|
|
18
|
-
|
|
19
|
-
if result.need_login?
|
|
20
|
-
do_login(force_login: true)
|
|
21
|
-
response = @http_client.get(path)
|
|
22
|
-
result = JPSClient::Response.new(response)
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
return result.to_h
|
|
16
|
+
return request_with_auth(:get, path)
|
|
26
17
|
end
|
|
27
18
|
|
|
28
19
|
end
|
|
@@ -14,16 +14,7 @@ module JPSClient
|
|
|
14
14
|
|
|
15
15
|
path = config["url"]
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
result = JPSClient::Response.new(response)
|
|
19
|
-
|
|
20
|
-
if result.need_login?
|
|
21
|
-
do_login(force_login: true)
|
|
22
|
-
response = @http_client.get(path, params: params)
|
|
23
|
-
result = JPSClient::Response.new(response)
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
return result.to_h
|
|
17
|
+
return request_with_auth(:get, path, params: params)
|
|
27
18
|
end
|
|
28
19
|
|
|
29
20
|
# 获取权限详情
|
|
@@ -37,16 +28,7 @@ module JPSClient
|
|
|
37
28
|
path = config["url"]
|
|
38
29
|
params = { id: id }
|
|
39
30
|
|
|
40
|
-
|
|
41
|
-
result = JPSClient::Response.new(response)
|
|
42
|
-
|
|
43
|
-
if result.need_login?
|
|
44
|
-
do_login(force_login: true)
|
|
45
|
-
response = @http_client.get(path, params: params)
|
|
46
|
-
result = JPSClient::Response.new(response)
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
return result.to_h
|
|
31
|
+
return request_with_auth(:get, path, params: params)
|
|
50
32
|
end
|
|
51
33
|
|
|
52
34
|
# 创建权限
|
|
@@ -67,16 +49,7 @@ module JPSClient
|
|
|
67
49
|
}
|
|
68
50
|
body[:description] = description if description
|
|
69
51
|
|
|
70
|
-
|
|
71
|
-
result = JPSClient::Response.new(response)
|
|
72
|
-
|
|
73
|
-
if result.need_login?
|
|
74
|
-
do_login(force_login: true)
|
|
75
|
-
response = @http_client.post(path, body: body)
|
|
76
|
-
result = JPSClient::Response.new(response)
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
return result.to_h
|
|
52
|
+
return request_with_auth(:post, path, body: body)
|
|
80
53
|
end
|
|
81
54
|
|
|
82
55
|
# 更新权限
|
|
@@ -97,16 +70,7 @@ module JPSClient
|
|
|
97
70
|
body[:code] = code if code
|
|
98
71
|
body[:description] = description if description
|
|
99
72
|
|
|
100
|
-
|
|
101
|
-
result = JPSClient::Response.new(response)
|
|
102
|
-
|
|
103
|
-
if result.need_login?
|
|
104
|
-
do_login(force_login: true)
|
|
105
|
-
response = @http_client.post(path, body: body)
|
|
106
|
-
result = JPSClient::Response.new(response)
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
return result.to_h
|
|
73
|
+
return request_with_auth(:post, path, body: body)
|
|
110
74
|
end
|
|
111
75
|
|
|
112
76
|
# 删除权限
|
|
@@ -120,16 +84,7 @@ module JPSClient
|
|
|
120
84
|
path = config["url"]
|
|
121
85
|
body = { id: id }
|
|
122
86
|
|
|
123
|
-
|
|
124
|
-
result = JPSClient::Response.new(response)
|
|
125
|
-
|
|
126
|
-
if result.need_login?
|
|
127
|
-
do_login(force_login: true)
|
|
128
|
-
response = @http_client.post(path, body: body)
|
|
129
|
-
result = JPSClient::Response.new(response)
|
|
130
|
-
end
|
|
131
|
-
|
|
132
|
-
return result.to_h
|
|
87
|
+
return request_with_auth(:post, path, body: body)
|
|
133
88
|
end
|
|
134
89
|
|
|
135
90
|
end
|
|
@@ -19,19 +19,8 @@ module JPSClient
|
|
|
19
19
|
|
|
20
20
|
params.each { |key,value| get_params[key] = value } if params
|
|
21
21
|
|
|
22
|
-
response = @http_client.get(path, params: get_params)
|
|
23
|
-
result = JPSClient::Response.new(response)
|
|
24
|
-
|
|
25
|
-
# 处理 401 错误,自动重新登录
|
|
26
|
-
if result.need_login?
|
|
27
|
-
do_login(force_login: true)
|
|
28
|
-
# 重试请求
|
|
29
|
-
response = @http_client.get(path, params: get_params)
|
|
30
|
-
result = JPSClient::Response.new(response)
|
|
31
|
-
end
|
|
32
|
-
|
|
33
22
|
# 处理响应数据格式
|
|
34
|
-
response_data =
|
|
23
|
+
response_data = request_with_auth(:get, path, params: get_params)
|
|
35
24
|
if response_data && response_data['data'] && response_data['data']['projects']
|
|
36
25
|
# 新的API格式:返回 projects 数组
|
|
37
26
|
response_data['data'] = response_data['data']['projects']
|
|
@@ -52,16 +41,7 @@ module JPSClient
|
|
|
52
41
|
get_params = { projectId: project_id }
|
|
53
42
|
get_params[:projectName] = project_name if project_name
|
|
54
43
|
|
|
55
|
-
|
|
56
|
-
result = JPSClient::Response.new(response)
|
|
57
|
-
|
|
58
|
-
if result.need_login?
|
|
59
|
-
do_login(force_login: true)
|
|
60
|
-
response = @http_client.get(path, params: get_params)
|
|
61
|
-
result = JPSClient::Response.new(response)
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
return result.to_h
|
|
44
|
+
return request_with_auth(:get, path, params: get_params)
|
|
65
45
|
end
|
|
66
46
|
|
|
67
47
|
end
|
|
@@ -45,18 +45,7 @@ module JPSClient
|
|
|
45
45
|
# 移除值为nil的键
|
|
46
46
|
body_params.compact!
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
result = JPSClient::Response.new(response)
|
|
50
|
-
|
|
51
|
-
# 处理 401 错误,自动重新登录
|
|
52
|
-
if result.need_login?
|
|
53
|
-
do_login(force_login: true)
|
|
54
|
-
# 重试请求
|
|
55
|
-
response = @http_client.post(path, body: body_params, timeout: timeout)
|
|
56
|
-
result = JPSClient::Response.new(response)
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
return result.to_h
|
|
48
|
+
return request_with_auth(:post, path, body: body_params, timeout: timeout)
|
|
60
49
|
end
|
|
61
50
|
|
|
62
51
|
# 上传 NuGet 包
|
|
@@ -110,39 +99,7 @@ module JPSClient
|
|
|
110
99
|
end
|
|
111
100
|
end
|
|
112
101
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
if ENV['PINDO_DEBUG']
|
|
116
|
-
puts "[DEBUG]upload_nuget_package HTTP 响应:"
|
|
117
|
-
puts "[DEBUG]upload_nuget_package 状态码: #{response.code}" if response.respond_to?(:code)
|
|
118
|
-
puts "[DEBUG]upload_nuget_package 响应体: #{response.body}" if response.respond_to?(:body)
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
result = JPSClient::Response.new(response)
|
|
122
|
-
|
|
123
|
-
if ENV['PINDO_DEBUG']
|
|
124
|
-
puts "[DEBUG]upload_nuget_package 解析后的结果:"
|
|
125
|
-
puts "[DEBUG]upload_nuget_package #{result.to_h.inspect}"
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
# 处理 401 错误,自动重新登录
|
|
129
|
-
if result.need_login?
|
|
130
|
-
puts "[DEBUG]upload_nuget_package 需要重新登录,执行自动登录..." if ENV['PINDO_DEBUG']
|
|
131
|
-
do_login(force_login: true)
|
|
132
|
-
# 重试请求
|
|
133
|
-
puts "[DEBUG]upload_nuget_package 重新发送请求..." if ENV['PINDO_DEBUG']
|
|
134
|
-
response = @http_client.post(path, body: body_params)
|
|
135
|
-
|
|
136
|
-
if ENV['PINDO_DEBUG']
|
|
137
|
-
puts "[DEBUG]upload_nuget_package 重试后的响应:"
|
|
138
|
-
puts "[DEBUG]upload_nuget_package 状态码: #{response.code}" if response.respond_to?(:code)
|
|
139
|
-
puts "[DEBUG]upload_nuget_package 响应体: #{response.body}" if response.respond_to?(:body)
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
result = JPSClient::Response.new(response)
|
|
143
|
-
end
|
|
144
|
-
|
|
145
|
-
return result.to_h
|
|
102
|
+
return request_with_auth(:post, path, body: body_params)
|
|
146
103
|
end
|
|
147
104
|
|
|
148
105
|
# 获取项目包列表
|
|
@@ -176,11 +133,8 @@ module JPSClient
|
|
|
176
133
|
get_params[:startTimestamp] = params[:startTimestamp] if params[:startTimestamp]
|
|
177
134
|
get_params[:endTimestamp] = params[:endTimestamp] if params[:endTimestamp]
|
|
178
135
|
|
|
179
|
-
response = @http_client.get(path, params: get_params)
|
|
180
|
-
result = JPSClient::Response.new(response)
|
|
181
|
-
|
|
182
136
|
# 处理响应数据格式
|
|
183
|
-
response_data =
|
|
137
|
+
response_data = request_with_auth(:get, path, params: get_params)
|
|
184
138
|
if response_data && response_data['data'] && response_data['data']['packages']
|
|
185
139
|
# 新的API格式:返回 packages 数组
|
|
186
140
|
response_data['data'] = response_data['data']['packages']
|
|
@@ -200,18 +154,7 @@ module JPSClient
|
|
|
200
154
|
description: description
|
|
201
155
|
}.compact # 移除nil值
|
|
202
156
|
|
|
203
|
-
|
|
204
|
-
result = JPSClient::Response.new(response)
|
|
205
|
-
|
|
206
|
-
# 处理 401 错误,自动重新登录
|
|
207
|
-
if result.need_login?
|
|
208
|
-
do_login(force_login: true)
|
|
209
|
-
# 重试请求
|
|
210
|
-
response = @http_client.post(path, body: body_params)
|
|
211
|
-
result = JPSClient::Response.new(response)
|
|
212
|
-
end
|
|
213
|
-
|
|
214
|
-
return result.to_h
|
|
157
|
+
return request_with_auth(:post, path, body: body_params)
|
|
215
158
|
end
|
|
216
159
|
|
|
217
160
|
# 签名项目包
|
|
@@ -225,18 +168,7 @@ module JPSClient
|
|
|
225
168
|
certId: certId
|
|
226
169
|
}
|
|
227
170
|
|
|
228
|
-
|
|
229
|
-
result = JPSClient::Response.new(response)
|
|
230
|
-
|
|
231
|
-
# 处理 401 错误,自动重新登录
|
|
232
|
-
if result.need_login?
|
|
233
|
-
do_login(force_login: true)
|
|
234
|
-
# 重试请求
|
|
235
|
-
response = @http_client.post(path, body: body_params)
|
|
236
|
-
result = JPSClient::Response.new(response)
|
|
237
|
-
end
|
|
238
|
-
|
|
239
|
-
return result.to_h
|
|
171
|
+
return request_with_auth(:post, path, body: body_params)
|
|
240
172
|
end
|
|
241
173
|
|
|
242
174
|
# 发送项目包消息
|
|
@@ -255,18 +187,7 @@ module JPSClient
|
|
|
255
187
|
# 添加可选参数
|
|
256
188
|
body_params[:indexNo] = indexNo if indexNo
|
|
257
189
|
|
|
258
|
-
|
|
259
|
-
result = JPSClient::Response.new(response)
|
|
260
|
-
|
|
261
|
-
# 处理 401 错误,自动重新登录
|
|
262
|
-
if result.need_login?
|
|
263
|
-
do_login(force_login: true)
|
|
264
|
-
# 重试请求
|
|
265
|
-
response = @http_client.post(path, body: body_params)
|
|
266
|
-
result = JPSClient::Response.new(response)
|
|
267
|
-
end
|
|
268
|
-
|
|
269
|
-
return result.to_h
|
|
190
|
+
return request_with_auth(:post, path, body: body_params)
|
|
270
191
|
end
|
|
271
192
|
|
|
272
193
|
# 绑定提交记录到项目包
|
|
@@ -280,18 +201,7 @@ module JPSClient
|
|
|
280
201
|
projectPackageIds: projectPackageIds
|
|
281
202
|
}
|
|
282
203
|
|
|
283
|
-
|
|
284
|
-
result = JPSClient::Response.new(response)
|
|
285
|
-
|
|
286
|
-
# 处理 401 错误,自动重新登录
|
|
287
|
-
if result.need_login?
|
|
288
|
-
do_login(force_login: true)
|
|
289
|
-
# 重试请求
|
|
290
|
-
response = @http_client.post(path, body: body_params)
|
|
291
|
-
result = JPSClient::Response.new(response)
|
|
292
|
-
end
|
|
293
|
-
|
|
294
|
-
return result.to_h
|
|
204
|
+
return request_with_auth(:post, path, body: body_params)
|
|
295
205
|
end
|
|
296
206
|
|
|
297
207
|
# 预览项目包
|
|
@@ -309,18 +219,7 @@ module JPSClient
|
|
|
309
219
|
projectId: params[:projectId]
|
|
310
220
|
}.compact # 移除nil值
|
|
311
221
|
|
|
312
|
-
|
|
313
|
-
result = JPSClient::Response.new(response)
|
|
314
|
-
|
|
315
|
-
# 处理 401 错误,自动重新登录
|
|
316
|
-
if result.need_login?
|
|
317
|
-
do_login(force_login: true)
|
|
318
|
-
# 重试请求
|
|
319
|
-
response = @http_client.get(path, params: get_params)
|
|
320
|
-
result = JPSClient::Response.new(response)
|
|
321
|
-
end
|
|
322
|
-
|
|
323
|
-
return result.to_h
|
|
222
|
+
return request_with_auth(:get, path, params: get_params)
|
|
324
223
|
end
|
|
325
224
|
|
|
326
225
|
# 获取项目包绑定列表
|
|
@@ -333,18 +232,7 @@ module JPSClient
|
|
|
333
232
|
projectId: projectId
|
|
334
233
|
}
|
|
335
234
|
|
|
336
|
-
|
|
337
|
-
result = JPSClient::Response.new(response)
|
|
338
|
-
|
|
339
|
-
# 处理 401 错误,自动重新登录
|
|
340
|
-
if result.need_login?
|
|
341
|
-
do_login(force_login: true)
|
|
342
|
-
# 重试请求
|
|
343
|
-
response = @http_client.get(path, params: get_params)
|
|
344
|
-
result = JPSClient::Response.new(response)
|
|
345
|
-
end
|
|
346
|
-
|
|
347
|
-
return result.to_h
|
|
235
|
+
return request_with_auth(:get, path, params: get_params)
|
|
348
236
|
end
|
|
349
237
|
|
|
350
238
|
end
|