Class: KalturaBox::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/kaltura_box/client.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#clientObject

Returns the value of attribute client.



6
7
8
# File 'lib/kaltura_box/client.rb', line 6

def client
  @client
end

#client_configObject

Returns the value of attribute client_config.



6
7
8
# File 'lib/kaltura_box/client.rb', line 6

def client_config
  @client_config
end

#session_keyObject

Returns the value of attribute session_key.



6
7
8
# File 'lib/kaltura_box/client.rb', line 6

def session_key
  @session_key
end

Class Method Details

.createObject



10
11
12
13
14
15
# File 'lib/kaltura_box/client.rb', line 10

def create
  self.setup_config unless @client_config
  @client = Kaltura::KalturaClient.new(@client_config)
  @client.ks = @session_key
  @client
end

.generate_session_keyObject



27
28
29
30
31
32
33
34
35
36
# File 'lib/kaltura_box/client.rb', line 27

def generate_session_key
  self.update_session

  raise "Missing Administrator Secret" unless KalturaBox.config.administrator_secret
  begin
    @session_key = @client.session_service.start(KalturaBox.config.administrator_secret, '', Kaltura::KalturaSessionType::ADMIN, KalturaBox.config.partner_id, 315360000)
  rescue Kaltura::KalturaAPIError => e
    puts e.message
  end
end

.setup_configObject



17
18
19
20
21
22
23
24
25
# File 'lib/kaltura_box/client.rb', line 17

def setup_config
  raise "Missing Partner Identifier" unless KalturaBox.config.partner_id
  @client_config = Kaltura::KalturaConfiguration.new(KalturaBox.config.partner_id)
  @client_config.service_url = KalturaBox.config.service_url

  self.generate_session_key

  @client_config
end

.update_sessionObject



38
39
40
# File 'lib/kaltura_box/client.rb', line 38

def update_session
  @client ? @client : self.create
end