plex_ruby_sdk 0.7.7 → 0.8.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/plex_ruby_sdk/activities.rb +115 -12
- data/lib/plex_ruby_sdk/authentication.rb +233 -29
- data/lib/plex_ruby_sdk/butler.rb +283 -30
- data/lib/plex_ruby_sdk/hubs.rb +174 -21
- data/lib/plex_ruby_sdk/library.rb +913 -110
- data/lib/plex_ruby_sdk/log.rb +179 -24
- data/lib/plex_ruby_sdk/media.rb +288 -35
- data/lib/plex_ruby_sdk/playlists.rb +513 -60
- data/lib/plex_ruby_sdk/plex.rb +388 -38
- data/lib/plex_ruby_sdk/plex_api.rb +29 -10
- data/lib/plex_ruby_sdk/sdk_hooks/hooks.rb +103 -0
- data/lib/plex_ruby_sdk/sdk_hooks/registration.rb +35 -0
- data/lib/plex_ruby_sdk/sdk_hooks/types.rb +152 -0
- data/lib/plex_ruby_sdk/sdkconfiguration.rb +26 -7
- data/lib/plex_ruby_sdk/search.rb +174 -21
- data/lib/plex_ruby_sdk/server.rb +505 -53
- data/lib/plex_ruby_sdk/sessions.rb +228 -25
- data/lib/plex_ruby_sdk/statistics.rb +174 -21
- data/lib/plex_ruby_sdk/updater.rb +173 -20
- data/lib/plex_ruby_sdk/users.rb +56 -4
- data/lib/plex_ruby_sdk/utils/retries.rb +95 -0
- data/lib/plex_ruby_sdk/utils/utils.rb +10 -0
- data/lib/plex_ruby_sdk/video.rb +117 -14
- data/lib/plex_ruby_sdk/watchlist.rb +60 -7
- metadata +36 -4
data/lib/plex_ruby_sdk/log.rb
CHANGED
@@ -5,7 +5,10 @@
|
|
5
5
|
|
6
6
|
require 'faraday'
|
7
7
|
require 'faraday/multipart'
|
8
|
+
require 'faraday/retry'
|
8
9
|
require 'sorbet-runtime'
|
10
|
+
require_relative 'sdk_hooks/hooks'
|
11
|
+
require_relative 'utils/retries'
|
9
12
|
|
10
13
|
module PlexRubySDK
|
11
14
|
extend T::Sig
|
@@ -20,8 +23,8 @@ module PlexRubySDK
|
|
20
23
|
end
|
21
24
|
|
22
25
|
|
23
|
-
sig { params(level: ::PlexRubySDK::Operations::Level, message: ::String, source: ::String).returns(::PlexRubySDK::Operations::LogLineResponse) }
|
24
|
-
def log_line(level, message, source)
|
26
|
+
sig { params(level: ::PlexRubySDK::Operations::Level, message: ::String, source: ::String, timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::LogLineResponse) }
|
27
|
+
def log_line(level, message, source, timeout_ms = nil)
|
25
28
|
# log_line - Logging a single line message.
|
26
29
|
# This endpoint will write a single-line log message, including a level and source to the main Plex Media Server log.
|
27
30
|
#
|
@@ -39,11 +42,61 @@ module PlexRubySDK
|
|
39
42
|
headers['Accept'] = 'application/json'
|
40
43
|
headers['user-agent'] = @sdk_configuration.user_agent
|
41
44
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
45
|
+
security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
|
46
|
+
|
47
|
+
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
|
48
|
+
timeout ||= @sdk_configuration.timeout
|
49
|
+
|
50
|
+
connection = @sdk_configuration.client
|
51
|
+
|
52
|
+
hook_ctx = SDKHooks::HookContext.new(
|
53
|
+
base_url: base_url,
|
54
|
+
oauth2_scopes: nil,
|
55
|
+
operation_id: 'logLine',
|
56
|
+
security_source: @sdk_configuration.security_source
|
57
|
+
)
|
58
|
+
|
59
|
+
error = T.let(nil, T.nilable(StandardError))
|
60
|
+
r = T.let(nil, T.nilable(Faraday::Response))
|
61
|
+
|
62
|
+
begin
|
63
|
+
r = connection.get(url) do |req|
|
64
|
+
req.headers.merge!(headers)
|
65
|
+
req.options.timeout = timeout unless timeout.nil?
|
66
|
+
req.params = query_params
|
67
|
+
Utils.configure_request_security(req, security)
|
68
|
+
|
69
|
+
@sdk_configuration.hooks.before_request(
|
70
|
+
hook_ctx: SDKHooks::BeforeRequestHookContext.new(
|
71
|
+
hook_ctx: hook_ctx
|
72
|
+
),
|
73
|
+
request: req
|
74
|
+
)
|
75
|
+
end
|
76
|
+
rescue StandardError => e
|
77
|
+
error = e
|
78
|
+
ensure
|
79
|
+
if r.nil? || Utils.error_status?(r.status)
|
80
|
+
r = @sdk_configuration.hooks.after_error(
|
81
|
+
error: error,
|
82
|
+
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
83
|
+
hook_ctx: hook_ctx
|
84
|
+
),
|
85
|
+
response: r
|
86
|
+
)
|
87
|
+
else
|
88
|
+
r = @sdk_configuration.hooks.after_success(
|
89
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
90
|
+
hook_ctx: hook_ctx
|
91
|
+
),
|
92
|
+
response: r
|
93
|
+
)
|
94
|
+
end
|
95
|
+
|
96
|
+
if r.nil?
|
97
|
+
raise error if !error.nil?
|
98
|
+
raise 'no response'
|
99
|
+
end
|
47
100
|
end
|
48
101
|
|
49
102
|
content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
|
@@ -68,8 +121,8 @@ module PlexRubySDK
|
|
68
121
|
end
|
69
122
|
|
70
123
|
|
71
|
-
sig { params(request: ::String).returns(::PlexRubySDK::Operations::LogMultiLineResponse) }
|
72
|
-
def log_multi_line(request)
|
124
|
+
sig { params(request: ::String, timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::LogMultiLineResponse) }
|
125
|
+
def log_multi_line(request, timeout_ms = nil)
|
73
126
|
# log_multi_line - Logging a multi-line message
|
74
127
|
# This endpoint allows for the batch addition of log entries to the main Plex Media Server log.
|
75
128
|
# It accepts a text/plain request body, where each line represents a distinct log entry.
|
@@ -100,19 +153,71 @@ module PlexRubySDK
|
|
100
153
|
req_content_type, data, form = Utils.serialize_request_body(request, :request, :string)
|
101
154
|
headers['content-type'] = req_content_type
|
102
155
|
raise StandardError, 'request body is required' if data.nil? && form.nil?
|
156
|
+
|
157
|
+
if form
|
158
|
+
body = Utils.encode_form(form)
|
159
|
+
elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded')
|
160
|
+
body = URI.encode_www_form(data)
|
161
|
+
else
|
162
|
+
body = data
|
163
|
+
end
|
103
164
|
headers['Accept'] = 'application/json'
|
104
165
|
headers['user-agent'] = @sdk_configuration.user_agent
|
105
166
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
167
|
+
security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
|
168
|
+
|
169
|
+
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
|
170
|
+
timeout ||= @sdk_configuration.timeout
|
171
|
+
|
172
|
+
connection = @sdk_configuration.client
|
173
|
+
|
174
|
+
hook_ctx = SDKHooks::HookContext.new(
|
175
|
+
base_url: base_url,
|
176
|
+
oauth2_scopes: nil,
|
177
|
+
operation_id: 'logMultiLine',
|
178
|
+
security_source: @sdk_configuration.security_source
|
179
|
+
)
|
180
|
+
|
181
|
+
error = T.let(nil, T.nilable(StandardError))
|
182
|
+
r = T.let(nil, T.nilable(Faraday::Response))
|
183
|
+
|
184
|
+
begin
|
185
|
+
r = connection.post(url) do |req|
|
186
|
+
req.body = body
|
187
|
+
req.headers.merge!(headers)
|
188
|
+
req.options.timeout = timeout unless timeout.nil?
|
189
|
+
Utils.configure_request_security(req, security)
|
190
|
+
|
191
|
+
@sdk_configuration.hooks.before_request(
|
192
|
+
hook_ctx: SDKHooks::BeforeRequestHookContext.new(
|
193
|
+
hook_ctx: hook_ctx
|
194
|
+
),
|
195
|
+
request: req
|
196
|
+
)
|
197
|
+
end
|
198
|
+
rescue StandardError => e
|
199
|
+
error = e
|
200
|
+
ensure
|
201
|
+
if r.nil? || Utils.error_status?(r.status)
|
202
|
+
r = @sdk_configuration.hooks.after_error(
|
203
|
+
error: error,
|
204
|
+
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
205
|
+
hook_ctx: hook_ctx
|
206
|
+
),
|
207
|
+
response: r
|
208
|
+
)
|
114
209
|
else
|
115
|
-
|
210
|
+
r = @sdk_configuration.hooks.after_success(
|
211
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
212
|
+
hook_ctx: hook_ctx
|
213
|
+
),
|
214
|
+
response: r
|
215
|
+
)
|
216
|
+
end
|
217
|
+
|
218
|
+
if r.nil?
|
219
|
+
raise error if !error.nil?
|
220
|
+
raise 'no response'
|
116
221
|
end
|
117
222
|
end
|
118
223
|
|
@@ -138,8 +243,8 @@ module PlexRubySDK
|
|
138
243
|
end
|
139
244
|
|
140
245
|
|
141
|
-
sig { returns(::PlexRubySDK::Operations::EnablePaperTrailResponse) }
|
142
|
-
def enable_paper_trail
|
246
|
+
sig { params(timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::EnablePaperTrailResponse) }
|
247
|
+
def enable_paper_trail(timeout_ms = nil)
|
143
248
|
# enable_paper_trail - Enabling Papertrail
|
144
249
|
# This endpoint will enable all Plex Media Serverlogs to be sent to the Papertrail networked logging site for a period of time.
|
145
250
|
#
|
@@ -150,10 +255,60 @@ module PlexRubySDK
|
|
150
255
|
headers['Accept'] = 'application/json'
|
151
256
|
headers['user-agent'] = @sdk_configuration.user_agent
|
152
257
|
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
258
|
+
security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
|
259
|
+
|
260
|
+
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
|
261
|
+
timeout ||= @sdk_configuration.timeout
|
262
|
+
|
263
|
+
connection = @sdk_configuration.client
|
264
|
+
|
265
|
+
hook_ctx = SDKHooks::HookContext.new(
|
266
|
+
base_url: base_url,
|
267
|
+
oauth2_scopes: nil,
|
268
|
+
operation_id: 'enablePaperTrail',
|
269
|
+
security_source: @sdk_configuration.security_source
|
270
|
+
)
|
271
|
+
|
272
|
+
error = T.let(nil, T.nilable(StandardError))
|
273
|
+
r = T.let(nil, T.nilable(Faraday::Response))
|
274
|
+
|
275
|
+
begin
|
276
|
+
r = connection.get(url) do |req|
|
277
|
+
req.headers.merge!(headers)
|
278
|
+
req.options.timeout = timeout unless timeout.nil?
|
279
|
+
Utils.configure_request_security(req, security)
|
280
|
+
|
281
|
+
@sdk_configuration.hooks.before_request(
|
282
|
+
hook_ctx: SDKHooks::BeforeRequestHookContext.new(
|
283
|
+
hook_ctx: hook_ctx
|
284
|
+
),
|
285
|
+
request: req
|
286
|
+
)
|
287
|
+
end
|
288
|
+
rescue StandardError => e
|
289
|
+
error = e
|
290
|
+
ensure
|
291
|
+
if r.nil? || Utils.error_status?(r.status)
|
292
|
+
r = @sdk_configuration.hooks.after_error(
|
293
|
+
error: error,
|
294
|
+
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
295
|
+
hook_ctx: hook_ctx
|
296
|
+
),
|
297
|
+
response: r
|
298
|
+
)
|
299
|
+
else
|
300
|
+
r = @sdk_configuration.hooks.after_success(
|
301
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
302
|
+
hook_ctx: hook_ctx
|
303
|
+
),
|
304
|
+
response: r
|
305
|
+
)
|
306
|
+
end
|
307
|
+
|
308
|
+
if r.nil?
|
309
|
+
raise error if !error.nil?
|
310
|
+
raise 'no response'
|
311
|
+
end
|
157
312
|
end
|
158
313
|
|
159
314
|
content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
|
data/lib/plex_ruby_sdk/media.rb
CHANGED
@@ -5,7 +5,10 @@
|
|
5
5
|
|
6
6
|
require 'faraday'
|
7
7
|
require 'faraday/multipart'
|
8
|
+
require 'faraday/retry'
|
8
9
|
require 'sorbet-runtime'
|
10
|
+
require_relative 'sdk_hooks/hooks'
|
11
|
+
require_relative 'utils/retries'
|
9
12
|
|
10
13
|
module PlexRubySDK
|
11
14
|
extend T::Sig
|
@@ -20,8 +23,8 @@ module PlexRubySDK
|
|
20
23
|
end
|
21
24
|
|
22
25
|
|
23
|
-
sig { params(key: ::Float).returns(::PlexRubySDK::Operations::MarkPlayedResponse) }
|
24
|
-
def mark_played(key)
|
26
|
+
sig { params(key: ::Float, timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::MarkPlayedResponse) }
|
27
|
+
def mark_played(key, timeout_ms = nil)
|
25
28
|
# mark_played - Mark Media Played
|
26
29
|
# This will mark the provided media key as Played.
|
27
30
|
request = ::PlexRubySDK::Operations::MarkPlayedRequest.new(
|
@@ -36,11 +39,61 @@ module PlexRubySDK
|
|
36
39
|
headers['Accept'] = 'application/json'
|
37
40
|
headers['user-agent'] = @sdk_configuration.user_agent
|
38
41
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
42
|
+
security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
|
43
|
+
|
44
|
+
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
|
45
|
+
timeout ||= @sdk_configuration.timeout
|
46
|
+
|
47
|
+
connection = @sdk_configuration.client
|
48
|
+
|
49
|
+
hook_ctx = SDKHooks::HookContext.new(
|
50
|
+
base_url: base_url,
|
51
|
+
oauth2_scopes: nil,
|
52
|
+
operation_id: 'markPlayed',
|
53
|
+
security_source: @sdk_configuration.security_source
|
54
|
+
)
|
55
|
+
|
56
|
+
error = T.let(nil, T.nilable(StandardError))
|
57
|
+
r = T.let(nil, T.nilable(Faraday::Response))
|
58
|
+
|
59
|
+
begin
|
60
|
+
r = connection.get(url) do |req|
|
61
|
+
req.headers.merge!(headers)
|
62
|
+
req.options.timeout = timeout unless timeout.nil?
|
63
|
+
req.params = query_params
|
64
|
+
Utils.configure_request_security(req, security)
|
65
|
+
|
66
|
+
@sdk_configuration.hooks.before_request(
|
67
|
+
hook_ctx: SDKHooks::BeforeRequestHookContext.new(
|
68
|
+
hook_ctx: hook_ctx
|
69
|
+
),
|
70
|
+
request: req
|
71
|
+
)
|
72
|
+
end
|
73
|
+
rescue StandardError => e
|
74
|
+
error = e
|
75
|
+
ensure
|
76
|
+
if r.nil? || Utils.error_status?(r.status)
|
77
|
+
r = @sdk_configuration.hooks.after_error(
|
78
|
+
error: error,
|
79
|
+
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
80
|
+
hook_ctx: hook_ctx
|
81
|
+
),
|
82
|
+
response: r
|
83
|
+
)
|
84
|
+
else
|
85
|
+
r = @sdk_configuration.hooks.after_success(
|
86
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
87
|
+
hook_ctx: hook_ctx
|
88
|
+
),
|
89
|
+
response: r
|
90
|
+
)
|
91
|
+
end
|
92
|
+
|
93
|
+
if r.nil?
|
94
|
+
raise error if !error.nil?
|
95
|
+
raise 'no response'
|
96
|
+
end
|
44
97
|
end
|
45
98
|
|
46
99
|
content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
|
@@ -65,8 +118,8 @@ module PlexRubySDK
|
|
65
118
|
end
|
66
119
|
|
67
120
|
|
68
|
-
sig { params(key: ::Float).returns(::PlexRubySDK::Operations::MarkUnplayedResponse) }
|
69
|
-
def mark_unplayed(key)
|
121
|
+
sig { params(key: ::Float, timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::MarkUnplayedResponse) }
|
122
|
+
def mark_unplayed(key, timeout_ms = nil)
|
70
123
|
# mark_unplayed - Mark Media Unplayed
|
71
124
|
# This will mark the provided media key as Unplayed.
|
72
125
|
request = ::PlexRubySDK::Operations::MarkUnplayedRequest.new(
|
@@ -81,11 +134,61 @@ module PlexRubySDK
|
|
81
134
|
headers['Accept'] = 'application/json'
|
82
135
|
headers['user-agent'] = @sdk_configuration.user_agent
|
83
136
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
137
|
+
security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
|
138
|
+
|
139
|
+
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
|
140
|
+
timeout ||= @sdk_configuration.timeout
|
141
|
+
|
142
|
+
connection = @sdk_configuration.client
|
143
|
+
|
144
|
+
hook_ctx = SDKHooks::HookContext.new(
|
145
|
+
base_url: base_url,
|
146
|
+
oauth2_scopes: nil,
|
147
|
+
operation_id: 'markUnplayed',
|
148
|
+
security_source: @sdk_configuration.security_source
|
149
|
+
)
|
150
|
+
|
151
|
+
error = T.let(nil, T.nilable(StandardError))
|
152
|
+
r = T.let(nil, T.nilable(Faraday::Response))
|
153
|
+
|
154
|
+
begin
|
155
|
+
r = connection.get(url) do |req|
|
156
|
+
req.headers.merge!(headers)
|
157
|
+
req.options.timeout = timeout unless timeout.nil?
|
158
|
+
req.params = query_params
|
159
|
+
Utils.configure_request_security(req, security)
|
160
|
+
|
161
|
+
@sdk_configuration.hooks.before_request(
|
162
|
+
hook_ctx: SDKHooks::BeforeRequestHookContext.new(
|
163
|
+
hook_ctx: hook_ctx
|
164
|
+
),
|
165
|
+
request: req
|
166
|
+
)
|
167
|
+
end
|
168
|
+
rescue StandardError => e
|
169
|
+
error = e
|
170
|
+
ensure
|
171
|
+
if r.nil? || Utils.error_status?(r.status)
|
172
|
+
r = @sdk_configuration.hooks.after_error(
|
173
|
+
error: error,
|
174
|
+
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
175
|
+
hook_ctx: hook_ctx
|
176
|
+
),
|
177
|
+
response: r
|
178
|
+
)
|
179
|
+
else
|
180
|
+
r = @sdk_configuration.hooks.after_success(
|
181
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
182
|
+
hook_ctx: hook_ctx
|
183
|
+
),
|
184
|
+
response: r
|
185
|
+
)
|
186
|
+
end
|
187
|
+
|
188
|
+
if r.nil?
|
189
|
+
raise error if !error.nil?
|
190
|
+
raise 'no response'
|
191
|
+
end
|
89
192
|
end
|
90
193
|
|
91
194
|
content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
|
@@ -110,8 +213,8 @@ module PlexRubySDK
|
|
110
213
|
end
|
111
214
|
|
112
215
|
|
113
|
-
sig { params(key: ::String, time: ::Float, state: ::String).returns(::PlexRubySDK::Operations::UpdatePlayProgressResponse) }
|
114
|
-
def update_play_progress(key, time, state)
|
216
|
+
sig { params(key: ::String, time: ::Float, state: ::String, timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::UpdatePlayProgressResponse) }
|
217
|
+
def update_play_progress(key, time, state, timeout_ms = nil)
|
115
218
|
# update_play_progress - Update Media Play Progress
|
116
219
|
# This API command can be used to update the play progress of a media item.
|
117
220
|
#
|
@@ -129,11 +232,61 @@ module PlexRubySDK
|
|
129
232
|
headers['Accept'] = 'application/json'
|
130
233
|
headers['user-agent'] = @sdk_configuration.user_agent
|
131
234
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
235
|
+
security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
|
236
|
+
|
237
|
+
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
|
238
|
+
timeout ||= @sdk_configuration.timeout
|
239
|
+
|
240
|
+
connection = @sdk_configuration.client
|
241
|
+
|
242
|
+
hook_ctx = SDKHooks::HookContext.new(
|
243
|
+
base_url: base_url,
|
244
|
+
oauth2_scopes: nil,
|
245
|
+
operation_id: 'updatePlayProgress',
|
246
|
+
security_source: @sdk_configuration.security_source
|
247
|
+
)
|
248
|
+
|
249
|
+
error = T.let(nil, T.nilable(StandardError))
|
250
|
+
r = T.let(nil, T.nilable(Faraday::Response))
|
251
|
+
|
252
|
+
begin
|
253
|
+
r = connection.post(url) do |req|
|
254
|
+
req.headers.merge!(headers)
|
255
|
+
req.options.timeout = timeout unless timeout.nil?
|
256
|
+
req.params = query_params
|
257
|
+
Utils.configure_request_security(req, security)
|
258
|
+
|
259
|
+
@sdk_configuration.hooks.before_request(
|
260
|
+
hook_ctx: SDKHooks::BeforeRequestHookContext.new(
|
261
|
+
hook_ctx: hook_ctx
|
262
|
+
),
|
263
|
+
request: req
|
264
|
+
)
|
265
|
+
end
|
266
|
+
rescue StandardError => e
|
267
|
+
error = e
|
268
|
+
ensure
|
269
|
+
if r.nil? || Utils.error_status?(r.status)
|
270
|
+
r = @sdk_configuration.hooks.after_error(
|
271
|
+
error: error,
|
272
|
+
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
273
|
+
hook_ctx: hook_ctx
|
274
|
+
),
|
275
|
+
response: r
|
276
|
+
)
|
277
|
+
else
|
278
|
+
r = @sdk_configuration.hooks.after_success(
|
279
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
280
|
+
hook_ctx: hook_ctx
|
281
|
+
),
|
282
|
+
response: r
|
283
|
+
)
|
284
|
+
end
|
285
|
+
|
286
|
+
if r.nil?
|
287
|
+
raise error if !error.nil?
|
288
|
+
raise 'no response'
|
289
|
+
end
|
137
290
|
end
|
138
291
|
|
139
292
|
content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
|
@@ -158,8 +311,8 @@ module PlexRubySDK
|
|
158
311
|
end
|
159
312
|
|
160
313
|
|
161
|
-
sig { params(request: T.nilable(::PlexRubySDK::Operations::GetBannerImageRequest)).returns(::PlexRubySDK::Operations::GetBannerImageResponse) }
|
162
|
-
def get_banner_image(request)
|
314
|
+
sig { params(request: T.nilable(::PlexRubySDK::Operations::GetBannerImageRequest), timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::GetBannerImageResponse) }
|
315
|
+
def get_banner_image(request, timeout_ms = nil)
|
163
316
|
# get_banner_image - Get Banner Image
|
164
317
|
# Gets the banner image of the media item
|
165
318
|
url, params = @sdk_configuration.get_server_details
|
@@ -175,11 +328,61 @@ module PlexRubySDK
|
|
175
328
|
headers['Accept'] = 'application/json;q=1, image/jpeg;q=0'
|
176
329
|
headers['user-agent'] = @sdk_configuration.user_agent
|
177
330
|
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
331
|
+
security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
|
332
|
+
|
333
|
+
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
|
334
|
+
timeout ||= @sdk_configuration.timeout
|
335
|
+
|
336
|
+
connection = @sdk_configuration.client
|
337
|
+
|
338
|
+
hook_ctx = SDKHooks::HookContext.new(
|
339
|
+
base_url: base_url,
|
340
|
+
oauth2_scopes: nil,
|
341
|
+
operation_id: 'get-banner-image',
|
342
|
+
security_source: @sdk_configuration.security_source
|
343
|
+
)
|
344
|
+
|
345
|
+
error = T.let(nil, T.nilable(StandardError))
|
346
|
+
r = T.let(nil, T.nilable(Faraday::Response))
|
347
|
+
|
348
|
+
begin
|
349
|
+
r = connection.get(url) do |req|
|
350
|
+
req.headers.merge!(headers)
|
351
|
+
req.options.timeout = timeout unless timeout.nil?
|
352
|
+
req.params = query_params
|
353
|
+
Utils.configure_request_security(req, security)
|
354
|
+
|
355
|
+
@sdk_configuration.hooks.before_request(
|
356
|
+
hook_ctx: SDKHooks::BeforeRequestHookContext.new(
|
357
|
+
hook_ctx: hook_ctx
|
358
|
+
),
|
359
|
+
request: req
|
360
|
+
)
|
361
|
+
end
|
362
|
+
rescue StandardError => e
|
363
|
+
error = e
|
364
|
+
ensure
|
365
|
+
if r.nil? || Utils.error_status?(r.status)
|
366
|
+
r = @sdk_configuration.hooks.after_error(
|
367
|
+
error: error,
|
368
|
+
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
369
|
+
hook_ctx: hook_ctx
|
370
|
+
),
|
371
|
+
response: r
|
372
|
+
)
|
373
|
+
else
|
374
|
+
r = @sdk_configuration.hooks.after_success(
|
375
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
376
|
+
hook_ctx: hook_ctx
|
377
|
+
),
|
378
|
+
response: r
|
379
|
+
)
|
380
|
+
end
|
381
|
+
|
382
|
+
if r.nil?
|
383
|
+
raise error if !error.nil?
|
384
|
+
raise 'no response'
|
385
|
+
end
|
183
386
|
end
|
184
387
|
|
185
388
|
content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
|
@@ -206,8 +409,8 @@ module PlexRubySDK
|
|
206
409
|
end
|
207
410
|
|
208
411
|
|
209
|
-
sig { params(request: T.nilable(::PlexRubySDK::Operations::GetThumbImageRequest)).returns(::PlexRubySDK::Operations::GetThumbImageResponse) }
|
210
|
-
def get_thumb_image(request)
|
412
|
+
sig { params(request: T.nilable(::PlexRubySDK::Operations::GetThumbImageRequest), timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::GetThumbImageResponse) }
|
413
|
+
def get_thumb_image(request, timeout_ms = nil)
|
211
414
|
# get_thumb_image - Get Thumb Image
|
212
415
|
# Gets the thumbnail image of the media item
|
213
416
|
url, params = @sdk_configuration.get_server_details
|
@@ -223,11 +426,61 @@ module PlexRubySDK
|
|
223
426
|
headers['Accept'] = 'application/json;q=1, image/jpeg;q=0'
|
224
427
|
headers['user-agent'] = @sdk_configuration.user_agent
|
225
428
|
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
429
|
+
security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
|
430
|
+
|
431
|
+
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
|
432
|
+
timeout ||= @sdk_configuration.timeout
|
433
|
+
|
434
|
+
connection = @sdk_configuration.client
|
435
|
+
|
436
|
+
hook_ctx = SDKHooks::HookContext.new(
|
437
|
+
base_url: base_url,
|
438
|
+
oauth2_scopes: nil,
|
439
|
+
operation_id: 'get-thumb-image',
|
440
|
+
security_source: @sdk_configuration.security_source
|
441
|
+
)
|
442
|
+
|
443
|
+
error = T.let(nil, T.nilable(StandardError))
|
444
|
+
r = T.let(nil, T.nilable(Faraday::Response))
|
445
|
+
|
446
|
+
begin
|
447
|
+
r = connection.get(url) do |req|
|
448
|
+
req.headers.merge!(headers)
|
449
|
+
req.options.timeout = timeout unless timeout.nil?
|
450
|
+
req.params = query_params
|
451
|
+
Utils.configure_request_security(req, security)
|
452
|
+
|
453
|
+
@sdk_configuration.hooks.before_request(
|
454
|
+
hook_ctx: SDKHooks::BeforeRequestHookContext.new(
|
455
|
+
hook_ctx: hook_ctx
|
456
|
+
),
|
457
|
+
request: req
|
458
|
+
)
|
459
|
+
end
|
460
|
+
rescue StandardError => e
|
461
|
+
error = e
|
462
|
+
ensure
|
463
|
+
if r.nil? || Utils.error_status?(r.status)
|
464
|
+
r = @sdk_configuration.hooks.after_error(
|
465
|
+
error: error,
|
466
|
+
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
467
|
+
hook_ctx: hook_ctx
|
468
|
+
),
|
469
|
+
response: r
|
470
|
+
)
|
471
|
+
else
|
472
|
+
r = @sdk_configuration.hooks.after_success(
|
473
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
474
|
+
hook_ctx: hook_ctx
|
475
|
+
),
|
476
|
+
response: r
|
477
|
+
)
|
478
|
+
end
|
479
|
+
|
480
|
+
if r.nil?
|
481
|
+
raise error if !error.nil?
|
482
|
+
raise 'no response'
|
483
|
+
end
|
231
484
|
end
|
232
485
|
|
233
486
|
content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
|