Class: KodiClient::Methods::Favourites

Inherits:
KodiMethod
  • Object
show all
Defined in:
lib/kodi_client/methods/favourites.rb

Overview

contains all Kodi Application methods

Constant Summary collapse

ADD_FAVOURITE =
'Favourites.AddFavourite'
GET_FAVOURITES =
'Favourites.GetFavourites'

Instance Method Summary collapse

Methods inherited from KodiMethod

#apply_options, #invoke_api

Instance Method Details

#add_favourite(title, type = Types::Favourites::Type::UNKNOWN, path = nil, window = nil, window_parameter = nil, thumbnail = nil, kodi_id = 1) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/kodi_client/methods/favourites.rb', line 11

def add_favourite(title, type = Types::Favourites::Type::UNKNOWN, path = nil, window = nil,
                  window_parameter = nil, thumbnail = nil, kodi_id = 1)
  params = { 'title' => title, 'type' => type }
  params['path'] = path unless path.nil?
  params['window'] = window unless window.nil?
  params['windowparameter'] = window_parameter unless window_parameter.nil?
  params['thumbnail'] = thumbnail unless thumbnail.nil?
  request = KodiRequest.new(kodi_id, ADD_FAVOURITE, params)
  json = invoke_api(request)
  KodiResponse.new(json)
end

#get_favourites(properties = Types::Favourites::FieldsFavourite.all_properties, type = nil, kodi_id = 1) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/kodi_client/methods/favourites.rb', line 23

def get_favourites(properties = Types::Favourites::FieldsFavourite.all_properties, type = nil, kodi_id = 1)
  params = { 'properties' => properties }
  params['type'] = type unless type.nil?
  request = KodiRequest.new(kodi_id, GET_FAVOURITES, params)
  json = invoke_api(request)
  result = Types::Favourites::GetFavouriteReturned.create(json['result'])
  json['result'] = result
  KodiResponse.new(json)
end