Class: WebexXmlApi::User::GetUser

Inherits:
Object
  • Object
show all
Includes:
Common
Defined in:
lib/webex_xml_api/user/get_user.rb

Overview

The GetUser Class queries WebEx API Service for given WebEx User ID and returns the details of the User configuration

Constant Summary collapse

REQUEST_TYPE =

XML Request Type for the WebexXmlApi::User::GetUser service

'java:com.webex.service.binding.user.GetUser'.freeze
PARAMETER_MAPPING =

The webex_id is required parameter for this service

{
  webex_id: 'webExId'
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Common

#check_response_and_return_data, #create_xml_request, #post_webex_request, #process_object

Constructor Details

#initialize(attributes = {}) ⇒ GetUser

The initialize method for newly created instance parsing provided parameters (if any). The initialize method automaticaly creates new SecurityContext instance and passes the attribes.



31
32
33
34
35
36
# File 'lib/webex_xml_api/user/get_user.rb', line 31

def initialize(attributes = {})
  attributes.each_pair do |k, v|
    send("#{k}=", v) if PARAMETER_MAPPING.key?(k)
  end
  @security_context ||= WebexXmlApi::SecurityContext.new(attributes)
end

Instance Attribute Details

#requestObject (readonly)

Reader methods for request and response objects



24
25
26
# File 'lib/webex_xml_api/user/get_user.rb', line 24

def request
  @request
end

#responseObject (readonly)

Reader methods for request and response objects



24
25
26
# File 'lib/webex_xml_api/user/get_user.rb', line 24

def response
  @response
end

#security_contextObject

Accessor methods for the webex_id property and security_context object



22
23
24
# File 'lib/webex_xml_api/user/get_user.rb', line 22

def security_context
  @security_context
end

#webex_idObject

Accessor methods for the webex_id property and security_context object



22
23
24
# File 'lib/webex_xml_api/user/get_user.rb', line 22

def webex_id
  @webex_id
end

Instance Method Details

#send_requestObject

The send_request method will issue the XML API request to WebEx, parse the results and return data if successful. Upon failure an exception is raised.



66
67
68
69
70
# File 'lib/webex_xml_api/user/get_user.rb', line 66

def send_request
  @request = to_xml
  @response = post_webex_request(security_context.site_name, @request)
  check_response_and_return_data(@response)
end

#to_xmlObject

The to_xml method returns XML representation of the WebexXmlApi::User::GetUser instance as understood by the WebEx XML Service.



43
44
45
46
47
48
49
50
51
# File 'lib/webex_xml_api/user/get_user.rb', line 43

def to_xml
  raise WebexXmlApi::NotEnoughArguments, 'User::GetUser' unless valid?
  body_content = {}
  PARAMETER_MAPPING.each_pair do |k, v|
    body_content[v] = send(k) if send(k)
  end
  create_xml_request(@security_context.to_xml, REQUEST_TYPE,
                     body_content)
end

#valid?(context = self) ⇒ Boolean

Returns true if required parameters provided, otherwise false.

Returns:

  • (Boolean)


56
57
58
59
# File 'lib/webex_xml_api/user/get_user.rb', line 56

def valid?(context = self)
  return false if context.webex_id.nil?
  true
end