Class: PlexRubySDK::PlexAPI
- Inherits:
-
Object
- Object
- PlexRubySDK::PlexAPI
- Extended by:
- T::Sig
- Defined in:
- lib/plex_ruby_sdk/plex_api.rb
Instance Attribute Summary collapse
-
#activities ⇒ Object
Returns the value of attribute activities.
-
#authentication ⇒ Object
Returns the value of attribute authentication.
-
#butler ⇒ Object
Returns the value of attribute butler.
-
#hubs ⇒ Object
Returns the value of attribute hubs.
-
#library ⇒ Object
Returns the value of attribute library.
-
#log ⇒ Object
Returns the value of attribute log.
-
#media ⇒ Object
Returns the value of attribute media.
-
#playlists ⇒ Object
Returns the value of attribute playlists.
-
#plex ⇒ Object
Returns the value of attribute plex.
-
#search ⇒ Object
Returns the value of attribute search.
-
#server ⇒ Object
Returns the value of attribute server.
-
#sessions ⇒ Object
Returns the value of attribute sessions.
-
#statistics ⇒ Object
Returns the value of attribute statistics.
-
#updater ⇒ Object
Returns the value of attribute updater.
-
#users ⇒ Object
Returns the value of attribute users.
-
#video ⇒ Object
Returns the value of attribute video.
-
#watchlist ⇒ Object
Returns the value of attribute watchlist.
Instance Method Summary collapse
- #init_sdks ⇒ Object
-
#initialize(client: nil, retry_config: nil, timeout_ms: nil, security: nil, security_source: nil, protocol: nil, ip: nil, port: nil, server_idx: nil, server_url: nil, url_params: nil) ⇒ PlexAPI
constructor
A new instance of PlexAPI.
Constructor Details
#initialize(client: nil, retry_config: nil, timeout_ms: nil, security: nil, security_source: nil, protocol: nil, ip: nil, port: nil, server_idx: nil, server_url: nil, url_params: nil) ⇒ PlexAPI
Returns a new instance of PlexAPI.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/plex_ruby_sdk/plex_api.rb', line 36 def initialize(client: nil, retry_config: nil, timeout_ms: nil, security: nil, security_source: nil, protocol: nil, ip: nil, port: nil, server_idx: nil, server_url: nil, url_params: nil) ## Instantiates the SDK configuring it with the provided parameters. # @param [T.nilable(Faraday::Connection)] client The faraday HTTP client to use for all operations # @param [T.nilable(::PlexRubySDK::Utils::RetryConfig)] retry_config The retry configuration to use for all operations # @param [T.nilable(Integer)] timeout_ms Request timeout in milliseconds for all operations # @param [T.nilable(Models::Shared::Security)] security: The security details required for authentication # @param [T.proc.returns(T.nilable(Models::Shared::Security))] security_source: A function that returns security details required for authentication # @param [T.nilable(::PlexRubySDK::Models::ServerVariables::ServerProtocol)] protocol: Allows setting the protocol variable for url substitution # @param [T.nilable(::String)] ip: Allows setting the ip variable for url substitution # @param [T.nilable(::String)] port: Allows setting the port variable for url substitution # @param [T.nilable(::Integer)] server_idx The index of the server to use for all operations # @param [T.nilable(::String)] server_url The server URL to use for all operations # @param [T.nilable(::Hash<::Symbol, ::String>)] url_params Parameters to optionally template the server URL with = { request: { params_encoder: Faraday::FlatParamsEncoder } } [:request][:timeout] = (timeout_ms.to_f / 1000) unless timeout_ms.nil? client ||= Faraday.new(**) do |f| f.request :multipart, {} # f.response :logger, nil, { headers: true, bodies: true, errors: true } end if !server_url.nil? if !url_params.nil? server_url = Utils.template_url(server_url, url_params) elsif !protocol.nil? || !ip.nil? || !port.nil? url_params = { protocol: protocol || 'https', ip: ip || '10.10.10.47', port: port || '32400', } server_url = Utils.template_url(server_url, url_params) end end server_idx = 0 if server_idx.nil? server_params = [ { protocol: protocol || 'https', ip: ip || '10.10.10.47', port: port || '32400', }, ] hooks = SDKHooks::Hooks.new @sdk_configuration = SDKConfiguration.new( client, hooks, retry_config, timeout_ms, security, security_source, server_url, server_idx, server_params ) original_server_url = @sdk_configuration.get_server_details.first new_server_url, @sdk_configuration.client = hooks.sdk_init(base_url: original_server_url, client: client) @sdk_configuration.server_url = new_server_url if new_server_url != original_server_url init_sdks end |
Instance Attribute Details
#activities ⇒ Object
Returns the value of attribute activities.
19 20 21 |
# File 'lib/plex_ruby_sdk/plex_api.rb', line 19 def activities @activities end |
#authentication ⇒ Object
Returns the value of attribute authentication.
19 20 21 |
# File 'lib/plex_ruby_sdk/plex_api.rb', line 19 def authentication @authentication end |
#butler ⇒ Object
Returns the value of attribute butler.
19 20 21 |
# File 'lib/plex_ruby_sdk/plex_api.rb', line 19 def butler @butler end |
#hubs ⇒ Object
Returns the value of attribute hubs.
19 20 21 |
# File 'lib/plex_ruby_sdk/plex_api.rb', line 19 def hubs @hubs end |
#library ⇒ Object
Returns the value of attribute library.
19 20 21 |
# File 'lib/plex_ruby_sdk/plex_api.rb', line 19 def library @library end |
#log ⇒ Object
Returns the value of attribute log.
19 20 21 |
# File 'lib/plex_ruby_sdk/plex_api.rb', line 19 def log @log end |
#media ⇒ Object
Returns the value of attribute media.
19 20 21 |
# File 'lib/plex_ruby_sdk/plex_api.rb', line 19 def media @media end |
#playlists ⇒ Object
Returns the value of attribute playlists.
19 20 21 |
# File 'lib/plex_ruby_sdk/plex_api.rb', line 19 def playlists @playlists end |
#plex ⇒ Object
Returns the value of attribute plex.
19 20 21 |
# File 'lib/plex_ruby_sdk/plex_api.rb', line 19 def plex @plex end |
#search ⇒ Object
Returns the value of attribute search.
19 20 21 |
# File 'lib/plex_ruby_sdk/plex_api.rb', line 19 def search @search end |
#server ⇒ Object
Returns the value of attribute server.
19 20 21 |
# File 'lib/plex_ruby_sdk/plex_api.rb', line 19 def server @server end |
#sessions ⇒ Object
Returns the value of attribute sessions.
19 20 21 |
# File 'lib/plex_ruby_sdk/plex_api.rb', line 19 def sessions @sessions end |
#statistics ⇒ Object
Returns the value of attribute statistics.
19 20 21 |
# File 'lib/plex_ruby_sdk/plex_api.rb', line 19 def statistics @statistics end |
#updater ⇒ Object
Returns the value of attribute updater.
19 20 21 |
# File 'lib/plex_ruby_sdk/plex_api.rb', line 19 def updater @updater end |
#users ⇒ Object
Returns the value of attribute users.
19 20 21 |
# File 'lib/plex_ruby_sdk/plex_api.rb', line 19 def users @users end |
#video ⇒ Object
Returns the value of attribute video.
19 20 21 |
# File 'lib/plex_ruby_sdk/plex_api.rb', line 19 def video @video end |
#watchlist ⇒ Object
Returns the value of attribute watchlist.
19 20 21 |
# File 'lib/plex_ruby_sdk/plex_api.rb', line 19 def watchlist @watchlist end |
Instance Method Details
#init_sdks ⇒ Object
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/plex_ruby_sdk/plex_api.rb', line 105 def init_sdks @server = Server.new(@sdk_configuration) @media = Media.new(@sdk_configuration) @video = Video.new(@sdk_configuration) @activities = Activities.new(@sdk_configuration) @butler = Butler.new(@sdk_configuration) @plex = Plex.new(@sdk_configuration) @hubs = Hubs.new(@sdk_configuration) @search = Search.new(@sdk_configuration) @library = Library.new(@sdk_configuration) @watchlist = Watchlist.new(@sdk_configuration) @log = Log.new(@sdk_configuration) @playlists = Playlists.new(@sdk_configuration) @authentication = Authentication.new(@sdk_configuration) @statistics = Statistics.new(@sdk_configuration) @sessions = Sessions.new(@sdk_configuration) @updater = Updater.new(@sdk_configuration) @users = Users.new(@sdk_configuration) end |