class WebexXmlApi::SecurityContext

SecurityContext class is shared among other API calls and is providing the WebEx XML API Service with user credentials for authentification.

Constants

PARAMETER_MAPPING

Allowed parameters in the SecurityContext class.

Public Class Methods

new(attributes = {}) click to toggle source

The initialize method for newly created instance parsing provided parameters (if any).

# File lib/webex_xml_api/security_context.rb, line 26
def initialize(attributes = {})
  attributes.each_pair do |k, v|
    send("#{k}=", v) if PARAMETER_MAPPING.key?(k)
  end
end

Public Instance Methods

to_xml() click to toggle source

The to_xml method returns XML representation of the SecurityContext instance as understood by the WebEx XML Service.

# File lib/webex_xml_api/security_context.rb, line 36
def to_xml
  raise WebexXmlApi::NotEnoughArguments, 'SecurityContext' unless valid?
  builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
    xml.header do
      xml.securityContext do
        PARAMETER_MAPPING.each_pair do |k, v|
          xml.send(v, send(k)) if send(k)
        end
      end
    end
  end
  builder.to_xml.gsub("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n", '')
end
valid?(context = self) click to toggle source

Returns true if required parameters provided, otherwise false. Parameters :site_name and :webex_id are required. One of the parameters :password or :session_ticket are required too.

# File lib/webex_xml_api/security_context.rb, line 55
def valid?(context = self)
  return false if context.site_name.nil? || context.webex_id.nil?
  return false if context.password.nil? && context.session_ticket.nil?
  true
end