Class: CanvasWebex::Service
- Inherits:
-
Object
- Object
- CanvasWebex::Service
- Defined in:
- lib/canvas_webex/service.rb
Instance Attribute Summary collapse
-
#meeting_password ⇒ Object
readonly
Returns the value of attribute meeting_password.
-
#partner_id ⇒ Object
readonly
Returns the value of attribute partner_id.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#site_id ⇒ Object
readonly
Returns the value of attribute site_id.
-
#site_name ⇒ Object
readonly
Returns the value of attribute site_name.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#webex_id ⇒ Object
readonly
Returns the value of attribute webex_id.
-
#webex_service ⇒ Object
readonly
Returns the value of attribute webex_service.
Instance Method Summary collapse
- #create_meeting(confName, options = {}) ⇒ Object
- #create_training_session(confName, options = {}) ⇒ Object
- #get_meeting(meeting_key) ⇒ Object
- #get_training_session(session_key) ⇒ Object
- #host_meeting_url(meeting_key, email) ⇒ Object
-
#initialize(webex_service, webex_id, password, site_id, site_name, partner_id, meeting_password) ⇒ Service
constructor
A new instance of Service.
- #join_meeting_url(meeting_key, email) ⇒ Object
- #list_recordings(meeting_key) ⇒ Object
- #list_summary_meetings ⇒ Object
- #list_time_zone(id, date) ⇒ Object
- #request(body) ⇒ Object
- #xml_request(email = nil) ⇒ Object
Constructor Details
#initialize(webex_service, webex_id, password, site_id, site_name, partner_id, meeting_password) ⇒ Service
Returns a new instance of Service.
7 8 9 10 |
# File 'lib/canvas_webex/service.rb', line 7 def initialize(webex_service, webex_id, password, site_id, site_name, partner_id, meeting_password) @webex_service, @webex_id, @password, @site_id, @site_name, @partner_id, @meeting_password = [webex_service, webex_id, password, site_id, site_name, partner_id, meeting_password] end |
Instance Attribute Details
#meeting_password ⇒ Object (readonly)
Returns the value of attribute meeting_password.
4 5 6 |
# File 'lib/canvas_webex/service.rb', line 4 def meeting_password @meeting_password end |
#partner_id ⇒ Object (readonly)
Returns the value of attribute partner_id.
4 5 6 |
# File 'lib/canvas_webex/service.rb', line 4 def partner_id @partner_id end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
4 5 6 |
# File 'lib/canvas_webex/service.rb', line 4 def password @password end |
#site_id ⇒ Object (readonly)
Returns the value of attribute site_id.
4 5 6 |
# File 'lib/canvas_webex/service.rb', line 4 def site_id @site_id end |
#site_name ⇒ Object (readonly)
Returns the value of attribute site_name.
4 5 6 |
# File 'lib/canvas_webex/service.rb', line 4 def site_name @site_name end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
4 5 6 |
# File 'lib/canvas_webex/service.rb', line 4 def status @status end |
#webex_id ⇒ Object (readonly)
Returns the value of attribute webex_id.
4 5 6 |
# File 'lib/canvas_webex/service.rb', line 4 def webex_id @webex_id end |
#webex_service ⇒ Object (readonly)
Returns the value of attribute webex_service.
4 5 6 |
# File 'lib/canvas_webex/service.rb', line 4 def webex_service @webex_service end |
Instance Method Details
#create_meeting(confName, options = {}) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/canvas_webex/service.rb', line 30 def create_meeting(confName, = {}) body = xml_request do |xml| xml.bodyContent('xsi:type' =>'java:com.webex.service.binding.meeting.CreateMeeting'){ xml.{ xml.confName confName } if meeting_password != nil && meeting_password.strip != '' xml.accessControl{ xml.meetingPassword meeting_password } end xml.schedule{ if [:scheduled_date].present? xml.startDate [:scheduled_date].in_time_zone('America/Los_Angeles').strftime("%m/%d/%Y %T") rescue nil xml.timeZoneID 4 else xml.startDate end xml.duration([:duration].to_i) } if [:emails] xml.participants{ xml.attendees{ [:emails].each do |email| xml.attendee { xml.emailInvitations true xml.person { xml.email email } } end } } end } end request(body) end |
#create_training_session(confName, options = {}) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/canvas_webex/service.rb', line 70 def create_training_session(confName, = {}) body = xml_request do |xml| xml.bodyContent('xsi:type' =>'java:com.webex.service.binding.training.CreateTrainingSession'){ xml.{ xml.confName confName } if meeting_password != nil && meeting_password.strip != '' xml.accessControl{ xml.sessionPassword meeting_password } end xml.schedule{ if [:scheduled_date].present? xml.startDate [:scheduled_date].in_time_zone('America/Los_Angeles').strftime("%m/%d/%Y %T") rescue nil xml.timeZoneID 4 else xml.startDate end xml.duration([:duration].to_i) } if [:emails] xml.attendees{ xml.participants{ [:emails].each do |email| xml.participant{ xml.person { xml.email email } } end } } xml.attendeeOptions { xml.emailInvitations true } end } end request(body) end |
#get_meeting(meeting_key) ⇒ Object
129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/canvas_webex/service.rb', line 129 def get_meeting(meeting_key) body = xml_request do |xml| xml.bodyContent('xsi:type' => 'java:com.webex.service.binding.meeting.GetMeeting'){ xml.meetingKey meeting_key } end begin request(body) rescue CanvasWebex::ConnectionError nil end end |
#get_training_session(session_key) ⇒ Object
143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/canvas_webex/service.rb', line 143 def get_training_session(session_key) body = xml_request do |xml| xml.bodyContent('xsi:type' => 'java:com.webex.service.binding.training.GetTrainingSession'){ xml.sessionKey session_key } end begin request(body) rescue CanvasWebex::ConnectionError nil end end |
#host_meeting_url(meeting_key, email) ⇒ Object
111 112 113 114 115 116 117 118 |
# File 'lib/canvas_webex/service.rb', line 111 def host_meeting_url(meeting_key, email) body = xml_request(email) do |xml| xml.bodyContent('xsi:type' => 'java:com.webex.service.binding.meeting.GethosturlMeeting'){ xml.meetingKey meeting_key } end request(body) end |
#join_meeting_url(meeting_key, email) ⇒ Object
120 121 122 123 124 125 126 127 |
# File 'lib/canvas_webex/service.rb', line 120 def join_meeting_url(meeting_key, email) body = xml_request(email) do |xml| xml.bodyContent('xsi:type' => 'java:com.webex.service.binding.meeting.GetjoinurlMeeting'){ xml.meetingKey meeting_key } end request(body) end |
#list_recordings(meeting_key) ⇒ Object
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/canvas_webex/service.rb', line 156 def list_recordings(meeting_key) body = xml_request do |xml| xml.bodyContent('xsi:type' => 'java:com.webex.service.binding.ep.LstRecording'){ xml.listControl{ xml.startFrom 0 } xml.sessionKey meeting_key xml.hostWebExID @webex_id xml.returnSessionDetails 'true' } end begin request(body) rescue CanvasWebex::ConnectionError nil end end |
#list_summary_meetings ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/canvas_webex/service.rb', line 12 def list_summary_meetings body = xml_request do |xml| xml.bodyContent('xsi:type' => 'java:com.webex.service.binding.meeting.LstsummaryMeeting'){ xml.listControl{ xml.startFrom 1 xml.listMethod 'OR' } xml.order{ xml.orderAD 'ASC' xml.orderBy 'STARTTIME' xml.orderAD 'ASC' xml.orderBy 'CONFNAME' } } end request(body) end |
#list_time_zone(id, date) ⇒ Object
174 175 176 177 178 179 180 181 182 |
# File 'lib/canvas_webex/service.rb', line 174 def list_time_zone(id, date) body = xml_request do |xml| xml.bodyContent('xsi:type' => 'site.LstTimeZone'){ xml.timeZoneID id xml.date date } end request(body) end |
#request(body) ⇒ Object
208 209 210 211 212 213 214 215 216 217 218 219 |
# File 'lib/canvas_webex/service.rb', line 208 def request(body) uri = URI.parse("https://#{@site_name}.webex.com") http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true response = http.post('/WBXService/XMLService', body) xml = Nokogiri::XML(response.body).remove_namespaces! if xml.at_xpath('/message/header/response/result').try(:text) == 'SUCCESS' xml.at_xpath('/message/body/bodyContent') else raise CanvasWebex::ConnectionError.new(xml.at_xpath('/message/header/response/reason').try(:text)) end end |
#xml_request(email = nil) ⇒ Object
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
# File 'lib/canvas_webex/service.rb', line 184 def 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 @webex_id xml.password @password xml.siteID @site_id xml.partnerID @partner_id if !!@partner_id xml.email email if !!email } } xml.body{ xml.parent.namespace = xml.parent.namespace_definitions.first yield xml } } end.to_xml end |