Sha256: 21a2579fc8069ec8333bdc0b2f4e018b2e7fb496779d652d9d9a182ecfab912b

Contents?: true

Size: 1.18 KB

Versions: 1

Compression:

Stored size: 1.18 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, KalturaBox.config.partner_id, 315360000)
        rescue Kaltura::KalturaAPIError => e
          puts e.message
        end
      end

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

    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kaltura_box-0.0.3 lib/kaltura_box/client.rb