Class: WebexApi::Request
- Inherits:
-
Object
- Object
- WebexApi::Request
- Defined in:
- lib/webex_api/request.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
-
#error ⇒ Object
Returns the value of attribute error.
-
#success ⇒ Object
Returns the value of attribute success.
-
#xml_response ⇒ Object
Returns the value of attribute xml_response.
Instance Method Summary collapse
-
#initialize(client) ⇒ Request
constructor
A new instance of Request.
- #perform_request(body) ⇒ Object
- #webex_xml_request(email = nil) ⇒ Object
Constructor Details
#initialize(client) ⇒ Request
Returns a new instance of Request.
4 5 6 7 8 |
# File 'lib/webex_api/request.rb', line 4 def initialize(client) @client = client @success = false end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
3 4 5 |
# File 'lib/webex_api/request.rb', line 3 def client @client end |
#error ⇒ Object
Returns the value of attribute error.
3 4 5 |
# File 'lib/webex_api/request.rb', line 3 def error @error end |
#success ⇒ Object
Returns the value of attribute success.
3 4 5 |
# File 'lib/webex_api/request.rb', line 3 def success @success end |
#xml_response ⇒ Object
Returns the value of attribute xml_response.
3 4 5 |
# File 'lib/webex_api/request.rb', line 3 def xml_response @xml_response end |
Instance Method Details
#perform_request(body) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/webex_api/request.rb', line 34 def perform_request(body) uri = URI.parse("https://#{@client.site_name}.webex.com") http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true response = http.post('/WBXService/XMLService', body) xml_data = Nokogiri::XML(response.body).remove_namespaces! if xml_data.at_xpath('/message/header/response/result') && xml_data.at_xpath('/message/header/response/result').text == 'SUCCESS' @success = true @xml_response = xml_data.at_xpath('/message/body/bodyContent') else @error = xml_data.at_xpath('/message/header/response/reason').text rescue "error" raise WebexApi::WebexError.new(@error) end end |
#webex_xml_request(email = nil) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/webex_api/request.rb', line 9 def webex_xml_request(email=nil) Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml| xml.('xmlns:xsi' => "http://www.w3.org/2001/XMLSchema-instance", 'xmlns:serv' => "http://www.webex.com/schemas/2002/06/service", 'xsi:schemaLocation' => "http://www.webex.com/schemas/2002/06/service"){ xml.parent.namespace = xml.parent.namespace_definitions.find{|ns|ns.prefix=="serv"} xml.header{ xml.parent.namespace = xml.parent.namespace_definitions.first xml.securityContext { xml.webExID @client.webex_id xml.password @client.webex_password xml.siteID @client.site_id xml.partnerID @client.partner_id if !!@client.partner_id xml.email email if !!email } } xml.body{ xml.parent.namespace = xml.parent.namespace_definitions.first yield xml } } end.to_xml end |