jpsclient 0.2.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 +7 -0
- data/LICENSE +21 -0
- data/bin/jpsclient +28 -0
- data/lib/jpsclient/api/app_level.rb +138 -0
- data/lib/jpsclient/api/app_resource.rb +164 -0
- data/lib/jpsclient/api/app_resource_version.rb +52 -0
- data/lib/jpsclient/api/apple_account.rb +140 -0
- data/lib/jpsclient/api/application.rb +268 -0
- data/lib/jpsclient/api/application_category.rb +120 -0
- data/lib/jpsclient/api/application_design.rb +118 -0
- data/lib/jpsclient/api/application_income.rb +54 -0
- data/lib/jpsclient/api/application_sales.rb +52 -0
- data/lib/jpsclient/api/application_version.rb +77 -0
- data/lib/jpsclient/api/assets_category.rb +120 -0
- data/lib/jpsclient/api/bug.rb +140 -0
- data/lib/jpsclient/api/cert.rb +27 -0
- data/lib/jpsclient/api/client.rb +268 -0
- data/lib/jpsclient/api/collect.rb +52 -0
- data/lib/jpsclient/api/collection.rb +162 -0
- data/lib/jpsclient/api/commit_log.rb +104 -0
- data/lib/jpsclient/api/creative.rb +52 -0
- data/lib/jpsclient/api/custom_application.rb +230 -0
- data/lib/jpsclient/api/custom_application_web.rb +52 -0
- data/lib/jpsclient/api/document_text.rb +30 -0
- data/lib/jpsclient/api/experience.rb +143 -0
- data/lib/jpsclient/api/experience_category.rb +97 -0
- data/lib/jpsclient/api/fgui_export.rb +52 -0
- data/lib/jpsclient/api/file.rb +84 -0
- data/lib/jpsclient/api/game_assets.rb +140 -0
- data/lib/jpsclient/api/healthy.rb +30 -0
- data/lib/jpsclient/api/icon_and_snapshot.rb +54 -0
- data/lib/jpsclient/api/idea.rb +121 -0
- data/lib/jpsclient/api/jssdk.rb +30 -0
- data/lib/jpsclient/api/lark_bitable.rb +30 -0
- data/lib/jpsclient/api/lark_chat_group.rb +30 -0
- data/lib/jpsclient/api/lark_comment.rb +118 -0
- data/lib/jpsclient/api/lark_task.rb +140 -0
- data/lib/jpsclient/api/lark_task_list.rb +118 -0
- data/lib/jpsclient/api/lark_task_section.rb +74 -0
- data/lib/jpsclient/api/lark_user.rb +30 -0
- data/lib/jpsclient/api/lark_wiki_node.rb +30 -0
- data/lib/jpsclient/api/lark_wiki_space.rb +30 -0
- data/lib/jpsclient/api/lazy_client.rb +290 -0
- data/lib/jpsclient/api/login.rb +96 -0
- data/lib/jpsclient/api/m3u8.rb +30 -0
- data/lib/jpsclient/api/menu.rb +143 -0
- data/lib/jpsclient/api/modular_client.rb +228 -0
- data/lib/jpsclient/api/project.rb +46 -0
- data/lib/jpsclient/api/project_package.rb +249 -0
- data/lib/jpsclient/api/publisher.rb +165 -0
- data/lib/jpsclient/api/publisher_category.rb +142 -0
- data/lib/jpsclient/api/publisher_group.rb +118 -0
- data/lib/jpsclient/api/publisher_group_category.rb +120 -0
- data/lib/jpsclient/api/requirements.rb +143 -0
- data/lib/jpsclient/api/requirements_category.rb +97 -0
- data/lib/jpsclient/api/resource_category.rb +120 -0
- data/lib/jpsclient/api/role.rb +165 -0
- data/lib/jpsclient/api/simple_search.rb +162 -0
- data/lib/jpsclient/api/sketch.rb +74 -0
- data/lib/jpsclient/api/sketch_category.rb +97 -0
- data/lib/jpsclient/api/sov.rb +30 -0
- data/lib/jpsclient/api/statistics.rb +30 -0
- data/lib/jpsclient/api/store.rb +30 -0
- data/lib/jpsclient/api/survey.rb +143 -0
- data/lib/jpsclient/api/survey_category.rb +97 -0
- data/lib/jpsclient/api/tag.rb +142 -0
- data/lib/jpsclient/api/tool.rb +121 -0
- data/lib/jpsclient/api/tool_category.rb +120 -0
- data/lib/jpsclient/api/trending.rb +30 -0
- data/lib/jpsclient/api/ud_id.rb +118 -0
- data/lib/jpsclient/api/user.rb +99 -0
- data/lib/jpsclient/api/util.rb +30 -0
- data/lib/jpsclient/api/video_cover.rb +30 -0
- data/lib/jpsclient/api/webhook.rb +118 -0
- data/lib/jpsclient/api/workflow.rb +118 -0
- data/lib/jpsclient/auth/auth.rb +676 -0
- data/lib/jpsclient/auth/token.rb +209 -0
- data/lib/jpsclient/base/api_config.rb +225 -0
- data/lib/jpsclient/base/exception.rb +5 -0
- data/lib/jpsclient/http/http_client.rb +148 -0
- data/lib/jpsclient/upload/upload_client.rb +334 -0
- data/lib/jpsclient/upload/upload_config.rb +128 -0
- data/lib/jpsclient/upload/upload_progress.rb +73 -0
- data/lib/jpsclient/utils/aes.rb +49 -0
- data/lib/jpsclient/utils/logger.rb +38 -0
- data/lib/jpsclient/version.rb +3 -0
- data/lib/jpsclient.rb +34 -0
- metadata +269 -0
@@ -0,0 +1,228 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'json'
|
3
|
+
require 'jpsclient/base/exception'
|
4
|
+
require 'jpsclient/base/api_config'
|
5
|
+
require 'jpsclient/utils/aes'
|
6
|
+
require 'jpsclient/http/http_client'
|
7
|
+
require 'jpsclient/auth/auth'
|
8
|
+
require 'jpsclient/auth/token'
|
9
|
+
require 'jpsclient/utils/logger'
|
10
|
+
|
11
|
+
module JPSClient
|
12
|
+
# 模块化Client - 支持按需加载指定的API模块组
|
13
|
+
class ModularClient
|
14
|
+
# 模块分组定义
|
15
|
+
MODULE_GROUPS = {
|
16
|
+
# 核心模块 - 项目和文件管理
|
17
|
+
core: %w[project project_package file cert],
|
18
|
+
|
19
|
+
# 应用管理相关
|
20
|
+
application: %w[application application_category application_version application_design
|
21
|
+
application_income application_sales],
|
22
|
+
|
23
|
+
# 资源管理相关
|
24
|
+
resource: %w[app_resource app_resource_version app_level assets_category
|
25
|
+
resource_category collection],
|
26
|
+
|
27
|
+
# Bug和工作流
|
28
|
+
workflow: %w[bug workflow commit_log],
|
29
|
+
|
30
|
+
# 用户和权限
|
31
|
+
user: %w[user role login],
|
32
|
+
|
33
|
+
# Lark集成
|
34
|
+
lark: %w[lark_task lark_task_list lark_task_section lark_user
|
35
|
+
lark_wiki_node lark_wiki_space lark_chat_group lark_comment lark_bitable],
|
36
|
+
|
37
|
+
# 创意和设计
|
38
|
+
creative: %w[creative idea sketch sketch_category experience experience_category],
|
39
|
+
|
40
|
+
# 发布商相关
|
41
|
+
publisher: %w[publisher publisher_category publisher_group publisher_group_category],
|
42
|
+
|
43
|
+
# 需求和调研
|
44
|
+
requirements: %w[requirements requirements_category survey survey_category],
|
45
|
+
|
46
|
+
# 工具和实用
|
47
|
+
utility: %w[tool tool_category util simple_search menu tag],
|
48
|
+
|
49
|
+
# 统计和分析
|
50
|
+
analytics: %w[statistics trending sov],
|
51
|
+
|
52
|
+
# 媒体相关
|
53
|
+
media: %w[video_cover icon_and_snapshot m3u8 document_text],
|
54
|
+
|
55
|
+
# 其他
|
56
|
+
misc: %w[store webhook healthy custom_application custom_application_web
|
57
|
+
apple_account ud_id jssdk fgui_export game_assets collect]
|
58
|
+
}.freeze
|
59
|
+
|
60
|
+
attr_accessor :token, :baseurl, :request_config, :http_client, :api_config
|
61
|
+
attr_reader :config_json, :config_file, :loaded_groups, :loaded_modules
|
62
|
+
|
63
|
+
def initialize(config_file:, load_groups: [:core])
|
64
|
+
begin
|
65
|
+
@config_file = config_file
|
66
|
+
@loaded_groups = []
|
67
|
+
@loaded_modules = []
|
68
|
+
|
69
|
+
raise ExceptionError, "必须提供配置文件路径" unless @config_file
|
70
|
+
raise ExceptionError, "配置文件不存在: #{@config_file}" unless File.exist?(@config_file)
|
71
|
+
|
72
|
+
@config_json = JSON.parse(File.read(@config_file))
|
73
|
+
@baseurl = @config_json["pgyerapps_base_url"]
|
74
|
+
@request_config = @config_json["api_path_config"]
|
75
|
+
|
76
|
+
# 初始化API配置管理器
|
77
|
+
@api_config = ApiConfig.new(@config_json)
|
78
|
+
|
79
|
+
# 从 auth_config 获取配置
|
80
|
+
auth_config = @config_json["auth_config"]
|
81
|
+
@pgyer_aes_key = auth_config["aes_key"]
|
82
|
+
|
83
|
+
# 加载 JPS 登录配置
|
84
|
+
@jps_config = LoginConfig.from_json(auth_config)
|
85
|
+
|
86
|
+
# 初始化 token 管理器
|
87
|
+
@token_manager = Token.new(@jps_config)
|
88
|
+
|
89
|
+
# 尝试加载已保存的 token
|
90
|
+
if @token_manager.load && @token_manager.valid?
|
91
|
+
@token = @token_manager.to_h
|
92
|
+
end
|
93
|
+
|
94
|
+
# 初始化共享的 HTTP 客户端
|
95
|
+
@http_client = HttpClient.new(base_url: @baseurl)
|
96
|
+
@http_client.update_token(@token["token"]) if @token && @token["token"]
|
97
|
+
|
98
|
+
# 加载指定的模块组
|
99
|
+
Array(load_groups).each { |group| load_group(group) }
|
100
|
+
|
101
|
+
rescue JSON::ParserError => error
|
102
|
+
raise ExceptionError.new("配置文件格式错误 (#{@config_file}): #{error.message}")
|
103
|
+
rescue ExceptionError
|
104
|
+
raise # 重新抛出 JPS 异常
|
105
|
+
rescue => error
|
106
|
+
raise ExceptionError.new("加载配置文件失败 (#{@config_file}): #{error.message}")
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
# 加载指定的模块组
|
111
|
+
def load_group(group_name)
|
112
|
+
group_name = group_name.to_sym
|
113
|
+
return if @loaded_groups.include?(group_name)
|
114
|
+
|
115
|
+
modules = MODULE_GROUPS[group_name]
|
116
|
+
unless modules
|
117
|
+
puts "警告: 未知的模块组 '#{group_name}'"
|
118
|
+
puts "可用的模块组: #{MODULE_GROUPS.keys.join(', ')}"
|
119
|
+
return
|
120
|
+
end
|
121
|
+
|
122
|
+
modules.each do |module_name|
|
123
|
+
load_module(module_name)
|
124
|
+
end
|
125
|
+
|
126
|
+
@loaded_groups << group_name
|
127
|
+
puts "已加载模块组: #{group_name} (#{modules.size}个模块)"
|
128
|
+
end
|
129
|
+
|
130
|
+
# 加载单个模块
|
131
|
+
def load_module(module_name)
|
132
|
+
return if @loaded_modules.include?(module_name)
|
133
|
+
|
134
|
+
begin
|
135
|
+
require "jpsclient/api/#{module_name}"
|
136
|
+
|
137
|
+
# 将模块名转换为类名
|
138
|
+
class_name = module_name.split('_').map(&:capitalize).join
|
139
|
+
|
140
|
+
# Include模块
|
141
|
+
if API.const_defined?(class_name)
|
142
|
+
self.class.send(:include, API.const_get(class_name))
|
143
|
+
@loaded_modules << module_name
|
144
|
+
end
|
145
|
+
rescue LoadError => e
|
146
|
+
puts "警告: 无法加载模块 #{module_name}: #{e.message}"
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
# 提供共享的HTTP客户端给其他模块
|
151
|
+
def shared_http_client
|
152
|
+
@http_client
|
153
|
+
end
|
154
|
+
|
155
|
+
# 打印加载状态
|
156
|
+
def print_status
|
157
|
+
puts "=" * 60
|
158
|
+
puts "ModularClient 加载状态"
|
159
|
+
puts "=" * 60
|
160
|
+
puts "已加载的模块组: #{@loaded_groups.join(', ')}"
|
161
|
+
puts "已加载的模块数: #{@loaded_modules.size}"
|
162
|
+
puts "可用的方法示例:"
|
163
|
+
|
164
|
+
# 显示一些可用的方法
|
165
|
+
sample_methods = self.methods(false).select { |m|
|
166
|
+
m.to_s.start_with?('get_', 'create_', 'update_', 'delete_')
|
167
|
+
}.first(10)
|
168
|
+
|
169
|
+
sample_methods.each { |m| puts " - #{m}" }
|
170
|
+
puts " ..." if self.methods(false).size > 10
|
171
|
+
end
|
172
|
+
|
173
|
+
# 核心登录功能
|
174
|
+
def do_login(force_login: false)
|
175
|
+
# 使用 token 管理器统一处理
|
176
|
+
if force_login
|
177
|
+
# 强制重新登录
|
178
|
+
@token_manager.clear # 清除旧 token
|
179
|
+
auth = Auth.new(@jps_config)
|
180
|
+
result = auth.login
|
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()
|
189
|
+
return true
|
190
|
+
else
|
191
|
+
Logger.instance.fancyinfo_error("登录失败,未能获取有效token")
|
192
|
+
return false
|
193
|
+
end
|
194
|
+
else
|
195
|
+
# 尝试加载并验证现有 token
|
196
|
+
if @token_manager.load && @token_manager.valid?
|
197
|
+
update_token_everywhere()
|
198
|
+
return true
|
199
|
+
else
|
200
|
+
# Token 无效或不存在,需要重新登录
|
201
|
+
auth = Auth.new(@jps_config)
|
202
|
+
result = auth.login
|
203
|
+
|
204
|
+
if result == :user_cancelled
|
205
|
+
Logger.instance.fancyinfo_error("用户取消了登录操作")
|
206
|
+
return false
|
207
|
+
elsif result == true
|
208
|
+
# 保存新 token
|
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
|
216
|
+
end
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
private
|
221
|
+
|
222
|
+
# 统一更新token到所有组件
|
223
|
+
def update_token_everywhere
|
224
|
+
@token = @token_manager.to_h
|
225
|
+
@http_client.update_token(@token["token"]) if @http_client && @token
|
226
|
+
end
|
227
|
+
end
|
228
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module JPSClient
|
2
|
+
module API
|
3
|
+
# 项目相关 API
|
4
|
+
# 处理 /api/project/* 路径的所有接口
|
5
|
+
module Project
|
6
|
+
|
7
|
+
# 获取项目列表
|
8
|
+
# @param params [Hash] 查询参数
|
9
|
+
# @return [Hash] 响应数据
|
10
|
+
def get_project_list(params:nil)
|
11
|
+
path = @request_config["project_list"]["url"]
|
12
|
+
|
13
|
+
get_params = {
|
14
|
+
orderByColumn: "update_time",
|
15
|
+
sort: "DESC",
|
16
|
+
pageNo: 1,
|
17
|
+
pageSize: 40,
|
18
|
+
}
|
19
|
+
|
20
|
+
params.each { |key,value| get_params[key] = value } if params
|
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
|
+
# 处理响应数据格式
|
34
|
+
response_data = result.to_h
|
35
|
+
if response_data && response_data['data'] && response_data['data']['projects']
|
36
|
+
# 新的API格式:返回 projects 数组
|
37
|
+
response_data['data'] = response_data['data']['projects']
|
38
|
+
end
|
39
|
+
|
40
|
+
return response_data
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,249 @@
|
|
1
|
+
module JPSClient
|
2
|
+
module API
|
3
|
+
# 项目包管理相关 API
|
4
|
+
# 处理 /api/project_package/* 路径的所有接口
|
5
|
+
#
|
6
|
+
# 支持的功能:
|
7
|
+
# - 上传项目包
|
8
|
+
# - 获取项目包列表
|
9
|
+
# - 更新项目包信息
|
10
|
+
# - 签名项目包
|
11
|
+
# - 发送项目包消息通知
|
12
|
+
# - 绑定提交记录
|
13
|
+
# - 预览项目包
|
14
|
+
# - 获取绑定列表
|
15
|
+
module ProjectPackage
|
16
|
+
|
17
|
+
# 上传项目包
|
18
|
+
def upload_project_package(projectId:nil, params:nil)
|
19
|
+
config = @request_config && @request_config["project_package_upload"]
|
20
|
+
raise JPSClient::ExceptionError, "Missing config for project_package_upload" unless config && config["url"]
|
21
|
+
path = config["url"]
|
22
|
+
|
23
|
+
body_params = {
|
24
|
+
projectId: projectId
|
25
|
+
}
|
26
|
+
|
27
|
+
# 合并传入的参数
|
28
|
+
if params
|
29
|
+
params.each { |key,value| body_params[key] = value }
|
30
|
+
end
|
31
|
+
|
32
|
+
# 确保必要的字段存在
|
33
|
+
body_params[:packageUrl] ||= params&.dig(:packageUrl)
|
34
|
+
body_params[:description] ||= params&.dig(:description)
|
35
|
+
body_params[:attachFileUrls] ||= params&.dig(:attachFileUrls) || []
|
36
|
+
body_params[:chatEnv] ||= params&.dig(:chatEnv)
|
37
|
+
body_params[:commitId] ||= params&.dig(:commitId)
|
38
|
+
body_params[:projectPackageId] ||= params&.dig(:projectPackageId)
|
39
|
+
|
40
|
+
# 移除值为nil的键
|
41
|
+
body_params.compact!
|
42
|
+
|
43
|
+
response = @http_client.post(path, body: body_params)
|
44
|
+
result = JPSClient::Response.new(response)
|
45
|
+
|
46
|
+
# 处理 401 错误,自动重新登录
|
47
|
+
if result.need_login?
|
48
|
+
do_login(force_login: true)
|
49
|
+
# 重试请求
|
50
|
+
response = @http_client.post(path, body: body_params)
|
51
|
+
result = JPSClient::Response.new(response)
|
52
|
+
end
|
53
|
+
|
54
|
+
return result.to_h
|
55
|
+
end
|
56
|
+
|
57
|
+
# 获取项目包列表
|
58
|
+
def get_project_package_list(projectId:nil, params:nil)
|
59
|
+
params = {} if params.nil?
|
60
|
+
config = @request_config && @request_config["project_package_list"]
|
61
|
+
raise JPSClient::ExceptionError, "Missing config for project_package_list" unless config && config["url"]
|
62
|
+
path = config["url"]
|
63
|
+
|
64
|
+
get_params = {
|
65
|
+
projectId: projectId,
|
66
|
+
pageNo: params[:pageNo] || 1,
|
67
|
+
pageSize: params[:pageSize] || 20,
|
68
|
+
}
|
69
|
+
|
70
|
+
# 添加可选的筛选参数
|
71
|
+
get_params[:uploadBy] = params[:uploadBy] if params[:uploadBy]
|
72
|
+
get_params[:nativePackageType] = params[:nativePackageType] if params[:nativePackageType]
|
73
|
+
get_params[:startTimestamp] = params[:startTimestamp] if params[:startTimestamp]
|
74
|
+
get_params[:endTimestamp] = params[:endTimestamp] if params[:endTimestamp]
|
75
|
+
|
76
|
+
response = @http_client.get(path, params: get_params)
|
77
|
+
result = JPSClient::Response.new(response)
|
78
|
+
|
79
|
+
# 处理响应数据格式
|
80
|
+
response_data = result.to_h
|
81
|
+
if response_data && response_data['data'] && response_data['data']['packages']
|
82
|
+
# 新的API格式:返回 packages 数组
|
83
|
+
response_data['data'] = response_data['data']['packages']
|
84
|
+
end
|
85
|
+
|
86
|
+
return response_data
|
87
|
+
end
|
88
|
+
|
89
|
+
# 更新项目包信息(备注等)
|
90
|
+
def update_project_package(id:, description:nil)
|
91
|
+
config = @request_config && @request_config["project_package_update"]
|
92
|
+
raise JPSClient::ExceptionError, "Missing config for project_package_update" unless config && config["url"]
|
93
|
+
path = config["url"]
|
94
|
+
|
95
|
+
body_params = {
|
96
|
+
id: id,
|
97
|
+
description: description
|
98
|
+
}.compact # 移除nil值
|
99
|
+
|
100
|
+
response = @http_client.post(path, body: body_params)
|
101
|
+
result = JPSClient::Response.new(response)
|
102
|
+
|
103
|
+
# 处理 401 错误,自动重新登录
|
104
|
+
if result.need_login?
|
105
|
+
do_login(force_login: true)
|
106
|
+
# 重试请求
|
107
|
+
response = @http_client.post(path, body: body_params)
|
108
|
+
result = JPSClient::Response.new(response)
|
109
|
+
end
|
110
|
+
|
111
|
+
return result.to_h
|
112
|
+
end
|
113
|
+
|
114
|
+
# 签名项目包
|
115
|
+
def sign_project_package(packageId:nil, certId:nil)
|
116
|
+
config = @request_config && @request_config["project_package_sign"]
|
117
|
+
raise JPSClient::ExceptionError, "Missing config for project_package_sign" unless config && config["url"]
|
118
|
+
path = config["url"]
|
119
|
+
|
120
|
+
body_params = {
|
121
|
+
projectPackageId: packageId, # 根据文档使用 projectPackageId
|
122
|
+
certId: certId
|
123
|
+
}
|
124
|
+
|
125
|
+
response = @http_client.post(path, body: body_params)
|
126
|
+
result = JPSClient::Response.new(response)
|
127
|
+
|
128
|
+
# 处理 401 错误,自动重新登录
|
129
|
+
if result.need_login?
|
130
|
+
do_login(force_login: true)
|
131
|
+
# 重试请求
|
132
|
+
response = @http_client.post(path, body: body_params)
|
133
|
+
result = JPSClient::Response.new(response)
|
134
|
+
end
|
135
|
+
|
136
|
+
return result.to_h
|
137
|
+
end
|
138
|
+
|
139
|
+
# 发送项目包消息
|
140
|
+
def send_project_package_message(projectId:nil, packageId:nil, chatEnv: nil, receiveType:nil, indexNo:nil)
|
141
|
+
config = @request_config && @request_config["project_package_send_message"]
|
142
|
+
raise JPSClient::ExceptionError, "Missing config for project_package_send_message" unless config && config["url"]
|
143
|
+
path = config["url"]
|
144
|
+
|
145
|
+
body_params = {
|
146
|
+
receiveType: receiveType,
|
147
|
+
projectId: projectId,
|
148
|
+
projectPackageId: packageId,
|
149
|
+
chatEnv: chatEnv
|
150
|
+
}
|
151
|
+
|
152
|
+
# 添加可选参数
|
153
|
+
body_params[:indexNo] = indexNo if indexNo
|
154
|
+
|
155
|
+
response = @http_client.post(path, body: body_params)
|
156
|
+
result = JPSClient::Response.new(response)
|
157
|
+
|
158
|
+
# 处理 401 错误,自动重新登录
|
159
|
+
if result.need_login?
|
160
|
+
do_login(force_login: true)
|
161
|
+
# 重试请求
|
162
|
+
response = @http_client.post(path, body: body_params)
|
163
|
+
result = JPSClient::Response.new(response)
|
164
|
+
end
|
165
|
+
|
166
|
+
return result.to_h
|
167
|
+
end
|
168
|
+
|
169
|
+
# 绑定提交记录到项目包
|
170
|
+
def bind_commit_to_package(commitId:, projectPackageIds:)
|
171
|
+
config = @request_config && @request_config["project_package_bind_commit"]
|
172
|
+
raise JPSClient::ExceptionError, "Missing config for project_package_bind_commit" unless config && config["url"]
|
173
|
+
path = config["url"]
|
174
|
+
|
175
|
+
body_params = {
|
176
|
+
commitId: commitId,
|
177
|
+
projectPackageIds: projectPackageIds
|
178
|
+
}
|
179
|
+
|
180
|
+
response = @http_client.post(path, body: body_params)
|
181
|
+
result = JPSClient::Response.new(response)
|
182
|
+
|
183
|
+
# 处理 401 错误,自动重新登录
|
184
|
+
if result.need_login?
|
185
|
+
do_login(force_login: true)
|
186
|
+
# 重试请求
|
187
|
+
response = @http_client.post(path, body: body_params)
|
188
|
+
result = JPSClient::Response.new(response)
|
189
|
+
end
|
190
|
+
|
191
|
+
return result.to_h
|
192
|
+
end
|
193
|
+
|
194
|
+
# 预览项目包
|
195
|
+
def preview_project_package(params:)
|
196
|
+
config = @request_config && @request_config["project_package_preview"]
|
197
|
+
raise JPSClient::ExceptionError, "Missing config for project_package_preview" unless config && config["url"]
|
198
|
+
path = config["url"]
|
199
|
+
|
200
|
+
get_params = {
|
201
|
+
id: params[:id],
|
202
|
+
url: params[:url],
|
203
|
+
packId: params[:packId],
|
204
|
+
packageType: params[:packageType],
|
205
|
+
packageVersion: params[:packageVersion],
|
206
|
+
projectName: params[:projectName]
|
207
|
+
}.compact # 移除nil值
|
208
|
+
|
209
|
+
response = @http_client.get(path, params: get_params)
|
210
|
+
result = JPSClient::Response.new(response)
|
211
|
+
|
212
|
+
# 处理 401 错误,自动重新登录
|
213
|
+
if result.need_login?
|
214
|
+
do_login(force_login: true)
|
215
|
+
# 重试请求
|
216
|
+
response = @http_client.get(path, params: get_params)
|
217
|
+
result = JPSClient::Response.new(response)
|
218
|
+
end
|
219
|
+
|
220
|
+
return result.to_h
|
221
|
+
end
|
222
|
+
|
223
|
+
# 获取项目包绑定列表
|
224
|
+
def get_project_package_bind_list(projectId:)
|
225
|
+
config = @request_config && @request_config["project_package_bind_list"]
|
226
|
+
raise JPSClient::ExceptionError, "Missing config for project_package_bind_list" unless config && config["url"]
|
227
|
+
path = config["url"]
|
228
|
+
|
229
|
+
get_params = {
|
230
|
+
projectId: projectId
|
231
|
+
}
|
232
|
+
|
233
|
+
response = @http_client.get(path, params: get_params)
|
234
|
+
result = JPSClient::Response.new(response)
|
235
|
+
|
236
|
+
# 处理 401 错误,自动重新登录
|
237
|
+
if result.need_login?
|
238
|
+
do_login(force_login: true)
|
239
|
+
# 重试请求
|
240
|
+
response = @http_client.get(path, params: get_params)
|
241
|
+
result = JPSClient::Response.new(response)
|
242
|
+
end
|
243
|
+
|
244
|
+
return result.to_h
|
245
|
+
end
|
246
|
+
|
247
|
+
end
|
248
|
+
end
|
249
|
+
end
|
@@ -0,0 +1,165 @@
|
|
1
|
+
module JPSClient
|
2
|
+
module API
|
3
|
+
# Publisher 相关 API
|
4
|
+
# 自动生成的模块,处理 publisher 相关接口
|
5
|
+
module Publisher
|
6
|
+
|
7
|
+
# Update Publisher
|
8
|
+
#
|
9
|
+
# @param params [Hash] 请求参数
|
10
|
+
# @return [Hash] API响应
|
11
|
+
def update_publisher(publisherId:, params: {})
|
12
|
+
config = @request_config && @request_config["publisher_publisher"]
|
13
|
+
raise JPSClient::ExceptionError, "Missing config for publisher_publisher" unless config && config["url"]
|
14
|
+
|
15
|
+
path = config["url"]
|
16
|
+
path = path.gsub("{publisherId}", publisherId.to_s)
|
17
|
+
|
18
|
+
response = @http_client.put(path, body: params)
|
19
|
+
result = JPSClient::Response.new(response)
|
20
|
+
|
21
|
+
if result.need_login?
|
22
|
+
do_login(force_login: true)
|
23
|
+
response = @http_client.put(path, body: params)
|
24
|
+
result = JPSClient::Response.new(response)
|
25
|
+
end
|
26
|
+
|
27
|
+
return result.to_h
|
28
|
+
end
|
29
|
+
|
30
|
+
# Delete Publisher
|
31
|
+
#
|
32
|
+
# @param params [Hash] 请求参数
|
33
|
+
# @return [Hash] API响应
|
34
|
+
def delete_publisher(publisherId:, params: {})
|
35
|
+
config = @request_config && @request_config["publisher_publisher"]
|
36
|
+
raise JPSClient::ExceptionError, "Missing config for publisher_publisher" unless config && config["url"]
|
37
|
+
|
38
|
+
path = config["url"]
|
39
|
+
path = path.gsub("{publisherId}", publisherId.to_s)
|
40
|
+
|
41
|
+
response = @http_client.delete(path)
|
42
|
+
result = JPSClient::Response.new(response)
|
43
|
+
|
44
|
+
if result.need_login?
|
45
|
+
do_login(force_login: true)
|
46
|
+
response = @http_client.delete(path)
|
47
|
+
result = JPSClient::Response.new(response)
|
48
|
+
end
|
49
|
+
|
50
|
+
return result.to_h
|
51
|
+
end
|
52
|
+
|
53
|
+
# Create Publishers
|
54
|
+
#
|
55
|
+
# @param params [Hash] 请求参数
|
56
|
+
# @return [Hash] API响应
|
57
|
+
def create_publishers(params: {})
|
58
|
+
config = @request_config && @request_config["publisher_publishers"]
|
59
|
+
raise JPSClient::ExceptionError, "Missing config for publisher_publishers" unless config && config["url"]
|
60
|
+
|
61
|
+
path = config["url"]
|
62
|
+
|
63
|
+
response = @http_client.post(path, body: params)
|
64
|
+
result = JPSClient::Response.new(response)
|
65
|
+
|
66
|
+
if result.need_login?
|
67
|
+
do_login(force_login: true)
|
68
|
+
response = @http_client.post(path, body: params)
|
69
|
+
result = JPSClient::Response.new(response)
|
70
|
+
end
|
71
|
+
|
72
|
+
return result.to_h
|
73
|
+
end
|
74
|
+
|
75
|
+
# Create Stream
|
76
|
+
#
|
77
|
+
# @param params [Hash] 请求参数
|
78
|
+
# @return [Hash] API响应
|
79
|
+
def create_stream(params: {})
|
80
|
+
config = @request_config && @request_config["publisher_stream"]
|
81
|
+
raise JPSClient::ExceptionError, "Missing config for publisher_stream" unless config && config["url"]
|
82
|
+
|
83
|
+
path = config["url"]
|
84
|
+
|
85
|
+
response = @http_client.post(path, body: params)
|
86
|
+
result = JPSClient::Response.new(response)
|
87
|
+
|
88
|
+
if result.need_login?
|
89
|
+
do_login(force_login: true)
|
90
|
+
response = @http_client.post(path, body: params)
|
91
|
+
result = JPSClient::Response.new(response)
|
92
|
+
end
|
93
|
+
|
94
|
+
return result.to_h
|
95
|
+
end
|
96
|
+
|
97
|
+
# Create Weights
|
98
|
+
#
|
99
|
+
# @param params [Hash] 请求参数
|
100
|
+
# @return [Hash] API响应
|
101
|
+
def create_weights(params: {})
|
102
|
+
config = @request_config && @request_config["publisher_weights"]
|
103
|
+
raise JPSClient::ExceptionError, "Missing config for publisher_weights" unless config && config["url"]
|
104
|
+
|
105
|
+
path = config["url"]
|
106
|
+
|
107
|
+
response = @http_client.post(path, body: params)
|
108
|
+
result = JPSClient::Response.new(response)
|
109
|
+
|
110
|
+
if result.need_login?
|
111
|
+
do_login(force_login: true)
|
112
|
+
response = @http_client.post(path, body: params)
|
113
|
+
result = JPSClient::Response.new(response)
|
114
|
+
end
|
115
|
+
|
116
|
+
return result.to_h
|
117
|
+
end
|
118
|
+
|
119
|
+
# Create Detail
|
120
|
+
#
|
121
|
+
# @param params [Hash] 请求参数
|
122
|
+
# @return [Hash] API响应
|
123
|
+
def create_detail(params: {})
|
124
|
+
config = @request_config && @request_config["publisher_detail"]
|
125
|
+
raise JPSClient::ExceptionError, "Missing config for publisher_detail" unless config && config["url"]
|
126
|
+
|
127
|
+
path = config["url"]
|
128
|
+
|
129
|
+
response = @http_client.post(path, body: params)
|
130
|
+
result = JPSClient::Response.new(response)
|
131
|
+
|
132
|
+
if result.need_login?
|
133
|
+
do_login(force_login: true)
|
134
|
+
response = @http_client.post(path, body: params)
|
135
|
+
result = JPSClient::Response.new(response)
|
136
|
+
end
|
137
|
+
|
138
|
+
return result.to_h
|
139
|
+
end
|
140
|
+
|
141
|
+
# Get Store Applications Detail
|
142
|
+
#
|
143
|
+
# @param params [Hash] 请求参数
|
144
|
+
# @return [Hash] API响应
|
145
|
+
def get_store_applications_detail(publisherId:, params: {})
|
146
|
+
config = @request_config && @request_config["publisher_store_applications_detail"]
|
147
|
+
raise JPSClient::ExceptionError, "Missing config for publisher_store_applications_detail" unless config && config["url"]
|
148
|
+
|
149
|
+
path = config["url"]
|
150
|
+
path = path.gsub("{publisherId}", publisherId.to_s)
|
151
|
+
|
152
|
+
response = @http_client.get(path, params: params)
|
153
|
+
result = JPSClient::Response.new(response)
|
154
|
+
|
155
|
+
if result.need_login?
|
156
|
+
do_login(force_login: true)
|
157
|
+
response = @http_client.get(path, params: params)
|
158
|
+
result = JPSClient::Response.new(response)
|
159
|
+
end
|
160
|
+
|
161
|
+
return result.to_h
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|