Sha256: c6b5c7790068ea96eca192d20ca62350a0d0a7680b51d65d0186fd72e57a594b

Contents?: true

Size: 1.14 KB

Versions: 2

Compression:

Stored size: 1.14 KB

Contents

require 'kaltura'
require 'kaltura_box/configuration'

module KalturaBox
  class Client
    attr_accessor :client, :client_config, :session_key

    class << self

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

      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

      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)
        rescue Kaltura::KalturaAPIError => e
          puts e.message
        end
      end

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

    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
kaltura_box-0.0.2 lib/kaltura_box/client.rb
kaltura_box-0.0.1 lib/kaltura_box/client.rb