plex_ruby_sdk 0.7.7 → 0.8.1
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 +1307 -110
- data/lib/plex_ruby_sdk/log.rb +179 -24
- data/lib/plex_ruby_sdk/media.rb +288 -35
- data/lib/plex_ruby_sdk/models/operations/get_media_arts_mediacontainer.rb +36 -0
- data/lib/plex_ruby_sdk/models/operations/get_media_arts_metadata.rb +36 -0
- data/lib/plex_ruby_sdk/models/operations/get_media_arts_request.rb +24 -0
- data/lib/plex_ruby_sdk/models/operations/get_media_arts_response.rb +33 -0
- data/lib/plex_ruby_sdk/models/operations/get_media_arts_responsebody.rb +24 -0
- data/lib/plex_ruby_sdk/models/operations/get_media_posters_mediacontainer.rb +36 -0
- data/lib/plex_ruby_sdk/models/operations/get_media_posters_metadata.rb +36 -0
- data/lib/plex_ruby_sdk/models/operations/get_media_posters_request.rb +24 -0
- data/lib/plex_ruby_sdk/models/operations/get_media_posters_response.rb +33 -0
- data/lib/plex_ruby_sdk/models/operations/get_media_posters_responsebody.rb +24 -0
- data/lib/plex_ruby_sdk/models/operations/post_media_arts_request.rb +30 -0
- data/lib/plex_ruby_sdk/models/operations/post_media_arts_response.rb +30 -0
- data/lib/plex_ruby_sdk/models/operations/post_media_poster_request.rb +30 -0
- data/lib/plex_ruby_sdk/models/operations/post_media_poster_response.rb +30 -0
- data/lib/plex_ruby_sdk/models/operations.rb +14 -0
- 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 +50 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf3067a10347445724f3a5df1fc48c14e5ca0816e712b9f368e6bccac6cfc9e2
|
4
|
+
data.tar.gz: 878ce677d32082acefa11d54b24c0dcf6f93f8550bbaa87f6ca4e4aa6237a08f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0e4e861fe59f6432aa7c6fdd5270ee7f9c2e00258af2f1d8db023c7f05c0ead2f060a1ec926828263dae2711be25e0b6717109f096afe93e968441462939ce8
|
7
|
+
data.tar.gz: 579c5b9be0c52f9a981d0e875ac673e1e6e70b6f2b3cac47aa6e6998f3b5e07d5bb8424cac60f81a6045ca5411e6b17cc7f5b605b96162812bf698c1758faba6
|
@@ -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
|
@@ -26,8 +29,8 @@ module PlexRubySDK
|
|
26
29
|
end
|
27
30
|
|
28
31
|
|
29
|
-
sig { returns(::PlexRubySDK::Operations::GetServerActivitiesResponse) }
|
30
|
-
def get_server_activities
|
32
|
+
sig { params(timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::GetServerActivitiesResponse) }
|
33
|
+
def get_server_activities(timeout_ms = nil)
|
31
34
|
# get_server_activities - Get Server Activities
|
32
35
|
# Get Server Activities
|
33
36
|
url, params = @sdk_configuration.get_server_details
|
@@ -37,10 +40,60 @@ module PlexRubySDK
|
|
37
40
|
headers['Accept'] = 'application/json'
|
38
41
|
headers['user-agent'] = @sdk_configuration.user_agent
|
39
42
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
43
|
+
security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
|
44
|
+
|
45
|
+
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
|
46
|
+
timeout ||= @sdk_configuration.timeout
|
47
|
+
|
48
|
+
connection = @sdk_configuration.client
|
49
|
+
|
50
|
+
hook_ctx = SDKHooks::HookContext.new(
|
51
|
+
base_url: base_url,
|
52
|
+
oauth2_scopes: nil,
|
53
|
+
operation_id: 'getServerActivities',
|
54
|
+
security_source: @sdk_configuration.security_source
|
55
|
+
)
|
56
|
+
|
57
|
+
error = T.let(nil, T.nilable(StandardError))
|
58
|
+
r = T.let(nil, T.nilable(Faraday::Response))
|
59
|
+
|
60
|
+
begin
|
61
|
+
r = connection.get(url) do |req|
|
62
|
+
req.headers.merge!(headers)
|
63
|
+
req.options.timeout = timeout unless timeout.nil?
|
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')
|
@@ -69,8 +122,8 @@ module PlexRubySDK
|
|
69
122
|
end
|
70
123
|
|
71
124
|
|
72
|
-
sig { params(activity_uuid: ::String).returns(::PlexRubySDK::Operations::CancelServerActivitiesResponse) }
|
73
|
-
def cancel_server_activities(activity_uuid)
|
125
|
+
sig { params(activity_uuid: ::String, timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::CancelServerActivitiesResponse) }
|
126
|
+
def cancel_server_activities(activity_uuid, timeout_ms = nil)
|
74
127
|
# cancel_server_activities - Cancel Server Activities
|
75
128
|
# Cancel Server Activities
|
76
129
|
request = ::PlexRubySDK::Operations::CancelServerActivitiesRequest.new(
|
@@ -89,10 +142,60 @@ module PlexRubySDK
|
|
89
142
|
headers['Accept'] = 'application/json'
|
90
143
|
headers['user-agent'] = @sdk_configuration.user_agent
|
91
144
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
145
|
+
security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
|
146
|
+
|
147
|
+
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
|
148
|
+
timeout ||= @sdk_configuration.timeout
|
149
|
+
|
150
|
+
connection = @sdk_configuration.client
|
151
|
+
|
152
|
+
hook_ctx = SDKHooks::HookContext.new(
|
153
|
+
base_url: base_url,
|
154
|
+
oauth2_scopes: nil,
|
155
|
+
operation_id: 'cancelServerActivities',
|
156
|
+
security_source: @sdk_configuration.security_source
|
157
|
+
)
|
158
|
+
|
159
|
+
error = T.let(nil, T.nilable(StandardError))
|
160
|
+
r = T.let(nil, T.nilable(Faraday::Response))
|
161
|
+
|
162
|
+
begin
|
163
|
+
r = connection.delete(url) do |req|
|
164
|
+
req.headers.merge!(headers)
|
165
|
+
req.options.timeout = timeout unless timeout.nil?
|
166
|
+
Utils.configure_request_security(req, security)
|
167
|
+
|
168
|
+
@sdk_configuration.hooks.before_request(
|
169
|
+
hook_ctx: SDKHooks::BeforeRequestHookContext.new(
|
170
|
+
hook_ctx: hook_ctx
|
171
|
+
),
|
172
|
+
request: req
|
173
|
+
)
|
174
|
+
end
|
175
|
+
rescue StandardError => e
|
176
|
+
error = e
|
177
|
+
ensure
|
178
|
+
if r.nil? || Utils.error_status?(r.status)
|
179
|
+
r = @sdk_configuration.hooks.after_error(
|
180
|
+
error: error,
|
181
|
+
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
182
|
+
hook_ctx: hook_ctx
|
183
|
+
),
|
184
|
+
response: r
|
185
|
+
)
|
186
|
+
else
|
187
|
+
r = @sdk_configuration.hooks.after_success(
|
188
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
189
|
+
hook_ctx: hook_ctx
|
190
|
+
),
|
191
|
+
response: r
|
192
|
+
)
|
193
|
+
end
|
194
|
+
|
195
|
+
if r.nil?
|
196
|
+
raise error if !error.nil?
|
197
|
+
raise 'no response'
|
198
|
+
end
|
96
199
|
end
|
97
200
|
|
98
201
|
content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
|
@@ -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
|
@@ -30,8 +33,8 @@ module PlexRubySDK
|
|
30
33
|
end
|
31
34
|
|
32
35
|
|
33
|
-
sig { params(type: ::PlexRubySDK::Operations::GetTransientTokenQueryParamType, scope: ::PlexRubySDK::Operations::Scope).returns(::PlexRubySDK::Operations::GetTransientTokenResponse) }
|
34
|
-
def get_transient_token(type, scope)
|
36
|
+
sig { params(type: ::PlexRubySDK::Operations::GetTransientTokenQueryParamType, scope: ::PlexRubySDK::Operations::Scope, timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::GetTransientTokenResponse) }
|
37
|
+
def get_transient_token(type, scope, timeout_ms = nil)
|
35
38
|
# get_transient_token - Get a Transient Token
|
36
39
|
# This endpoint provides the caller with a temporary token with the same access level as the caller's token. These tokens are valid for up to 48 hours and are destroyed if the server instance is restarted.
|
37
40
|
#
|
@@ -48,11 +51,61 @@ module PlexRubySDK
|
|
48
51
|
headers['Accept'] = 'application/json'
|
49
52
|
headers['user-agent'] = @sdk_configuration.user_agent
|
50
53
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
54
|
+
security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
|
55
|
+
|
56
|
+
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
|
57
|
+
timeout ||= @sdk_configuration.timeout
|
58
|
+
|
59
|
+
connection = @sdk_configuration.client
|
60
|
+
|
61
|
+
hook_ctx = SDKHooks::HookContext.new(
|
62
|
+
base_url: base_url,
|
63
|
+
oauth2_scopes: nil,
|
64
|
+
operation_id: 'getTransientToken',
|
65
|
+
security_source: @sdk_configuration.security_source
|
66
|
+
)
|
67
|
+
|
68
|
+
error = T.let(nil, T.nilable(StandardError))
|
69
|
+
r = T.let(nil, T.nilable(Faraday::Response))
|
70
|
+
|
71
|
+
begin
|
72
|
+
r = connection.get(url) do |req|
|
73
|
+
req.headers.merge!(headers)
|
74
|
+
req.options.timeout = timeout unless timeout.nil?
|
75
|
+
req.params = query_params
|
76
|
+
Utils.configure_request_security(req, security)
|
77
|
+
|
78
|
+
@sdk_configuration.hooks.before_request(
|
79
|
+
hook_ctx: SDKHooks::BeforeRequestHookContext.new(
|
80
|
+
hook_ctx: hook_ctx
|
81
|
+
),
|
82
|
+
request: req
|
83
|
+
)
|
84
|
+
end
|
85
|
+
rescue StandardError => e
|
86
|
+
error = e
|
87
|
+
ensure
|
88
|
+
if r.nil? || Utils.error_status?(r.status)
|
89
|
+
r = @sdk_configuration.hooks.after_error(
|
90
|
+
error: error,
|
91
|
+
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
92
|
+
hook_ctx: hook_ctx
|
93
|
+
),
|
94
|
+
response: r
|
95
|
+
)
|
96
|
+
else
|
97
|
+
r = @sdk_configuration.hooks.after_success(
|
98
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
99
|
+
hook_ctx: hook_ctx
|
100
|
+
),
|
101
|
+
response: r
|
102
|
+
)
|
103
|
+
end
|
104
|
+
|
105
|
+
if r.nil?
|
106
|
+
raise error if !error.nil?
|
107
|
+
raise 'no response'
|
108
|
+
end
|
56
109
|
end
|
57
110
|
|
58
111
|
content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
|
@@ -77,8 +130,8 @@ module PlexRubySDK
|
|
77
130
|
end
|
78
131
|
|
79
132
|
|
80
|
-
sig { params(source: ::String).returns(::PlexRubySDK::Operations::GetSourceConnectionInformationResponse) }
|
81
|
-
def get_source_connection_information(source)
|
133
|
+
sig { params(source: ::String, timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::GetSourceConnectionInformationResponse) }
|
134
|
+
def get_source_connection_information(source, timeout_ms = nil)
|
82
135
|
# get_source_connection_information - Get Source Connection Information
|
83
136
|
# If a caller requires connection details and a transient token for a source that is known to the server, for example a cloud media provider or shared PMS, then this endpoint can be called. This endpoint is only accessible with either an admin token or a valid transient token generated from an admin token.
|
84
137
|
# Note: requires Plex Media Server >= 1.15.4.
|
@@ -95,11 +148,61 @@ module PlexRubySDK
|
|
95
148
|
headers['Accept'] = 'application/json'
|
96
149
|
headers['user-agent'] = @sdk_configuration.user_agent
|
97
150
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
151
|
+
security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
|
152
|
+
|
153
|
+
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
|
154
|
+
timeout ||= @sdk_configuration.timeout
|
155
|
+
|
156
|
+
connection = @sdk_configuration.client
|
157
|
+
|
158
|
+
hook_ctx = SDKHooks::HookContext.new(
|
159
|
+
base_url: base_url,
|
160
|
+
oauth2_scopes: nil,
|
161
|
+
operation_id: 'getSourceConnectionInformation',
|
162
|
+
security_source: @sdk_configuration.security_source
|
163
|
+
)
|
164
|
+
|
165
|
+
error = T.let(nil, T.nilable(StandardError))
|
166
|
+
r = T.let(nil, T.nilable(Faraday::Response))
|
167
|
+
|
168
|
+
begin
|
169
|
+
r = connection.get(url) do |req|
|
170
|
+
req.headers.merge!(headers)
|
171
|
+
req.options.timeout = timeout unless timeout.nil?
|
172
|
+
req.params = query_params
|
173
|
+
Utils.configure_request_security(req, security)
|
174
|
+
|
175
|
+
@sdk_configuration.hooks.before_request(
|
176
|
+
hook_ctx: SDKHooks::BeforeRequestHookContext.new(
|
177
|
+
hook_ctx: hook_ctx
|
178
|
+
),
|
179
|
+
request: req
|
180
|
+
)
|
181
|
+
end
|
182
|
+
rescue StandardError => e
|
183
|
+
error = e
|
184
|
+
ensure
|
185
|
+
if r.nil? || Utils.error_status?(r.status)
|
186
|
+
r = @sdk_configuration.hooks.after_error(
|
187
|
+
error: error,
|
188
|
+
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
189
|
+
hook_ctx: hook_ctx
|
190
|
+
),
|
191
|
+
response: r
|
192
|
+
)
|
193
|
+
else
|
194
|
+
r = @sdk_configuration.hooks.after_success(
|
195
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
196
|
+
hook_ctx: hook_ctx
|
197
|
+
),
|
198
|
+
response: r
|
199
|
+
)
|
200
|
+
end
|
201
|
+
|
202
|
+
if r.nil?
|
203
|
+
raise error if !error.nil?
|
204
|
+
raise 'no response'
|
205
|
+
end
|
103
206
|
end
|
104
207
|
|
105
208
|
content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
|
@@ -124,8 +227,8 @@ module PlexRubySDK
|
|
124
227
|
end
|
125
228
|
|
126
229
|
|
127
|
-
sig { params(server_url: T.nilable(String)).returns(::PlexRubySDK::Operations::GetTokenDetailsResponse) }
|
128
|
-
def get_token_details(server_url = nil)
|
230
|
+
sig { params(server_url: T.nilable(String), timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::GetTokenDetailsResponse) }
|
231
|
+
def get_token_details(server_url = nil, timeout_ms = nil)
|
129
232
|
# get_token_details - Get Token Details
|
130
233
|
# Get the User data from the provided X-Plex-Token
|
131
234
|
base_url = Utils.template_url(GET_TOKEN_DETAILS_SERVERS[0], {
|
@@ -136,10 +239,60 @@ module PlexRubySDK
|
|
136
239
|
headers['Accept'] = 'application/json'
|
137
240
|
headers['user-agent'] = @sdk_configuration.user_agent
|
138
241
|
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
242
|
+
security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
|
243
|
+
|
244
|
+
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
|
245
|
+
timeout ||= @sdk_configuration.timeout
|
246
|
+
|
247
|
+
connection = @sdk_configuration.client
|
248
|
+
|
249
|
+
hook_ctx = SDKHooks::HookContext.new(
|
250
|
+
base_url: base_url,
|
251
|
+
oauth2_scopes: nil,
|
252
|
+
operation_id: 'getTokenDetails',
|
253
|
+
security_source: @sdk_configuration.security_source
|
254
|
+
)
|
255
|
+
|
256
|
+
error = T.let(nil, T.nilable(StandardError))
|
257
|
+
r = T.let(nil, T.nilable(Faraday::Response))
|
258
|
+
|
259
|
+
begin
|
260
|
+
r = connection.get(url) do |req|
|
261
|
+
req.headers.merge!(headers)
|
262
|
+
req.options.timeout = timeout unless timeout.nil?
|
263
|
+
Utils.configure_request_security(req, security)
|
264
|
+
|
265
|
+
@sdk_configuration.hooks.before_request(
|
266
|
+
hook_ctx: SDKHooks::BeforeRequestHookContext.new(
|
267
|
+
hook_ctx: hook_ctx
|
268
|
+
),
|
269
|
+
request: req
|
270
|
+
)
|
271
|
+
end
|
272
|
+
rescue StandardError => e
|
273
|
+
error = e
|
274
|
+
ensure
|
275
|
+
if r.nil? || Utils.error_status?(r.status)
|
276
|
+
r = @sdk_configuration.hooks.after_error(
|
277
|
+
error: error,
|
278
|
+
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
279
|
+
hook_ctx: hook_ctx
|
280
|
+
),
|
281
|
+
response: r
|
282
|
+
)
|
283
|
+
else
|
284
|
+
r = @sdk_configuration.hooks.after_success(
|
285
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
286
|
+
hook_ctx: hook_ctx
|
287
|
+
),
|
288
|
+
response: r
|
289
|
+
)
|
290
|
+
end
|
291
|
+
|
292
|
+
if r.nil?
|
293
|
+
raise error if !error.nil?
|
294
|
+
raise 'no response'
|
295
|
+
end
|
143
296
|
end
|
144
297
|
|
145
298
|
content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
|
@@ -168,8 +321,8 @@ module PlexRubySDK
|
|
168
321
|
end
|
169
322
|
|
170
323
|
|
171
|
-
sig { params(request: T.nilable(::PlexRubySDK::Operations::PostUsersSignInDataRequest), server_url: T.nilable(String)).returns(::PlexRubySDK::Operations::PostUsersSignInDataResponse) }
|
172
|
-
def post_users_sign_in_data(request, server_url = nil)
|
324
|
+
sig { params(request: T.nilable(::PlexRubySDK::Operations::PostUsersSignInDataRequest), server_url: T.nilable(String), timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::PostUsersSignInDataResponse) }
|
325
|
+
def post_users_sign_in_data(request, server_url = nil, timeout_ms = nil)
|
173
326
|
# post_users_sign_in_data - Get User Sign In Data
|
174
327
|
# Sign in user with username and password and return user data with Plex authentication token
|
175
328
|
base_url = Utils.template_url(POST_USERS_SIGN_IN_DATA_SERVERS[0], {
|
@@ -179,17 +332,68 @@ module PlexRubySDK
|
|
179
332
|
headers = Utils.get_headers(request)
|
180
333
|
req_content_type, data, form = Utils.serialize_request_body(request, :request_body, :form)
|
181
334
|
headers['content-type'] = req_content_type
|
335
|
+
|
336
|
+
if form
|
337
|
+
body = Utils.encode_form(form)
|
338
|
+
elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded')
|
339
|
+
body = URI.encode_www_form(data)
|
340
|
+
else
|
341
|
+
body = data
|
342
|
+
end
|
182
343
|
headers['Accept'] = 'application/json'
|
183
344
|
headers['user-agent'] = @sdk_configuration.user_agent
|
184
345
|
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
346
|
+
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
|
347
|
+
timeout ||= @sdk_configuration.timeout
|
348
|
+
|
349
|
+
connection = @sdk_configuration.client
|
350
|
+
|
351
|
+
hook_ctx = SDKHooks::HookContext.new(
|
352
|
+
base_url: base_url,
|
353
|
+
oauth2_scopes: nil,
|
354
|
+
operation_id: 'post-users-sign-in-data',
|
355
|
+
security_source: nil
|
356
|
+
)
|
357
|
+
|
358
|
+
error = T.let(nil, T.nilable(StandardError))
|
359
|
+
r = T.let(nil, T.nilable(Faraday::Response))
|
360
|
+
|
361
|
+
begin
|
362
|
+
r = connection.post(url) do |req|
|
363
|
+
req.body = body
|
364
|
+
req.headers.merge!(headers)
|
365
|
+
req.options.timeout = timeout unless timeout.nil?
|
366
|
+
|
367
|
+
@sdk_configuration.hooks.before_request(
|
368
|
+
hook_ctx: SDKHooks::BeforeRequestHookContext.new(
|
369
|
+
hook_ctx: hook_ctx
|
370
|
+
),
|
371
|
+
request: req
|
372
|
+
)
|
373
|
+
end
|
374
|
+
rescue StandardError => e
|
375
|
+
error = e
|
376
|
+
ensure
|
377
|
+
if r.nil? || Utils.error_status?(r.status)
|
378
|
+
r = @sdk_configuration.hooks.after_error(
|
379
|
+
error: error,
|
380
|
+
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
381
|
+
hook_ctx: hook_ctx
|
382
|
+
),
|
383
|
+
response: r
|
384
|
+
)
|
191
385
|
else
|
192
|
-
|
386
|
+
r = @sdk_configuration.hooks.after_success(
|
387
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
388
|
+
hook_ctx: hook_ctx
|
389
|
+
),
|
390
|
+
response: r
|
391
|
+
)
|
392
|
+
end
|
393
|
+
|
394
|
+
if r.nil?
|
395
|
+
raise error if !error.nil?
|
396
|
+
raise 'no response'
|
193
397
|
end
|
194
398
|
end
|
195
399
|
|