Class: KodiClient::Methods::Addons

Inherits:
KodiMethod show all
Defined in:
lib/kodi_client/methods/addons.rb

Overview

contains all Kodi Application methods

Constant Summary collapse

EXECUTE_ADDON =
'Addons.ExecuteAddon'
GET_ADDON_DETAILS =
'Addons.GetAddonDetails'
GET_ADDONS =
'Addons.GetAddons'
SET_ADDON_ENABLED =
'Addons.SetAddonEnabled'

Instance Method Summary collapse

Methods inherited from KodiMethod

#apply_options, #invoke_api

Instance Method Details

#execute_addon(addon_id = nil, params = '', wait = false, kodi_id = 1) ⇒ Object



42
43
44
45
46
47
# File 'lib/kodi_client/methods/addons.rb', line 42

def execute_addon(addon_id = nil, params = '', wait = false, kodi_id = 1)
  request = KodiRequest.new(kodi_id, EXECUTE_ADDON, { 'addonid' => addon_id, 'params' => params,
                                                      'wait' => wait })
  json = invoke_api(request)
  KodiResponse.new(json)
end

#get_addon_details(addon_id = nil, properties = [], kodi_id = 1) ⇒ Object



32
33
34
35
36
37
38
39
40
# File 'lib/kodi_client/methods/addons.rb', line 32

def get_addon_details(addon_id = nil, properties = [], kodi_id = 1)
  request = KodiRequest.new(kodi_id, GET_ADDON_DETAILS, { 'addonid' => addon_id,
                                                          'properties' => properties })
  json = invoke_api(request)

  result = Types::Addons::GetAddonReturned.create(json['result'])
  json['result'] = result
  KodiResponse.new(json)
end

#get_addons(type = Types::Addons::AddonTypes::UNKNOWN, content = Types::Addons::AddonContent::UNKNOWN, enabled = nil, properties = [], limits = Types::List::ListLimits.new(0, 50), installed = nil, kodi_id = 1) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/kodi_client/methods/addons.rb', line 13

def get_addons(type = Types::Addons::AddonTypes::UNKNOWN,
               content = Types::Addons::AddonContent::UNKNOWN,
               enabled = nil, properties = [],
               limits = Types::List::ListLimits.new(0, 50), installed = nil, kodi_id = 1)
  request = KodiRequest.new(kodi_id, GET_ADDONS,
                            {
                              'type' => type,
                              'content' => content,
                              'enabled' => enabled.nil? || !enabled ? 'all' : 'enabled',
                              'properties' => properties,
                              'limits' => limits.to_h,
                              'installed' => installed.nil? || !installed ? 'all' : 'installed'
                            })
  json = invoke_api(request)
  result = Types::Addons::GetAddonsReturned.create(json['result'])
  json['result'] = result
  KodiResponse.new(json)
end

#set_addon_enabled(addon_id = nil, enabled = Types::Global::Toggle::TOGGLE, kodi_id = 1) ⇒ Object



49
50
51
52
53
# File 'lib/kodi_client/methods/addons.rb', line 49

def set_addon_enabled(addon_id = nil, enabled = Types::Global::Toggle::TOGGLE, kodi_id = 1)
  request = KodiRequest.new(kodi_id, SET_ADDON_ENABLED, { 'addonid' => addon_id, 'enabled' => enabled })
  json = invoke_api(request)
  KodiResponse.new(json)
end