Class: PlexRubySDK::PlexAPI

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/plex_ruby_sdk/plex_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client: 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.



31
32
33
34
35
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
# File 'lib/plex_ruby_sdk/plex_api.rb', line 31

def initialize(client: 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::Request)] client The faraday HTTP client to use for all operations
  # @param [T.nilable(::PlexRubySDK::Shared::Security)] security: The security details required for authentication
  # @param [T.proc.returns(T.nilable(::PlexRubySDK::Shared::Security))] security_source: A function that returns security details required for authentication
  # @param [T.nilable(::PlexRubySDK::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

  if client.nil?
    client = Faraday.new(request: {
                      params_encoder: Faraday::FlatParamsEncoder
                    }) do |f|
      f.request :multipart, {}
      # f.response :logger
    end
  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',
    },
  ]
  @sdk_configuration = SDKConfiguration.new(
    client,
    security,
    security_source,
    server_url,
    server_idx,
    server_params
  )
  init_sdks
end

Instance Attribute Details

#activitiesObject

Returns the value of attribute activities.



16
17
18
# File 'lib/plex_ruby_sdk/plex_api.rb', line 16

def activities
  @activities
end

#authenticationObject

Returns the value of attribute authentication.



16
17
18
# File 'lib/plex_ruby_sdk/plex_api.rb', line 16

def authentication
  @authentication
end

#butlerObject

Returns the value of attribute butler.



16
17
18
# File 'lib/plex_ruby_sdk/plex_api.rb', line 16

def butler
  @butler
end

#hubsObject

Returns the value of attribute hubs.



16
17
18
# File 'lib/plex_ruby_sdk/plex_api.rb', line 16

def hubs
  @hubs
end

#libraryObject

Returns the value of attribute library.



16
17
18
# File 'lib/plex_ruby_sdk/plex_api.rb', line 16

def library
  @library
end

#logObject

Returns the value of attribute log.



16
17
18
# File 'lib/plex_ruby_sdk/plex_api.rb', line 16

def log
  @log
end

#mediaObject

Returns the value of attribute media.



16
17
18
# File 'lib/plex_ruby_sdk/plex_api.rb', line 16

def media
  @media
end

#playlistsObject

Returns the value of attribute playlists.



16
17
18
# File 'lib/plex_ruby_sdk/plex_api.rb', line 16

def playlists
  @playlists
end

#plexObject

Returns the value of attribute plex.



16
17
18
# File 'lib/plex_ruby_sdk/plex_api.rb', line 16

def plex
  @plex
end

#searchObject

Returns the value of attribute search.



16
17
18
# File 'lib/plex_ruby_sdk/plex_api.rb', line 16

def search
  @search
end

#serverObject

Returns the value of attribute server.



16
17
18
# File 'lib/plex_ruby_sdk/plex_api.rb', line 16

def server
  @server
end

#sessionsObject

Returns the value of attribute sessions.



16
17
18
# File 'lib/plex_ruby_sdk/plex_api.rb', line 16

def sessions
  @sessions
end

#statisticsObject

Returns the value of attribute statistics.



16
17
18
# File 'lib/plex_ruby_sdk/plex_api.rb', line 16

def statistics
  @statistics
end

#updaterObject

Returns the value of attribute updater.



16
17
18
# File 'lib/plex_ruby_sdk/plex_api.rb', line 16

def updater
  @updater
end

#usersObject

Returns the value of attribute users.



16
17
18
# File 'lib/plex_ruby_sdk/plex_api.rb', line 16

def users
  @users
end

#videoObject

Returns the value of attribute video.



16
17
18
# File 'lib/plex_ruby_sdk/plex_api.rb', line 16

def video
  @video
end

#watchlistObject

Returns the value of attribute watchlist.



16
17
18
# File 'lib/plex_ruby_sdk/plex_api.rb', line 16

def watchlist
  @watchlist
end

Instance Method Details

#init_sdksObject



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/plex_ruby_sdk/plex_api.rb', line 86

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