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,30 @@
|
|
1
|
+
module JPSClient
|
2
|
+
module API
|
3
|
+
# LarkWikiNode 相关 API
|
4
|
+
# 自动生成的模块,处理 lark_wiki_node 相关接口
|
5
|
+
module LarkWikiNode
|
6
|
+
|
7
|
+
# Get List
|
8
|
+
#
|
9
|
+
# @param params [Hash] 请求参数
|
10
|
+
# @return [Hash] API响应
|
11
|
+
def get_list(params: {})
|
12
|
+
config = @request_config && @request_config["lark_wiki_node_list"]
|
13
|
+
raise JPSClient::ExceptionError, "Missing config for lark_wiki_node_list" unless config && config["url"]
|
14
|
+
|
15
|
+
path = config["url"]
|
16
|
+
|
17
|
+
response = @http_client.post(path, body: params)
|
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
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module JPSClient
|
2
|
+
module API
|
3
|
+
# LarkWikiSpace 相关 API
|
4
|
+
# 自动生成的模块,处理 lark_wiki_space 相关接口
|
5
|
+
module LarkWikiSpace
|
6
|
+
|
7
|
+
# Get List
|
8
|
+
#
|
9
|
+
# @param params [Hash] 请求参数
|
10
|
+
# @return [Hash] API响应
|
11
|
+
def get_list(params: {})
|
12
|
+
config = @request_config && @request_config["lark_wiki_space_list"]
|
13
|
+
raise JPSClient::ExceptionError, "Missing config for lark_wiki_space_list" unless config && config["url"]
|
14
|
+
|
15
|
+
path = config["url"]
|
16
|
+
|
17
|
+
response = @http_client.get(path, params: params)
|
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
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,290 @@
|
|
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
|
13
|
+
# 只在实际使用时才加载对应的API模块
|
14
|
+
class LazyClient
|
15
|
+
# 核心模块 - 始终加载
|
16
|
+
CORE_MODULES = %w[project file cert].freeze
|
17
|
+
|
18
|
+
# API模块映射表
|
19
|
+
API_MODULES = {
|
20
|
+
app_level: 'AppLevel',
|
21
|
+
app_resource: 'AppResource',
|
22
|
+
app_resource_version: 'AppResourceVersion',
|
23
|
+
apple_account: 'AppleAccount',
|
24
|
+
application: 'Application',
|
25
|
+
application_category: 'ApplicationCategory',
|
26
|
+
application_design: 'ApplicationDesign',
|
27
|
+
application_income: 'ApplicationIncome',
|
28
|
+
application_sales: 'ApplicationSales',
|
29
|
+
application_version: 'ApplicationVersion',
|
30
|
+
assets_category: 'AssetsCategory',
|
31
|
+
bug: 'Bug',
|
32
|
+
cert: 'Cert',
|
33
|
+
collect: 'Collect',
|
34
|
+
collection: 'Collection',
|
35
|
+
commit_log: 'CommitLog',
|
36
|
+
creative: 'Creative',
|
37
|
+
custom_application: 'CustomApplication',
|
38
|
+
custom_application_web: 'CustomApplicationWeb',
|
39
|
+
document_text: 'DocumentText',
|
40
|
+
experience: 'Experience',
|
41
|
+
experience_category: 'ExperienceCategory',
|
42
|
+
fgui_export: 'FguiExport',
|
43
|
+
file: 'File',
|
44
|
+
game_assets: 'GameAssets',
|
45
|
+
healthy: 'Healthy',
|
46
|
+
icon_and_snapshot: 'IconAndSnapshot',
|
47
|
+
idea: 'Idea',
|
48
|
+
jssdk: 'Jssdk',
|
49
|
+
lark_bitable: 'LarkBitable',
|
50
|
+
lark_chat_group: 'LarkChatGroup',
|
51
|
+
lark_comment: 'LarkComment',
|
52
|
+
lark_task: 'LarkTask',
|
53
|
+
lark_task_list: 'LarkTaskList',
|
54
|
+
lark_task_section: 'LarkTaskSection',
|
55
|
+
lark_user: 'LarkUser',
|
56
|
+
lark_wiki_node: 'LarkWikiNode',
|
57
|
+
lark_wiki_space: 'LarkWikiSpace',
|
58
|
+
login: 'Login',
|
59
|
+
m3u8: 'M3u8',
|
60
|
+
menu: 'Menu',
|
61
|
+
project: 'Project',
|
62
|
+
project_package: 'ProjectPackage',
|
63
|
+
publisher: 'Publisher',
|
64
|
+
publisher_category: 'PublisherCategory',
|
65
|
+
publisher_group: 'PublisherGroup',
|
66
|
+
publisher_group_category: 'PublisherGroupCategory',
|
67
|
+
requirements: 'Requirements',
|
68
|
+
requirements_category: 'RequirementsCategory',
|
69
|
+
resource_category: 'ResourceCategory',
|
70
|
+
role: 'Role',
|
71
|
+
simple_search: 'SimpleSearch',
|
72
|
+
sketch: 'Sketch',
|
73
|
+
sketch_category: 'SketchCategory',
|
74
|
+
sov: 'Sov',
|
75
|
+
statistics: 'Statistics',
|
76
|
+
store: 'Store',
|
77
|
+
survey: 'Survey',
|
78
|
+
survey_category: 'SurveyCategory',
|
79
|
+
tag: 'Tag',
|
80
|
+
tool: 'Tool',
|
81
|
+
tool_category: 'ToolCategory',
|
82
|
+
trending: 'Trending',
|
83
|
+
ud_id: 'UdId',
|
84
|
+
user: 'User',
|
85
|
+
util: 'Util',
|
86
|
+
video_cover: 'VideoCover',
|
87
|
+
webhook: 'Webhook',
|
88
|
+
workflow: 'Workflow'
|
89
|
+
}.freeze
|
90
|
+
|
91
|
+
attr_accessor :token, :baseurl, :request_config, :http_client, :api_config
|
92
|
+
attr_reader :config_json, :config_file
|
93
|
+
|
94
|
+
def initialize(config_file:, preload_modules: nil)
|
95
|
+
begin
|
96
|
+
@config_file = config_file
|
97
|
+
@loaded_modules = {}
|
98
|
+
|
99
|
+
raise ExceptionError, "必须提供配置文件路径" unless @config_file
|
100
|
+
raise ExceptionError, "配置文件不存在: #{@config_file}" unless File.exist?(@config_file)
|
101
|
+
|
102
|
+
@config_json = JSON.parse(File.read(@config_file))
|
103
|
+
@baseurl = @config_json["pgyerapps_base_url"]
|
104
|
+
@request_config = @config_json["api_path_config"]
|
105
|
+
|
106
|
+
# 初始化API配置管理器
|
107
|
+
@api_config = ApiConfig.new(@config_json)
|
108
|
+
|
109
|
+
# 从 auth_config 获取配置
|
110
|
+
auth_config = @config_json["auth_config"]
|
111
|
+
@pgyer_aes_key = auth_config["aes_key"]
|
112
|
+
|
113
|
+
# 加载 JPS 登录配置
|
114
|
+
@jps_config = LoginConfig.from_json(auth_config)
|
115
|
+
|
116
|
+
# 初始化 token 管理器
|
117
|
+
@token_manager = Token.new(@jps_config)
|
118
|
+
|
119
|
+
# 尝试加载已保存的 token
|
120
|
+
if @token_manager.load && @token_manager.valid?
|
121
|
+
@token = @token_manager.to_h
|
122
|
+
end
|
123
|
+
|
124
|
+
# 初始化共享的 HTTP 客户端
|
125
|
+
@http_client = HttpClient.new(base_url: @baseurl)
|
126
|
+
@http_client.update_token(@token["token"]) if @token && @token["token"]
|
127
|
+
|
128
|
+
# 预加载核心模块
|
129
|
+
CORE_MODULES.each { |mod| load_module(mod) }
|
130
|
+
|
131
|
+
# 预加载用户指定的模块
|
132
|
+
if preload_modules
|
133
|
+
Array(preload_modules).each { |mod| load_module(mod.to_s) }
|
134
|
+
end
|
135
|
+
|
136
|
+
rescue JSON::ParserError => error
|
137
|
+
raise ExceptionError.new("配置文件格式错误 (#{@config_file}): #{error.message}")
|
138
|
+
rescue ExceptionError
|
139
|
+
raise # 重新抛出 JPS 异常
|
140
|
+
rescue => error
|
141
|
+
raise ExceptionError.new("加载配置文件失败 (#{@config_file}): #{error.message}")
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
# 提供共享的HTTP客户端给其他模块
|
146
|
+
def shared_http_client
|
147
|
+
@http_client
|
148
|
+
end
|
149
|
+
|
150
|
+
# 核心登录功能
|
151
|
+
def do_login(force_login: false)
|
152
|
+
# 使用 token 管理器统一处理
|
153
|
+
if force_login
|
154
|
+
# 强制重新登录
|
155
|
+
@token_manager.clear # 清除旧 token
|
156
|
+
auth = Auth.new(@jps_config)
|
157
|
+
result = auth.login
|
158
|
+
|
159
|
+
if result == :user_cancelled
|
160
|
+
Logger.instance.fancyinfo_error("用户取消了登录操作")
|
161
|
+
return false
|
162
|
+
elsif result == true
|
163
|
+
# 保存新 token
|
164
|
+
@token_manager.save(auth.access_token, auth.username, auth.expires_at)
|
165
|
+
update_token_everywhere()
|
166
|
+
return true
|
167
|
+
else
|
168
|
+
Logger.instance.fancyinfo_error("登录失败,未能获取有效token")
|
169
|
+
return false
|
170
|
+
end
|
171
|
+
else
|
172
|
+
# 尝试加载并验证现有 token
|
173
|
+
if @token_manager.load && @token_manager.valid?
|
174
|
+
update_token_everywhere()
|
175
|
+
return true
|
176
|
+
else
|
177
|
+
# Token 无效或不存在,需要重新登录
|
178
|
+
auth = Auth.new(@jps_config)
|
179
|
+
result = auth.login
|
180
|
+
|
181
|
+
if result == :user_cancelled
|
182
|
+
Logger.instance.fancyinfo_error("用户取消了登录操作")
|
183
|
+
return false
|
184
|
+
elsif result == true
|
185
|
+
# 保存新 token
|
186
|
+
@token_manager.save(auth.access_token, auth.username, auth.expires_at)
|
187
|
+
update_token_everywhere()
|
188
|
+
return true
|
189
|
+
else
|
190
|
+
Logger.instance.fancyinfo_error("登录失败,未能获取有效token")
|
191
|
+
return false
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
# 获取已加载的模块列表
|
198
|
+
def loaded_modules
|
199
|
+
@loaded_modules.keys
|
200
|
+
end
|
201
|
+
|
202
|
+
# 手动加载指定模块
|
203
|
+
def load_module(module_name)
|
204
|
+
module_key = module_name.to_sym
|
205
|
+
return true if @loaded_modules[module_key]
|
206
|
+
|
207
|
+
begin
|
208
|
+
require "jpsclient/api/#{module_name}"
|
209
|
+
module_class = API_MODULES[module_key]
|
210
|
+
if module_class
|
211
|
+
self.class.send(:include, API.const_get(module_class))
|
212
|
+
@loaded_modules[module_key] = true
|
213
|
+
# Logger.instance.fancyinfo_info("Loaded module: #{module_name}")
|
214
|
+
true
|
215
|
+
else
|
216
|
+
false
|
217
|
+
end
|
218
|
+
rescue LoadError => e
|
219
|
+
Logger.instance.fancyinfo_error("Failed to load module #{module_name}: #{e.message}")
|
220
|
+
false
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
# 重写 method_missing 来实现延迟加载
|
225
|
+
def method_missing(method_name, *args, **kwargs, &block)
|
226
|
+
# 尝试根据方法名猜测模块
|
227
|
+
module_name = guess_module_from_method(method_name)
|
228
|
+
|
229
|
+
if module_name && load_module(module_name)
|
230
|
+
# 模块加载成功,再次尝试调用方法
|
231
|
+
if respond_to?(method_name)
|
232
|
+
return send(method_name, *args, **kwargs, &block)
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
super
|
237
|
+
end
|
238
|
+
|
239
|
+
def respond_to_missing?(method_name, include_private = false)
|
240
|
+
module_name = guess_module_from_method(method_name)
|
241
|
+
module_name && API_MODULES.key?(module_name.to_sym) || super
|
242
|
+
end
|
243
|
+
|
244
|
+
private
|
245
|
+
|
246
|
+
# 统一更新token到所有组件
|
247
|
+
def update_token_everywhere
|
248
|
+
@token = @token_manager.to_h
|
249
|
+
@http_client.update_token(@token["token"]) if @http_client && @token
|
250
|
+
end
|
251
|
+
|
252
|
+
# 根据方法名猜测对应的模块
|
253
|
+
def guess_module_from_method(method_name)
|
254
|
+
method_str = method_name.to_s
|
255
|
+
|
256
|
+
# 常见的方法名模式匹配
|
257
|
+
case method_str
|
258
|
+
when /^(get|create|update|delete)_app_level/
|
259
|
+
'app_level'
|
260
|
+
when /^(get|create|update|delete|copy|transfer).*resource/
|
261
|
+
'app_resource'
|
262
|
+
when /^(get|create|update|delete).*application/
|
263
|
+
'application'
|
264
|
+
when /bug|get_list/
|
265
|
+
'bug'
|
266
|
+
when /user/
|
267
|
+
'user'
|
268
|
+
when /project/
|
269
|
+
'project'
|
270
|
+
when /collection/
|
271
|
+
'collection'
|
272
|
+
when /lark/
|
273
|
+
# 提取lark相关的模块
|
274
|
+
if method_str.include?('task_list')
|
275
|
+
'lark_task_list'
|
276
|
+
elsif method_str.include?('task_section')
|
277
|
+
'lark_task_section'
|
278
|
+
elsif method_str.include?('task')
|
279
|
+
'lark_task'
|
280
|
+
elsif method_str.include?('wiki')
|
281
|
+
method_str.include?('space') ? 'lark_wiki_space' : 'lark_wiki_node'
|
282
|
+
else
|
283
|
+
nil
|
284
|
+
end
|
285
|
+
else
|
286
|
+
nil
|
287
|
+
end
|
288
|
+
end
|
289
|
+
end
|
290
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
module JPSClient
|
2
|
+
module API
|
3
|
+
# Login 相关 API
|
4
|
+
# 自动生成的模块,处理 login 相关接口
|
5
|
+
module Login
|
6
|
+
|
7
|
+
# Create Logout
|
8
|
+
#
|
9
|
+
# @param params [Hash] 请求参数
|
10
|
+
# @return [Hash] API响应
|
11
|
+
def create_logout(params: {})
|
12
|
+
config = @request_config && @request_config["login_logout"]
|
13
|
+
raise JPSClient::ExceptionError, "Missing config for login_logout" unless config && config["url"]
|
14
|
+
|
15
|
+
path = config["url"]
|
16
|
+
|
17
|
+
response = @http_client.post(path, body: params)
|
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
|
27
|
+
end
|
28
|
+
|
29
|
+
# Create Lark Login
|
30
|
+
#
|
31
|
+
# @param params [Hash] 请求参数
|
32
|
+
# @return [Hash] API响应
|
33
|
+
def create_lark_login(params: {})
|
34
|
+
config = @request_config && @request_config["login_lark_login"]
|
35
|
+
raise JPSClient::ExceptionError, "Missing config for login_lark_login" unless config && config["url"]
|
36
|
+
|
37
|
+
path = config["url"]
|
38
|
+
|
39
|
+
response = @http_client.post(path, body: params)
|
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
|
49
|
+
end
|
50
|
+
|
51
|
+
# Get Swagger Lark Login
|
52
|
+
#
|
53
|
+
# @param params [Hash] 请求参数
|
54
|
+
# @return [Hash] API响应
|
55
|
+
def get_swagger_lark_login(params: {})
|
56
|
+
config = @request_config && @request_config["login_swagger_lark_login"]
|
57
|
+
raise JPSClient::ExceptionError, "Missing config for login_swagger_lark_login" unless config && config["url"]
|
58
|
+
|
59
|
+
path = config["url"]
|
60
|
+
|
61
|
+
response = @http_client.get(path, params: params)
|
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
|
71
|
+
end
|
72
|
+
|
73
|
+
# Get Get User By Uuid
|
74
|
+
#
|
75
|
+
# @param params [Hash] 请求参数
|
76
|
+
# @return [Hash] API响应
|
77
|
+
def get_get_user_by_uuid(params: {})
|
78
|
+
config = @request_config && @request_config["login_get_user_by_uuid"]
|
79
|
+
raise JPSClient::ExceptionError, "Missing config for login_get_user_by_uuid" unless config && config["url"]
|
80
|
+
|
81
|
+
path = config["url"]
|
82
|
+
|
83
|
+
response = @http_client.get(path, params: params)
|
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
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module JPSClient
|
2
|
+
module API
|
3
|
+
# M3u8 相关 API
|
4
|
+
# 自动生成的模块,处理 m3u8 相关接口
|
5
|
+
module M3u8
|
6
|
+
|
7
|
+
# Get To Mp4
|
8
|
+
#
|
9
|
+
# @param params [Hash] 请求参数
|
10
|
+
# @return [Hash] API响应
|
11
|
+
def get_to_mp4(params: {})
|
12
|
+
config = @request_config && @request_config["m3u8_to_mp4"]
|
13
|
+
raise JPSClient::ExceptionError, "Missing config for m3u8_to_mp4" unless config && config["url"]
|
14
|
+
|
15
|
+
path = config["url"]
|
16
|
+
|
17
|
+
response = @http_client.get(path, params: params)
|
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
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,143 @@
|
|
1
|
+
module JPSClient
|
2
|
+
module API
|
3
|
+
# Menu 相关 API
|
4
|
+
# 自动生成的模块,处理 menu 相关接口
|
5
|
+
module Menu
|
6
|
+
|
7
|
+
# Get Menu Detail
|
8
|
+
#
|
9
|
+
# @param params [Hash] 请求参数
|
10
|
+
# @return [Hash] API响应
|
11
|
+
def get_menu_detail(menuId:, params: {})
|
12
|
+
config = @request_config && @request_config["menu_menu_detail"]
|
13
|
+
raise JPSClient::ExceptionError, "Missing config for menu_menu_detail" unless config && config["url"]
|
14
|
+
|
15
|
+
path = config["url"]
|
16
|
+
path = path.gsub("{menuId}", menuId.to_s)
|
17
|
+
|
18
|
+
response = @http_client.get(path, params: params)
|
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
|
28
|
+
end
|
29
|
+
|
30
|
+
# Update Menu
|
31
|
+
#
|
32
|
+
# @param params [Hash] 请求参数
|
33
|
+
# @return [Hash] API响应
|
34
|
+
def update_menu(menuId:, params: {})
|
35
|
+
config = @request_config && @request_config["menu_menu"]
|
36
|
+
raise JPSClient::ExceptionError, "Missing config for menu_menu" unless config && config["url"]
|
37
|
+
|
38
|
+
path = config["url"]
|
39
|
+
path = path.gsub("{menuId}", menuId.to_s)
|
40
|
+
|
41
|
+
response = @http_client.put(path, body: params)
|
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
|
51
|
+
end
|
52
|
+
|
53
|
+
# Delete Menu
|
54
|
+
#
|
55
|
+
# @param params [Hash] 请求参数
|
56
|
+
# @return [Hash] API响应
|
57
|
+
def delete_menu(menuId:, params: {})
|
58
|
+
config = @request_config && @request_config["menu_menu"]
|
59
|
+
raise JPSClient::ExceptionError, "Missing config for menu_menu" unless config && config["url"]
|
60
|
+
|
61
|
+
path = config["url"]
|
62
|
+
path = path.gsub("{menuId}", menuId.to_s)
|
63
|
+
|
64
|
+
response = @http_client.delete(path)
|
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
|
74
|
+
end
|
75
|
+
|
76
|
+
# Create Menu
|
77
|
+
#
|
78
|
+
# @param params [Hash] 请求参数
|
79
|
+
# @return [Hash] API响应
|
80
|
+
def create_menu(params: {})
|
81
|
+
config = @request_config && @request_config["menu_menu"]
|
82
|
+
raise JPSClient::ExceptionError, "Missing config for menu_menu" unless config && config["url"]
|
83
|
+
|
84
|
+
path = config["url"]
|
85
|
+
|
86
|
+
response = @http_client.post(path, body: params)
|
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
|
96
|
+
end
|
97
|
+
|
98
|
+
# Get Menus
|
99
|
+
#
|
100
|
+
# @param params [Hash] 请求参数
|
101
|
+
# @return [Hash] API响应
|
102
|
+
def get_menus(params: {})
|
103
|
+
config = @request_config && @request_config["menu_menus"]
|
104
|
+
raise JPSClient::ExceptionError, "Missing config for menu_menus" unless config && config["url"]
|
105
|
+
|
106
|
+
path = config["url"]
|
107
|
+
|
108
|
+
response = @http_client.get(path, params: params)
|
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
|
118
|
+
end
|
119
|
+
|
120
|
+
# Get Role
|
121
|
+
#
|
122
|
+
# @param params [Hash] 请求参数
|
123
|
+
# @return [Hash] API响应
|
124
|
+
def get_role(params: {})
|
125
|
+
config = @request_config && @request_config["menu_role"]
|
126
|
+
raise JPSClient::ExceptionError, "Missing config for menu_role" unless config && config["url"]
|
127
|
+
|
128
|
+
path = config["url"]
|
129
|
+
|
130
|
+
response = @http_client.get(path, params: params)
|
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
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|