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.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/lib/jpsclient/api/android_jks.rb +7 -70
  3. data/lib/jpsclient/api/app_level.rb +6 -60
  4. data/lib/jpsclient/api/app_resource.rb +7 -70
  5. data/lib/jpsclient/api/apple_account.rb +6 -60
  6. data/lib/jpsclient/api/apple_bundle_id.rb +1 -11
  7. data/lib/jpsclient/api/apple_cert.rb +1 -11
  8. data/lib/jpsclient/api/apple_profile.rb +1 -11
  9. data/lib/jpsclient/api/application.rb +12 -121
  10. data/lib/jpsclient/api/application_income.rb +2 -20
  11. data/lib/jpsclient/api/application_sales.rb +2 -20
  12. data/lib/jpsclient/api/application_version.rb +3 -30
  13. data/lib/jpsclient/api/archived_outdated/app_resource_version.rb +2 -20
  14. data/lib/jpsclient/api/archived_outdated/application_category.rb +5 -50
  15. data/lib/jpsclient/api/archived_outdated/application_design.rb +5 -50
  16. data/lib/jpsclient/api/archived_outdated/assets_category.rb +5 -50
  17. data/lib/jpsclient/api/archived_outdated/experience.rb +6 -60
  18. data/lib/jpsclient/api/archived_outdated/experience_category.rb +4 -40
  19. data/lib/jpsclient/api/archived_outdated/icon_and_snapshot.rb +2 -20
  20. data/lib/jpsclient/api/archived_outdated/publisher_category.rb +6 -60
  21. data/lib/jpsclient/api/archived_outdated/publisher_group_category.rb +5 -50
  22. data/lib/jpsclient/api/archived_outdated/requirements_category.rb +4 -40
  23. data/lib/jpsclient/api/archived_outdated/resource_category.rb +5 -50
  24. data/lib/jpsclient/api/archived_outdated/sketch_category.rb +4 -40
  25. data/lib/jpsclient/api/archived_outdated/survey_category.rb +4 -40
  26. data/lib/jpsclient/api/archived_outdated/tool_category.rb +5 -50
  27. data/lib/jpsclient/api/bug.rb +6 -60
  28. data/lib/jpsclient/api/category.rb +6 -60
  29. data/lib/jpsclient/api/cert.rb +1 -12
  30. data/lib/jpsclient/api/collect.rb +2 -20
  31. data/lib/jpsclient/api/collection.rb +7 -70
  32. data/lib/jpsclient/api/commit_log.rb +5 -52
  33. data/lib/jpsclient/api/creative.rb +2 -20
  34. data/lib/jpsclient/api/custom_application.rb +10 -100
  35. data/lib/jpsclient/api/custom_application_web.rb +2 -20
  36. data/lib/jpsclient/api/design.rb +5 -50
  37. data/lib/jpsclient/api/document_text.rb +1 -10
  38. data/lib/jpsclient/api/fgui_export.rb +2 -20
  39. data/lib/jpsclient/api/file.rb +4 -41
  40. data/lib/jpsclient/api/game_assets.rb +6 -60
  41. data/lib/jpsclient/api/healthy.rb +1 -10
  42. data/lib/jpsclient/api/idea.rb +5 -50
  43. data/lib/jpsclient/api/image_search.rb +2 -20
  44. data/lib/jpsclient/api/js_sdk.rb +1 -10
  45. data/lib/jpsclient/api/lark_bitable.rb +1 -10
  46. data/lib/jpsclient/api/lark_card_message.rb +1 -10
  47. data/lib/jpsclient/api/lark_chat_group.rb +1 -10
  48. data/lib/jpsclient/api/lark_comment.rb +5 -50
  49. data/lib/jpsclient/api/lark_department.rb +1 -10
  50. data/lib/jpsclient/api/lark_file.rb +1 -10
  51. data/lib/jpsclient/api/lark_leave_approval.rb +1 -10
  52. data/lib/jpsclient/api/lark_message.rb +1 -10
  53. data/lib/jpsclient/api/lark_task.rb +6 -60
  54. data/lib/jpsclient/api/lark_task_list.rb +5 -50
  55. data/lib/jpsclient/api/lark_task_section.rb +3 -30
  56. data/lib/jpsclient/api/lark_user.rb +1 -10
  57. data/lib/jpsclient/api/lark_wiki_node.rb +1 -10
  58. data/lib/jpsclient/api/lark_wiki_space.rb +1 -10
  59. data/lib/jpsclient/api/lazy_client.rb +39 -39
  60. data/lib/jpsclient/api/login.rb +4 -40
  61. data/lib/jpsclient/api/m3u8.rb +1 -10
  62. data/lib/jpsclient/api/menu.rb +6 -60
  63. data/lib/jpsclient/api/modular_client.rb +38 -38
  64. data/lib/jpsclient/api/nuget.rb +1 -10
  65. data/lib/jpsclient/api/permission.rb +5 -50
  66. data/lib/jpsclient/api/project.rb +2 -22
  67. data/lib/jpsclient/api/project_package.rb +9 -121
  68. data/lib/jpsclient/api/publisher.rb +7 -70
  69. data/lib/jpsclient/api/publisher_group.rb +5 -50
  70. data/lib/jpsclient/api/requirements.rb +6 -60
  71. data/lib/jpsclient/api/role.rb +7 -70
  72. data/lib/jpsclient/api/simple_search.rb +7 -70
  73. data/lib/jpsclient/api/sketch.rb +3 -30
  74. data/lib/jpsclient/api/sov.rb +1 -10
  75. data/lib/jpsclient/api/statistics.rb +1 -10
  76. data/lib/jpsclient/api/store.rb +1 -10
  77. data/lib/jpsclient/api/survey.rb +6 -60
  78. data/lib/jpsclient/api/tag.rb +6 -60
  79. data/lib/jpsclient/api/template.rb +5 -50
  80. data/lib/jpsclient/api/tool.rb +5 -50
  81. data/lib/jpsclient/api/trending.rb +1 -10
  82. data/lib/jpsclient/api/ud_id.rb +5 -50
  83. data/lib/jpsclient/api/user.rb +4 -40
  84. data/lib/jpsclient/api/util.rb +1 -10
  85. data/lib/jpsclient/api/video_cover.rb +1 -10
  86. data/lib/jpsclient/api/webhook.rb +5 -50
  87. data/lib/jpsclient/api/workflow.rb +5 -50
  88. data/lib/jpsclient/auth/auth.rb +21 -31
  89. data/lib/jpsclient/auth/token.rb +49 -95
  90. data/lib/jpsclient/base/client.rb +43 -38
  91. data/lib/jpsclient/http/http_client.rb +18 -2
  92. data/lib/jpsclient/version.rb +1 -1
  93. metadata +15 -1
@@ -14,16 +14,7 @@ module JPSClient
14
14
 
15
15
  path = config["url"]
16
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
17
+ return request_with_auth(:post, path, body: params)
27
18
  end
28
19
  end
29
20
  end
@@ -28,16 +28,7 @@ module JPSClient
28
28
  params[:startTime] = start_time if start_time
29
29
  params[:endTime] = end_time if end_time
30
30
 
31
- response = @http_client.get(path, params: params)
32
- result = JPSClient::Response.new(response)
33
-
34
- if result.need_login?
35
- do_login(force_login: true)
36
- response = @http_client.get(path, params: params)
37
- result = JPSClient::Response.new(response)
38
- end
39
-
40
- return result.to_h
31
+ return request_with_auth(:get, path, params: params)
41
32
  end
42
33
 
43
34
  end
@@ -14,16 +14,7 @@ module JPSClient
14
14
 
15
15
  path = config["url"]
16
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
17
+ return request_with_auth(:get, path, params: params)
27
18
  end
28
19
  end
29
20
  end
@@ -14,16 +14,7 @@ module JPSClient
14
14
 
15
15
  path = config["url"]
16
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
17
+ return request_with_auth(:post, path, body: params)
27
18
  end
28
19
 
29
20
  # Create Sync
@@ -36,16 +27,7 @@ module JPSClient
36
27
 
37
28
  path = config["url"]
38
29
 
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
30
+ return request_with_auth(:post, path, body: params)
49
31
  end
50
32
 
51
33
  # Create Delete
@@ -58,16 +40,7 @@ module JPSClient
58
40
 
59
41
  path = config["url"]
60
42
 
61
- response = @http_client.post(path, body: params)
62
- result = JPSClient::Response.new(response)
63
-
64
- if result.need_login?
65
- do_login(force_login: true)
66
- response = @http_client.post(path, body: params)
67
- result = JPSClient::Response.new(response)
68
- end
69
-
70
- return result.to_h
43
+ return request_with_auth(:post, path, body: params)
71
44
  end
72
45
 
73
46
  # Create Create
@@ -80,16 +53,7 @@ module JPSClient
80
53
 
81
54
  path = config["url"]
82
55
 
83
- response = @http_client.post(path, body: params)
84
- result = JPSClient::Response.new(response)
85
-
86
- if result.need_login?
87
- do_login(force_login: true)
88
- response = @http_client.post(path, body: params)
89
- result = JPSClient::Response.new(response)
90
- end
91
-
92
- return result.to_h
56
+ return request_with_auth(:post, path, body: params)
93
57
  end
94
58
 
95
59
  # Get List
@@ -102,16 +66,7 @@ module JPSClient
102
66
 
103
67
  path = config["url"]
104
68
 
105
- response = @http_client.get(path, params: params)
106
- result = JPSClient::Response.new(response)
107
-
108
- if result.need_login?
109
- do_login(force_login: true)
110
- response = @http_client.get(path, params: params)
111
- result = JPSClient::Response.new(response)
112
- end
113
-
114
- return result.to_h
69
+ return request_with_auth(:get, path, params: params)
115
70
  end
116
71
  end
117
72
  end
@@ -24,16 +24,7 @@ module JPSClient
24
24
  params[:parent_department_id] = parent_department_id if parent_department_id
25
25
  params[:page_token] = page_token if page_token
26
26
 
27
- response = @http_client.get(path, params: params)
28
- result = JPSClient::Response.new(response)
29
-
30
- if result.need_login?
31
- do_login(force_login: true)
32
- response = @http_client.get(path, params: params)
33
- result = JPSClient::Response.new(response)
34
- end
35
-
36
- return result.to_h
27
+ return request_with_auth(:get, path, params: params)
37
28
  end
38
29
 
39
30
  # 获取所有部门(别名方法)
@@ -15,16 +15,7 @@ module JPSClient
15
15
  path = config["url"]
16
16
  params = { image_key: image_key }
17
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
18
+ return request_with_auth(:get, path, params: params)
28
19
  end
29
20
 
30
21
  end
@@ -30,16 +30,7 @@ module JPSClient
30
30
  params[:department_id] = department_id if department_id
31
31
  params[:status] = status if status
32
32
 
33
- response = @http_client.get(path, params: params)
34
- result = JPSClient::Response.new(response)
35
-
36
- if result.need_login?
37
- do_login(force_login: true)
38
- response = @http_client.get(path, params: params)
39
- result = JPSClient::Response.new(response)
40
- end
41
-
42
- return result.to_h
33
+ return request_with_auth(:get, path, params: params)
43
34
  end
44
35
 
45
36
  end
@@ -15,16 +15,7 @@ module JPSClient
15
15
  path = config["url"]
16
16
  params = { message_id: message_id }
17
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
18
+ return request_with_auth(:get, path, params: params)
28
19
  end
29
20
 
30
21
  end
@@ -14,16 +14,7 @@ module JPSClient
14
14
 
15
15
  path = config["url"]
16
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
17
+ return request_with_auth(:post, path, body: params)
27
18
  end
28
19
 
29
20
  # Get List
@@ -36,16 +27,7 @@ module JPSClient
36
27
 
37
28
  path = config["url"]
38
29
 
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
30
+ return request_with_auth(:post, path, body: params)
49
31
  end
50
32
 
51
33
  # Create Delete
@@ -58,16 +40,7 @@ module JPSClient
58
40
 
59
41
  path = config["url"]
60
42
 
61
- response = @http_client.post(path, body: params)
62
- result = JPSClient::Response.new(response)
63
-
64
- if result.need_login?
65
- do_login(force_login: true)
66
- response = @http_client.post(path, body: params)
67
- result = JPSClient::Response.new(response)
68
- end
69
-
70
- return result.to_h
43
+ return request_with_auth(:post, path, body: params)
71
44
  end
72
45
 
73
46
  # Create Create
@@ -80,16 +53,7 @@ module JPSClient
80
53
 
81
54
  path = config["url"]
82
55
 
83
- response = @http_client.post(path, body: params)
84
- result = JPSClient::Response.new(response)
85
-
86
- if result.need_login?
87
- do_login(force_login: true)
88
- response = @http_client.post(path, body: params)
89
- result = JPSClient::Response.new(response)
90
- end
91
-
92
- return result.to_h
56
+ return request_with_auth(:post, path, body: params)
93
57
  end
94
58
 
95
59
  # Get Type Info List
@@ -102,16 +66,7 @@ module JPSClient
102
66
 
103
67
  path = config["url"]
104
68
 
105
- response = @http_client.get(path, params: params)
106
- result = JPSClient::Response.new(response)
107
-
108
- if result.need_login?
109
- do_login(force_login: true)
110
- response = @http_client.get(path, params: params)
111
- result = JPSClient::Response.new(response)
112
- end
113
-
114
- return result.to_h
69
+ return request_with_auth(:get, path, params: params)
115
70
  end
116
71
 
117
72
  # Get Detail
@@ -124,16 +79,7 @@ module JPSClient
124
79
 
125
80
  path = config["url"]
126
81
 
127
- response = @http_client.get(path, params: params)
128
- result = JPSClient::Response.new(response)
129
-
130
- if result.need_login?
131
- do_login(force_login: true)
132
- response = @http_client.get(path, params: params)
133
- result = JPSClient::Response.new(response)
134
- end
135
-
136
- return result.to_h
82
+ return request_with_auth(:get, path, params: params)
137
83
  end
138
84
  end
139
85
  end
@@ -14,16 +14,7 @@ module JPSClient
14
14
 
15
15
  path = config["url"]
16
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
17
+ return request_with_auth(:post, path, body: params)
27
18
  end
28
19
 
29
20
  # Get Create
@@ -36,16 +27,7 @@ module JPSClient
36
27
 
37
28
  path = config["url"]
38
29
 
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
30
+ return request_with_auth(:post, path, body: params)
49
31
  end
50
32
 
51
33
  # Get List
@@ -58,16 +40,7 @@ module JPSClient
58
40
 
59
41
  path = config["url"]
60
42
 
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
43
+ return request_with_auth(:get, path, params: params)
71
44
  end
72
45
 
73
46
  # Get Custom Fields
@@ -80,16 +53,7 @@ module JPSClient
80
53
 
81
54
  path = config["url"]
82
55
 
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
56
+ return request_with_auth(:get, path, params: params)
93
57
  end
94
58
 
95
59
  # Get All
@@ -102,16 +66,7 @@ module JPSClient
102
66
 
103
67
  path = config["url"]
104
68
 
105
- response = @http_client.get(path, params: params)
106
- result = JPSClient::Response.new(response)
107
-
108
- if result.need_login?
109
- do_login(force_login: true)
110
- response = @http_client.get(path, params: params)
111
- result = JPSClient::Response.new(response)
112
- end
113
-
114
- return result.to_h
69
+ return request_with_auth(:get, path, params: params)
115
70
  end
116
71
  end
117
72
  end
@@ -14,16 +14,7 @@ module JPSClient
14
14
 
15
15
  path = config["url"]
16
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
17
+ return request_with_auth(:post, path, body: params)
27
18
  end
28
19
 
29
20
  # Get List
@@ -36,16 +27,7 @@ module JPSClient
36
27
 
37
28
  path = config["url"]
38
29
 
39
- response = @http_client.get(path, params: params)
40
- result = JPSClient::Response.new(response)
41
-
42
- if result.need_login?
43
- do_login(force_login: true)
44
- response = @http_client.get(path, params: params)
45
- result = JPSClient::Response.new(response)
46
- end
47
-
48
- return result.to_h
30
+ return request_with_auth(:get, path, params: params)
49
31
  end
50
32
 
51
33
  # Get Detail
@@ -58,16 +40,7 @@ module JPSClient
58
40
 
59
41
  path = config["url"]
60
42
 
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
43
+ return request_with_auth(:get, path, params: params)
71
44
  end
72
45
  end
73
46
  end
@@ -14,16 +14,7 @@ module JPSClient
14
14
 
15
15
  path = config["url"]
16
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
17
+ return request_with_auth(:get, path, params: params)
27
18
  end
28
19
  end
29
20
  end
@@ -14,16 +14,7 @@ module JPSClient
14
14
 
15
15
  path = config["url"]
16
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
17
+ return request_with_auth(:post, path, body: params)
27
18
  end
28
19
  end
29
20
  end
@@ -14,16 +14,7 @@ module JPSClient
14
14
 
15
15
  path = config["url"]
16
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
17
+ return request_with_auth(:get, path, params: params)
27
18
  end
28
19
  end
29
20
  end
@@ -117,7 +117,7 @@ module JPSClient
117
117
  @token_manager = Token.new(@jps_config)
118
118
 
119
119
  # 尝试加载已保存的 token
120
- if @token_manager.load && @token_manager.valid?
120
+ if @token_manager.load && @token_manager.loaded?
121
121
  @token = @token_manager.to_h
122
122
  end
123
123
 
@@ -148,50 +148,35 @@ module JPSClient
148
148
  end
149
149
 
150
150
  # 核心登录功能
151
+ # token 有效性由服务端 401 响应判断,本地不做过期检查
151
152
  def do_login(force_login: false)
152
- # 使用 token 管理器统一处理
153
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
154
+ @token_manager.clear
171
155
  else
172
- # 尝试加载并验证现有 token
173
- if @token_manager.load && @token_manager.valid?
174
- update_token_everywhere()
156
+ # 本地存在 token,直接使用
157
+ if @token_manager.load && @token_manager.loaded?
158
+ update_token_everywhere
175
159
  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
160
  end
194
161
  end
162
+
163
+ # 需要重新登录
164
+ auth = Auth.new(@jps_config)
165
+ result = auth.login
166
+
167
+ if result == :user_cancelled
168
+ Logger.instance.fancyinfo_error("用户取消了登录操作")
169
+ return false
170
+ elsif result == true
171
+ unless @token_manager.save(auth.get_token_data)
172
+ Logger.instance.fancyinfo_error("Token 保存失败,下次启动需要重新登录")
173
+ end
174
+ update_token_everywhere
175
+ return true
176
+ else
177
+ Logger.instance.fancyinfo_error("登录失败,未能获取有效token")
178
+ return false
179
+ end
195
180
  end
196
181
 
197
182
  # 获取已加载的模块列表
@@ -241,6 +226,21 @@ module JPSClient
241
226
  module_name && API_MODULES.key?(module_name.to_sym) || super
242
227
  end
243
228
 
229
+ # 带 401 重试的统一请求方法
230
+ def request_with_auth(method, path, **opts)
231
+ response = @http_client.send(method, path, **opts)
232
+ result = JPSClient::Response.new(response)
233
+
234
+ if result.need_login?
235
+ if do_login(force_login: true)
236
+ response = @http_client.send(method, path, **opts)
237
+ result = JPSClient::Response.new(response)
238
+ end
239
+ end
240
+
241
+ result.to_h
242
+ end
243
+
244
244
  private
245
245
 
246
246
  # 统一更新token到所有组件