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
@@ -0,0 +1,103 @@
|
|
1
|
+
# Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
2
|
+
|
3
|
+
# typed: true
|
4
|
+
# frozen_string_literal: true
|
5
|
+
|
6
|
+
require_relative './registration'
|
7
|
+
require_relative './types'
|
8
|
+
|
9
|
+
require 'sorbet-runtime'
|
10
|
+
|
11
|
+
module PlexRubySDK
|
12
|
+
module SDKHooks
|
13
|
+
class Hooks
|
14
|
+
extend T::Sig
|
15
|
+
|
16
|
+
sig { void }
|
17
|
+
def initialize
|
18
|
+
@sdk_init_hooks = T.let([], T::Array[AbstractSDKInitHook])
|
19
|
+
@before_request_hooks = T.let([], T::Array[AbstractBeforeRequestHook])
|
20
|
+
@after_success_hooks = T.let([], T::Array[AbstractAfterSuccessHook])
|
21
|
+
@after_error_hooks = T.let([], T::Array[AbstractAfterErrorHook])
|
22
|
+
Registration.init_hooks self
|
23
|
+
end
|
24
|
+
|
25
|
+
sig { params(hook: AbstractSDKInitHook).void }
|
26
|
+
def register_sdk_init_hook(hook)
|
27
|
+
@sdk_init_hooks << hook
|
28
|
+
end
|
29
|
+
|
30
|
+
sig { params(hook: AbstractBeforeRequestHook).void }
|
31
|
+
def register_before_request_hook(hook)
|
32
|
+
@before_request_hooks << hook
|
33
|
+
end
|
34
|
+
|
35
|
+
sig { params(hook: AbstractAfterSuccessHook).void }
|
36
|
+
def register_after_success_hook(hook)
|
37
|
+
@after_success_hooks << hook
|
38
|
+
end
|
39
|
+
|
40
|
+
sig { params(hook: AbstractAfterErrorHook).void }
|
41
|
+
def register_after_error_hook(hook)
|
42
|
+
@after_error_hooks << hook
|
43
|
+
end
|
44
|
+
|
45
|
+
sig do
|
46
|
+
params(
|
47
|
+
base_url: String,
|
48
|
+
client: Faraday::Connection
|
49
|
+
).returns([String, Faraday::Connection])
|
50
|
+
end
|
51
|
+
def sdk_init(base_url:, client:)
|
52
|
+
@sdk_init_hooks.each do |hook|
|
53
|
+
base_url, client = hook.sdk_init(base_url: base_url, client: client)
|
54
|
+
end
|
55
|
+
|
56
|
+
return base_url, client
|
57
|
+
end
|
58
|
+
|
59
|
+
sig do
|
60
|
+
params(
|
61
|
+
hook_ctx: BeforeRequestHookContext,
|
62
|
+
request: Faraday::Request
|
63
|
+
).returns(Faraday::Request)
|
64
|
+
end
|
65
|
+
def before_request(hook_ctx:, request:)
|
66
|
+
@before_request_hooks.each do |hook|
|
67
|
+
request = hook.before_request(hook_ctx: hook_ctx, request: request)
|
68
|
+
end
|
69
|
+
|
70
|
+
request
|
71
|
+
end
|
72
|
+
|
73
|
+
sig do
|
74
|
+
params(
|
75
|
+
hook_ctx: AfterSuccessHookContext,
|
76
|
+
response: Faraday::Response
|
77
|
+
).returns(Faraday::Response)
|
78
|
+
end
|
79
|
+
def after_success(hook_ctx:, response:)
|
80
|
+
@after_success_hooks.each do |hook|
|
81
|
+
response = hook.after_success(hook_ctx: hook_ctx, response: response)
|
82
|
+
end
|
83
|
+
|
84
|
+
response
|
85
|
+
end
|
86
|
+
|
87
|
+
sig do
|
88
|
+
params(
|
89
|
+
error: T.nilable(StandardError),
|
90
|
+
hook_ctx: AfterErrorHookContext,
|
91
|
+
response: T.nilable(Faraday::Response)
|
92
|
+
).returns(T.nilable(Faraday::Response))
|
93
|
+
end
|
94
|
+
def after_error(error:, hook_ctx:, response:)
|
95
|
+
@after_error_hooks.each do |hook|
|
96
|
+
response = hook.after_error(error: error, hook_ctx: hook_ctx, response: response)
|
97
|
+
end
|
98
|
+
|
99
|
+
response
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# typed: true
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file is only ever generated once on the first generation and then is free to be modified.
|
6
|
+
# Any hooks you wish to add should be registered in the init_hooks method.
|
7
|
+
#
|
8
|
+
# Hooks are registered per SDK instance, and are valid for the lifetime of the SDK instance.
|
9
|
+
#
|
10
|
+
|
11
|
+
require_relative './types'
|
12
|
+
|
13
|
+
require 'sorbet-runtime'
|
14
|
+
|
15
|
+
module PlexRubySDK
|
16
|
+
module SDKHooks
|
17
|
+
class Registration
|
18
|
+
extend T::Sig
|
19
|
+
|
20
|
+
sig do
|
21
|
+
params(
|
22
|
+
hooks: Hooks
|
23
|
+
).void
|
24
|
+
end
|
25
|
+
def self.init_hooks(hooks)
|
26
|
+
# example_hook = ExampleHook.new
|
27
|
+
|
28
|
+
# hooks.register_sdk_init_hook example_hook
|
29
|
+
# hooks.register_before_request_hook example_hook
|
30
|
+
# hooks.register_after_error_hook example_hook
|
31
|
+
# hooks.register_after_success_hook example_hook
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,152 @@
|
|
1
|
+
# Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
2
|
+
|
3
|
+
# typed: true
|
4
|
+
# frozen_string_literal: true
|
5
|
+
|
6
|
+
require 'sorbet-runtime'
|
7
|
+
|
8
|
+
module PlexRubySDK
|
9
|
+
module SDKHooks
|
10
|
+
class HookContext
|
11
|
+
extend T::Sig
|
12
|
+
|
13
|
+
sig { returns(String) }
|
14
|
+
attr_accessor :base_url
|
15
|
+
|
16
|
+
sig { returns(T.nilable(T::Array[String])) }
|
17
|
+
attr_accessor :oauth2_scopes
|
18
|
+
|
19
|
+
sig { returns(String) }
|
20
|
+
attr_accessor :operation_id
|
21
|
+
|
22
|
+
sig { returns(T.nilable(T.proc.returns(T.untyped))) }
|
23
|
+
attr_accessor :security_source
|
24
|
+
|
25
|
+
sig do
|
26
|
+
params(
|
27
|
+
base_url: String,
|
28
|
+
oauth2_scopes: T.nilable(T::Array[String]),
|
29
|
+
operation_id: String,
|
30
|
+
security_source: T.nilable(T.proc.returns(T.untyped))
|
31
|
+
).void
|
32
|
+
end
|
33
|
+
def initialize(base_url:, oauth2_scopes:, operation_id:, security_source:)
|
34
|
+
@base_url = T.let(base_url, String)
|
35
|
+
@oauth2_scopes = T.let(oauth2_scopes, T.nilable(T::Array[String]))
|
36
|
+
@operation_id = T.let(operation_id, String)
|
37
|
+
@security_source = T.let(security_source, T.nilable(T.proc.returns(T.untyped)))
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
class BeforeRequestHookContext < HookContext
|
42
|
+
extend T::Sig
|
43
|
+
|
44
|
+
sig do
|
45
|
+
params(
|
46
|
+
hook_ctx: HookContext
|
47
|
+
).void
|
48
|
+
end
|
49
|
+
def initialize(hook_ctx:)
|
50
|
+
super(
|
51
|
+
base_url: hook_ctx.base_url,
|
52
|
+
operation_id: hook_ctx.operation_id,
|
53
|
+
oauth2_scopes: hook_ctx.oauth2_scopes,
|
54
|
+
security_source: hook_ctx.security_source
|
55
|
+
)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
class AfterSuccessHookContext < HookContext
|
60
|
+
extend T::Sig
|
61
|
+
|
62
|
+
sig do
|
63
|
+
params(
|
64
|
+
hook_ctx: HookContext
|
65
|
+
).void
|
66
|
+
end
|
67
|
+
def initialize(hook_ctx:)
|
68
|
+
super(
|
69
|
+
base_url: hook_ctx.base_url,
|
70
|
+
operation_id: hook_ctx.operation_id,
|
71
|
+
oauth2_scopes: hook_ctx.oauth2_scopes,
|
72
|
+
security_source: hook_ctx.security_source
|
73
|
+
)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
class AfterErrorHookContext < HookContext
|
78
|
+
extend T::Sig
|
79
|
+
|
80
|
+
sig do
|
81
|
+
params(
|
82
|
+
hook_ctx: HookContext
|
83
|
+
).void
|
84
|
+
end
|
85
|
+
def initialize(hook_ctx:)
|
86
|
+
super(
|
87
|
+
base_url: hook_ctx.base_url,
|
88
|
+
operation_id: hook_ctx.operation_id,
|
89
|
+
oauth2_scopes: hook_ctx.oauth2_scopes,
|
90
|
+
security_source: hook_ctx.security_source
|
91
|
+
)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
module AbstractSDKInitHook
|
96
|
+
extend T::Sig
|
97
|
+
extend T::Helpers
|
98
|
+
abstract!
|
99
|
+
|
100
|
+
sig do
|
101
|
+
abstract.params(
|
102
|
+
base_url: String,
|
103
|
+
client: Faraday::Connection
|
104
|
+
).returns([String, Faraday::Connection])
|
105
|
+
end
|
106
|
+
def sdk_init(base_url:, client:); end
|
107
|
+
end
|
108
|
+
|
109
|
+
module AbstractBeforeRequestHook
|
110
|
+
extend T::Sig
|
111
|
+
extend T::Helpers
|
112
|
+
abstract!
|
113
|
+
|
114
|
+
sig do
|
115
|
+
abstract.params(
|
116
|
+
hook_ctx: BeforeRequestHookContext,
|
117
|
+
request: Faraday::Request
|
118
|
+
).returns(Faraday::Request)
|
119
|
+
end
|
120
|
+
def before_request(hook_ctx:, request:); end
|
121
|
+
end
|
122
|
+
|
123
|
+
module AbstractAfterSuccessHook
|
124
|
+
extend T::Sig
|
125
|
+
extend T::Helpers
|
126
|
+
abstract!
|
127
|
+
|
128
|
+
sig do
|
129
|
+
abstract.params(
|
130
|
+
hook_ctx: AfterSuccessHookContext,
|
131
|
+
response: Faraday::Response
|
132
|
+
).returns(Faraday::Response)
|
133
|
+
end
|
134
|
+
def after_success(hook_ctx:, response:); end
|
135
|
+
end
|
136
|
+
|
137
|
+
module AbstractAfterErrorHook
|
138
|
+
extend T::Sig
|
139
|
+
extend T::Helpers
|
140
|
+
abstract!
|
141
|
+
|
142
|
+
sig do
|
143
|
+
abstract.params(
|
144
|
+
error: T.nilable(StandardError),
|
145
|
+
hook_ctx: AfterErrorHookContext,
|
146
|
+
response: T.nilable(Faraday::Response)
|
147
|
+
).returns(T.nilable(Faraday::Response))
|
148
|
+
end
|
149
|
+
def after_error(error:, hook_ctx:, response:); end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
@@ -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
|
@@ -19,6 +22,9 @@ module PlexRubySDK
|
|
19
22
|
extend T::Sig
|
20
23
|
|
21
24
|
field :client, T.nilable(Faraday::Connection)
|
25
|
+
field :hooks, ::PlexRubySDK::SDKHooks::Hooks
|
26
|
+
field :retry_config, T.nilable(::PlexRubySDK::Utils::RetryConfig)
|
27
|
+
field :timeout, T.nilable(Float)
|
22
28
|
field :security_source, T.nilable(T.proc.returns(T.nilable(::PlexRubySDK::Shared::Security)))
|
23
29
|
field :server_url, T.nilable(String)
|
24
30
|
field :server_idx, T.nilable(Integer)
|
@@ -29,12 +35,25 @@ module PlexRubySDK
|
|
29
35
|
field :gen_version, String
|
30
36
|
field :user_agent, String
|
31
37
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
38
|
+
sig do
|
39
|
+
params(
|
40
|
+
client: T.nilable(Faraday::Connection),
|
41
|
+
hooks: ::PlexRubySDK::SDKHooks::Hooks,
|
42
|
+
retry_config: T.nilable(::PlexRubySDK::Utils::RetryConfig),
|
43
|
+
timeout_ms: T.nilable(Integer),
|
44
|
+
security: T.nilable(::PlexRubySDK::Shared::Security),
|
45
|
+
security_source: T.nilable(T.proc.returns(::PlexRubySDK::Shared::Security)),
|
46
|
+
server_url: T.nilable(String),
|
47
|
+
server_idx: T.nilable(Integer),
|
48
|
+
server_params: T::Array[String]
|
49
|
+
).void
|
50
|
+
end
|
51
|
+
def initialize(client, hooks, retry_config, timeout_ms, security, security_source, server_url, server_idx, server_params)
|
36
52
|
@client = client
|
53
|
+
@hooks = hooks
|
54
|
+
@retry_config = retry_config
|
37
55
|
@server_url = server_url
|
56
|
+
@timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
|
38
57
|
@server_idx = server_idx.nil? ? 0 : server_idx
|
39
58
|
raise StandardError, "Invalid server index #{server_idx}" if @server_idx.negative? || @server_idx >= SERVERS.length
|
40
59
|
@server_params = server_params
|
@@ -45,9 +64,9 @@ module PlexRubySDK
|
|
45
64
|
end
|
46
65
|
@language = 'ruby'
|
47
66
|
@openapi_doc_version = '0.0.3'
|
48
|
-
@sdk_version = '0.
|
49
|
-
@gen_version = '2.
|
50
|
-
@user_agent = 'speakeasy-sdk/ruby 0.
|
67
|
+
@sdk_version = '0.8.1'
|
68
|
+
@gen_version = '2.565.1'
|
69
|
+
@user_agent = 'speakeasy-sdk/ruby 0.8.1 2.565.1 0.0.3 plex_ruby_sdk'
|
51
70
|
end
|
52
71
|
|
53
72
|
sig { returns([String, T::Hash[Symbol, String]]) }
|
data/lib/plex_ruby_sdk/search.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(query: ::String, section_id: T.nilable(::Float), limit: T.nilable(::Float)).returns(::PlexRubySDK::Operations::PerformSearchResponse) }
|
24
|
-
def perform_search(query, section_id = nil, limit = nil)
|
26
|
+
sig { params(query: ::String, section_id: T.nilable(::Float), limit: T.nilable(::Float), timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::PerformSearchResponse) }
|
27
|
+
def perform_search(query, section_id = nil, limit = nil, timeout_ms = nil)
|
25
28
|
# perform_search - Perform a search
|
26
29
|
# This endpoint performs a search across all library sections, or a single section, and returns matches as hubs, split up by type. It performs spell checking, looks for partial matches, and orders the hubs based on quality of results. In addition, based on matches, it will return other related matches (e.g. for a genre match, it may return movies in that genre, or for an actor match, movies with that actor).
|
27
30
|
#
|
@@ -50,11 +53,61 @@ module PlexRubySDK
|
|
50
53
|
headers['Accept'] = 'application/json'
|
51
54
|
headers['user-agent'] = @sdk_configuration.user_agent
|
52
55
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
56
|
+
security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
|
57
|
+
|
58
|
+
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
|
59
|
+
timeout ||= @sdk_configuration.timeout
|
60
|
+
|
61
|
+
connection = @sdk_configuration.client
|
62
|
+
|
63
|
+
hook_ctx = SDKHooks::HookContext.new(
|
64
|
+
base_url: base_url,
|
65
|
+
oauth2_scopes: nil,
|
66
|
+
operation_id: 'performSearch',
|
67
|
+
security_source: @sdk_configuration.security_source
|
68
|
+
)
|
69
|
+
|
70
|
+
error = T.let(nil, T.nilable(StandardError))
|
71
|
+
r = T.let(nil, T.nilable(Faraday::Response))
|
72
|
+
|
73
|
+
begin
|
74
|
+
r = connection.get(url) do |req|
|
75
|
+
req.headers.merge!(headers)
|
76
|
+
req.options.timeout = timeout unless timeout.nil?
|
77
|
+
req.params = query_params
|
78
|
+
Utils.configure_request_security(req, security)
|
79
|
+
|
80
|
+
@sdk_configuration.hooks.before_request(
|
81
|
+
hook_ctx: SDKHooks::BeforeRequestHookContext.new(
|
82
|
+
hook_ctx: hook_ctx
|
83
|
+
),
|
84
|
+
request: req
|
85
|
+
)
|
86
|
+
end
|
87
|
+
rescue StandardError => e
|
88
|
+
error = e
|
89
|
+
ensure
|
90
|
+
if r.nil? || Utils.error_status?(r.status)
|
91
|
+
r = @sdk_configuration.hooks.after_error(
|
92
|
+
error: error,
|
93
|
+
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
94
|
+
hook_ctx: hook_ctx
|
95
|
+
),
|
96
|
+
response: r
|
97
|
+
)
|
98
|
+
else
|
99
|
+
r = @sdk_configuration.hooks.after_success(
|
100
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
101
|
+
hook_ctx: hook_ctx
|
102
|
+
),
|
103
|
+
response: r
|
104
|
+
)
|
105
|
+
end
|
106
|
+
|
107
|
+
if r.nil?
|
108
|
+
raise error if !error.nil?
|
109
|
+
raise 'no response'
|
110
|
+
end
|
58
111
|
end
|
59
112
|
|
60
113
|
content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
|
@@ -79,8 +132,8 @@ module PlexRubySDK
|
|
79
132
|
end
|
80
133
|
|
81
134
|
|
82
|
-
sig { params(query: ::String, section_id: T.nilable(::Float), limit: T.nilable(::Float)).returns(::PlexRubySDK::Operations::PerformVoiceSearchResponse) }
|
83
|
-
def perform_voice_search(query, section_id = nil, limit = nil)
|
135
|
+
sig { params(query: ::String, section_id: T.nilable(::Float), limit: T.nilable(::Float), timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::PerformVoiceSearchResponse) }
|
136
|
+
def perform_voice_search(query, section_id = nil, limit = nil, timeout_ms = nil)
|
84
137
|
# perform_voice_search - Perform a voice search
|
85
138
|
# This endpoint performs a search specifically tailored towards voice or other imprecise input which may work badly with the substring and spell-checking heuristics used by the `/hubs/search` endpoint.
|
86
139
|
# It uses a [Levenshtein distance](https://en.wikipedia.org/wiki/Levenshtein_distance) heuristic to search titles, and as such is much slower than the other search endpoint.
|
@@ -101,11 +154,61 @@ module PlexRubySDK
|
|
101
154
|
headers['Accept'] = 'application/json'
|
102
155
|
headers['user-agent'] = @sdk_configuration.user_agent
|
103
156
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
157
|
+
security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
|
158
|
+
|
159
|
+
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
|
160
|
+
timeout ||= @sdk_configuration.timeout
|
161
|
+
|
162
|
+
connection = @sdk_configuration.client
|
163
|
+
|
164
|
+
hook_ctx = SDKHooks::HookContext.new(
|
165
|
+
base_url: base_url,
|
166
|
+
oauth2_scopes: nil,
|
167
|
+
operation_id: 'performVoiceSearch',
|
168
|
+
security_source: @sdk_configuration.security_source
|
169
|
+
)
|
170
|
+
|
171
|
+
error = T.let(nil, T.nilable(StandardError))
|
172
|
+
r = T.let(nil, T.nilable(Faraday::Response))
|
173
|
+
|
174
|
+
begin
|
175
|
+
r = connection.get(url) do |req|
|
176
|
+
req.headers.merge!(headers)
|
177
|
+
req.options.timeout = timeout unless timeout.nil?
|
178
|
+
req.params = query_params
|
179
|
+
Utils.configure_request_security(req, security)
|
180
|
+
|
181
|
+
@sdk_configuration.hooks.before_request(
|
182
|
+
hook_ctx: SDKHooks::BeforeRequestHookContext.new(
|
183
|
+
hook_ctx: hook_ctx
|
184
|
+
),
|
185
|
+
request: req
|
186
|
+
)
|
187
|
+
end
|
188
|
+
rescue StandardError => e
|
189
|
+
error = e
|
190
|
+
ensure
|
191
|
+
if r.nil? || Utils.error_status?(r.status)
|
192
|
+
r = @sdk_configuration.hooks.after_error(
|
193
|
+
error: error,
|
194
|
+
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
195
|
+
hook_ctx: hook_ctx
|
196
|
+
),
|
197
|
+
response: r
|
198
|
+
)
|
199
|
+
else
|
200
|
+
r = @sdk_configuration.hooks.after_success(
|
201
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
202
|
+
hook_ctx: hook_ctx
|
203
|
+
),
|
204
|
+
response: r
|
205
|
+
)
|
206
|
+
end
|
207
|
+
|
208
|
+
if r.nil?
|
209
|
+
raise error if !error.nil?
|
210
|
+
raise 'no response'
|
211
|
+
end
|
109
212
|
end
|
110
213
|
|
111
214
|
content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
|
@@ -130,8 +233,8 @@ module PlexRubySDK
|
|
130
233
|
end
|
131
234
|
|
132
235
|
|
133
|
-
sig { params(query: ::String).returns(::PlexRubySDK::Operations::GetSearchResultsResponse) }
|
134
|
-
def get_search_results(query)
|
236
|
+
sig { params(query: ::String, timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::GetSearchResultsResponse) }
|
237
|
+
def get_search_results(query, timeout_ms = nil)
|
135
238
|
# get_search_results - Get Search Results
|
136
239
|
# This will search the database for the string provided.
|
137
240
|
request = ::PlexRubySDK::Operations::GetSearchResultsRequest.new(
|
@@ -146,11 +249,61 @@ module PlexRubySDK
|
|
146
249
|
headers['Accept'] = 'application/json'
|
147
250
|
headers['user-agent'] = @sdk_configuration.user_agent
|
148
251
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
252
|
+
security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
|
253
|
+
|
254
|
+
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
|
255
|
+
timeout ||= @sdk_configuration.timeout
|
256
|
+
|
257
|
+
connection = @sdk_configuration.client
|
258
|
+
|
259
|
+
hook_ctx = SDKHooks::HookContext.new(
|
260
|
+
base_url: base_url,
|
261
|
+
oauth2_scopes: nil,
|
262
|
+
operation_id: 'getSearchResults',
|
263
|
+
security_source: @sdk_configuration.security_source
|
264
|
+
)
|
265
|
+
|
266
|
+
error = T.let(nil, T.nilable(StandardError))
|
267
|
+
r = T.let(nil, T.nilable(Faraday::Response))
|
268
|
+
|
269
|
+
begin
|
270
|
+
r = connection.get(url) do |req|
|
271
|
+
req.headers.merge!(headers)
|
272
|
+
req.options.timeout = timeout unless timeout.nil?
|
273
|
+
req.params = query_params
|
274
|
+
Utils.configure_request_security(req, security)
|
275
|
+
|
276
|
+
@sdk_configuration.hooks.before_request(
|
277
|
+
hook_ctx: SDKHooks::BeforeRequestHookContext.new(
|
278
|
+
hook_ctx: hook_ctx
|
279
|
+
),
|
280
|
+
request: req
|
281
|
+
)
|
282
|
+
end
|
283
|
+
rescue StandardError => e
|
284
|
+
error = e
|
285
|
+
ensure
|
286
|
+
if r.nil? || Utils.error_status?(r.status)
|
287
|
+
r = @sdk_configuration.hooks.after_error(
|
288
|
+
error: error,
|
289
|
+
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
290
|
+
hook_ctx: hook_ctx
|
291
|
+
),
|
292
|
+
response: r
|
293
|
+
)
|
294
|
+
else
|
295
|
+
r = @sdk_configuration.hooks.after_success(
|
296
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
297
|
+
hook_ctx: hook_ctx
|
298
|
+
),
|
299
|
+
response: r
|
300
|
+
)
|
301
|
+
end
|
302
|
+
|
303
|
+
if r.nil?
|
304
|
+
raise error if !error.nil?
|
305
|
+
raise 'no response'
|
306
|
+
end
|
154
307
|
end
|
155
308
|
|
156
309
|
content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
|