Class: Innowhite
- Inherits:
-
Object
- Object
- Innowhite
- Defined in:
- lib/innowhite.rb
Instance Attribute Summary collapse
-
#mod_name ⇒ Object
Returns the value of attribute mod_name.
-
#org_name ⇒ Object
Returns the value of attribute org_name.
-
#private_key ⇒ Object
Returns the value of attribute private_key.
-
#server_address ⇒ Object
Returns the value of attribute server_address.
-
#sub ⇒ Object
Returns the value of attribute sub.
Instance Method Summary collapse
- #cancel_meeting(room_id) ⇒ Object
- #create_room(params = {}) ⇒ Object
- #create_room_info(room_id, user, tags, desc, parent_org, address) ⇒ Object
- #create_schedule(room_id, user, tags, desc, parent_org, address, start_time, end_time, time_zone) ⇒ Object
- #get_scheduled_list(params = {}) ⇒ Object
- #get_sessions(params = {}) ⇒ Object
-
#initialize ⇒ Innowhite
constructor
A new instance of Innowhite.
- #join_meeting(room_id, user) ⇒ Object
- #load_settings ⇒ Object
- #past_sessions(params = {}) ⇒ Object
-
#schedule_meeting(params = {}) ⇒ Object
A call to schedule a session.
- #set_room_id ⇒ Object
- #update_schedule(params = {}) ⇒ Object
Constructor Details
#initialize ⇒ Innowhite
Returns a new instance of Innowhite.
9 10 11 12 13 |
# File 'lib/innowhite.rb', line 9 def initialize load_settings #@mod_name = mod_name.gsub(/ /,'') #@org_name = org_name.nil? ? @parent_org : org_name end |
Instance Attribute Details
#mod_name ⇒ Object
Returns the value of attribute mod_name.
7 8 9 |
# File 'lib/innowhite.rb', line 7 def mod_name @mod_name end |
#org_name ⇒ Object
Returns the value of attribute org_name.
7 8 9 |
# File 'lib/innowhite.rb', line 7 def org_name @org_name end |
#private_key ⇒ Object
Returns the value of attribute private_key.
7 8 9 |
# File 'lib/innowhite.rb', line 7 def private_key @private_key end |
#server_address ⇒ Object
Returns the value of attribute server_address.
7 8 9 |
# File 'lib/innowhite.rb', line 7 def server_address @server_address end |
#sub ⇒ Object
Returns the value of attribute sub.
7 8 9 |
# File 'lib/innowhite.rb', line 7 def sub @sub end |
Instance Method Details
#cancel_meeting(room_id) ⇒ Object
216 217 218 219 220 221 222 223 |
# File 'lib/innowhite.rb', line 216 def cancel_meeting(room_id) checksum = main_cheksum(@parent_org, @org_name) par = url_generator(@parent_org, @org_name) url = URI.escape("#{@api_address}cancel_meeting?roomId=#{room_id}&#{par}&checksum=#{checksum}") x = Nokogiri::XML(open(url)) return x.xpath("//success").map(&:text) end |
#create_room(params = {}) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/innowhite.rb', line 24 def create_room(params = {}) params[:parentOrg] ||= @parent_org params[:orgName] ||= @org_name user = params[:user] = params[:tags] desc = params[:desc] #parent_org = params[:parentOrg] @org_name = @parent_org if @org_name.nil? room_id = set_room_id address = join_room_helper(@server_address,@org_name, room_id, user,true) res = create_room_info(room_id,user,,desc, @org_name,address) res = res.include?("Missing") if res == true return "Failed to fetch, maybe you have entered wrong username / organization name .." else return {:address => address, :room_id => room_id} end end |
#create_room_info(room_id, user, tags, desc, parent_org, address) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/innowhite.rb', line 43 def create_room_info(room_id,user,,desc, parent_org,address) checksum_tmp = "parentOrg=#{parent_org}&orgName=#{parent_org}" checksum = (URI.escape(checksum_tmp)) res = RestClient.post("#{@api_address}create_room_info", {:roomId => room_id, :user => user, :tags => ,:desc => desc, :parentOrg => parent_org, :address => address, :orgName => parent_org, :checksum => checksum } ) return res end |
#create_schedule(room_id, user, tags, desc, parent_org, address, start_time, end_time, time_zone) ⇒ Object
171 172 173 174 175 176 177 178 179 180 181 182 183 |
# File 'lib/innowhite.rb', line 171 def create_schedule(room_id,user,,desc, parent_org,address, start_time, end_time, time_zone) checksum_tmp = "parentOrg=#{parent_org}&orgName=#{parent_org}" checksum = (URI.escape(checksum_tmp)) address = join_room_helper(@server_address,@org_name, room_id, user,true) res = RestClient.post("#{@api_address}create_schedule_meeting", {:roomId => room_id, :user => user, :tags => ,:desc => desc,:startTime => start_time, :endTime => end_time, :timeZone => time_zone, :parentOrg => parent_org, :address => address, :orgName => parent_org, :checksum => checksum } ) return res end |
#get_scheduled_list(params = {}) ⇒ Object
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
# File 'lib/innowhite.rb', line 185 def get_scheduled_list(params={}) @org_name ||= params[:orgName] checksum = main_cheksum(@parent_org, @org_name) = params[:tags] if params[:tags] par = url_generator(@parent_org, @org_name) url = URI.escape("#{@api_address}get_scheduled_sessions?#{par}&checksum=#{checksum}&tags=#{}") x = Nokogiri::XML(open(url)) ids = [], start_at = [], end_at = [], zone = [] desc = [] x.xpath('//web-session/session-id').each{|m| ids << m.text} x.xpath('//web-session/session-desc').each{|m| desc << m.text} x.xpath('//web-session/start-at').each{|m| start_at << m.text.to_time.to_i rescue 0} x.xpath('//web-session/end-at').each{|m| end_at << m.text.to_time.to_i rescue 0} x.xpath('//web-session/start-at').each{|m| zone << m.text.to_datetime.utc_offset rescue 0} res = [] ids.each_with_index do |id, index| res << { :tags => , :orgName => @org_name, :room_id => id, :startTime => start_at[index], :timeZone => zone[index], :endTime => end_at[index], :moderatorName => "", :room_desc => desc[index] } end return res end |
#get_sessions(params = {}) ⇒ Object
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/innowhite.rb', line 120 def get_sessions(params = {}) begin params[:parentOrg] ||= @parent_org if params[:orgName].nil? org_name1 = params[:parentOrg] else org_name1 = params[:orgName] end ids = [] parent_org = params[:parentOrg] org_name1 = parent_org if org_name1.blank? user = params[:user] = params[:tags] descs = [] res = [] checksum_tmp = "parentOrg=#{parent_org}&orgName=#{org_name1}" tmp = "parentOrg=#{parent_org}&orgName=#{org_name1}&user=#{user}&tags=#{}" checksum = (URI.escape(checksum_tmp)) url = URI.escape("#{@api_address}list_sessions?#{tmp}&checksum=#{checksum}") x = Nokogiri::XML(open(url)) x.xpath('//web-session/session-id').each{|m| ids << m.text} x.xpath('//web-session/session-desc').each{|m| descs << m.text} ids.each_with_index do |id, index| res << {:id => id, :description => descs[index]} end return res rescue => e return "Error fetching sessions check the organization and private key .." end end |
#join_meeting(room_id, user) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/innowhite.rb', line 75 def join_meeting(room_id, user) url = "#{@api_address}exist_session?roomId=#{room_id}" doc = Nokogiri::XML(open(url)) missing = false if doc.text.blank? missing = true end address = join_room_helper(@server_address,@org_name, room_id, user, false) if missing raise "Room is not exist / Expired" else return address end end |
#load_settings ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/innowhite.rb', line 15 def load_settings settings = YAML.load_file('config/innowhite.yml') @server_address = settings["innowhite"]["server_address"] @api_address = settings["innowhite"]["api_address"] @private_key = settings["innowhite"]["private_key"] @parent_org = settings["innowhite"]["organization"] @org_name = @parent_org end |
#past_sessions(params = {}) ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/innowhite.rb', line 91 def past_sessions(params = {}) begin params[:parentOrg] ||= @parent_org org_name1 = params[:parentOrg] if params[:orgName].nil? ids = [] parent_org = params[:parentOrg] user = params[:user] = params[:tags] descs = [] res = [] tmp = "parentOrg=#{parent_org}&orgName=#{org_name1}&user=#{user}&tags=#{}" checksum_tmp = "parentOrg=#{parent_org}&orgName=#{org_name1}" checksum = (URI.escape(checksum_tmp)) # pp "#{@api_address}list_sessions?#{tmp}&cheksum=#{checksum}" url = URI.escape("#{@api_address}past_sessions?#{tmp}&checksum=#{checksum}") x = Nokogiri::XML(open(url)) x.xpath('//web-session/session-id').each{|m| ids << m.text} x.xpath('//web-session/session-desc').each{|m| descs << m.text} ids.each_with_index do |id, index| res << {:id => id, :description => descs[index]} end return res rescue => e return "Error fetching sessions check the organization and private key .." end end |
#schedule_meeting(params = {}) ⇒ Object
A call to schedule a session
157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/innowhite.rb', line 157 def schedule_meeting(params = {}) @org_name ||= params[:orgName] = params[:tags] start_time = params[:startTime] time_zone = params[:timeZone] end_time = params[:endTime] user = params[:user] desc = params[:description] room_id = set_room_id address = join_room_helper(@server_address,@org_name, room_id, user,true) create_schedule(room_id, user, ,desc, @parent_org, address,start_time,end_time, time_zone) end |
#set_room_id ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/innowhite.rb', line 56 def set_room_id room_id = "" url = "#{@server_address}CreateRoom?parentOrg=#{@parent_org}&orgName=#{@org_name}&user=#{@mod_name}&checksum=#{generate_checksum(@parent_org,@org_name, @mod_name)}" doc = Nokogiri::XML(open(url)) status = doc.xpath('//returnStatus').text.gsub("\n","") rescue "" if status.include?('SUCCESS') room_id = doc.xpath('//roomId').text.gsub("\n","").to_i elsif status.include?('AUTH_FAILED') room_id = "AUTH_FAILED" elsif status.include?('EXPIRED') room_id = 'EXPIRED' elsif status.include?('OUT_OF_SERVICE') room_id = 'OUT_OF_SERVICE' else room_id = "Error With the Server #{@server_address}CreateRoom?parentOrg=#{@parent_org}&orgName=#{@org_name}&user=#{@mod_name}&checksum=#{generate_checksum(@parent_org,@org_name, @mod_name)}" end return room_id end |
#update_schedule(params = {}) ⇒ Object
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 |
# File 'lib/innowhite.rb', line 225 def update_schedule(params = {}) checksum = main_cheksum(@parent_org, @org_name) room_id = params[:room_id] start_time = params[:startTime] if params[:startTime] time_zone = params[:timeZone] if params[:timeZone] end_time = params[:endTime] if params[:endTime] desc = params[:description] if params[:description] = params[:tags] res = RestClient.put("#{@api_address}update_schedule", {:roomId => room_id, :tags => ,:description => desc, :parentOrg => @parent_org, :orgName => @org_name, :checksum => checksum } ) end |