innowhite 0.1.7 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/innowhite.gemspec +1 -1
- data/lib/innowhite.rb +105 -54
- metadata +2 -2
data/innowhite.gemspec
CHANGED
data/lib/innowhite.rb
CHANGED
@@ -13,7 +13,7 @@ class Innowhite
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def load_settings
|
16
|
-
settings = YAML.load_file('config/
|
16
|
+
settings = YAML.load_file('config/innowhite_test.yml')
|
17
17
|
@server_address = settings["innowhite"]["server_address"]
|
18
18
|
@api_address = settings["innowhite"]["api_address"]
|
19
19
|
@private_key = settings["innowhite"]["private_key"]
|
@@ -21,20 +21,6 @@ class Innowhite
|
|
21
21
|
@org_name = @parent_org
|
22
22
|
end
|
23
23
|
|
24
|
-
# def create_room(user,org_name1=nil,parent_org = nil,desc = nil,tags=nil)
|
25
|
-
# parent_org ||= @parent_org
|
26
|
-
# org_name1 ||= @org_name
|
27
|
-
#
|
28
|
-
# room_id = set_room_id
|
29
|
-
# address = join_room_helper(@server_address,@org_name, room_id, user,true)
|
30
|
-
# res = create_room_info(room_id,user,tags,desc, parent_org,address)
|
31
|
-
# res = res.include?("Missing")
|
32
|
-
# if res == true
|
33
|
-
# return "Failed to fetch, maybe you have entered wrong username / organization name .."
|
34
|
-
# else
|
35
|
-
# return {:address => address, :room_id => room_id}
|
36
|
-
# end
|
37
|
-
# end
|
38
24
|
def create_room(params = {})
|
39
25
|
params[:parentOrg] ||= @parent_org
|
40
26
|
params[:orgName] ||= @org_name
|
@@ -101,43 +87,7 @@ class Innowhite
|
|
101
87
|
end
|
102
88
|
|
103
89
|
end
|
104
|
-
|
105
|
-
# def get_sessions(status)
|
106
|
-
# ids = []
|
107
|
-
# descs = []
|
108
|
-
# res = []
|
109
|
-
# url = URI.escape("http://innowhite.com/get_active_session?orgName=#{@org_name}&status=#{status}")
|
110
|
-
#
|
111
|
-
# x = Nokogiri::XML(open(url))
|
112
|
-
# x.xpath('//web-session/session-id').each{|m| ids << m.text}
|
113
|
-
# x.xpath('//web-session/session-desc').each{|m| descs << m.text}
|
114
|
-
#
|
115
|
-
# ids.each_with_index do |id, index|
|
116
|
-
# res << {:id => id, :description => descs[index]}
|
117
|
-
# end
|
118
|
-
# return res
|
119
|
-
# end
|
120
|
-
|
121
|
-
# def get_sessions(parent_org = nil, org_name1 = nil,user = nil,tag = nil)
|
122
|
-
# parent_org ||= @parent_org
|
123
|
-
# org_name1 = parent_org if org_name1.nil?
|
124
|
-
# ids = []
|
125
|
-
# descs = []
|
126
|
-
# res = []
|
127
|
-
# tmp = "parentOrg=#{parent_org}&orgName=#{org_name1}&user=#{user}&tags=#{tag}"
|
128
|
-
# checksum = generating_checksum(URI.escape(tmp))
|
129
|
-
# pp "#{@api_address}list_sessions?#{tmp}&cheksum=#{checksum}"
|
130
|
-
# url = URI.escape("#{@api_address}list_sessions?#{tmp}&cheksum=#{checksum}")
|
131
|
-
#
|
132
|
-
# x = Nokogiri::XML(open(url))
|
133
|
-
# x.xpath('//web-session/session-id').each{|m| ids << m.text}
|
134
|
-
# x.xpath('//web-session/session-desc').each{|m| descs << m.text}
|
135
|
-
#
|
136
|
-
# ids.each_with_index do |id, index|
|
137
|
-
# res << {:id => id, :description => descs[index]}
|
138
|
-
# end
|
139
|
-
# return res
|
140
|
-
# end
|
90
|
+
|
141
91
|
def past_sessions(params = {})
|
142
92
|
begin
|
143
93
|
params[:parentOrg] ||= @parent_org
|
@@ -166,6 +116,7 @@ class Innowhite
|
|
166
116
|
return "Error fetching sessions check the organization and private key .."
|
167
117
|
end
|
168
118
|
end
|
119
|
+
|
169
120
|
def get_sessions(params = {})
|
170
121
|
begin
|
171
122
|
params[:parentOrg] ||= @parent_org
|
@@ -183,8 +134,7 @@ class Innowhite
|
|
183
134
|
res = []
|
184
135
|
checksum_tmp = "parentOrg=#{parent_org}&orgName=#{org_name1}"
|
185
136
|
tmp = "parentOrg=#{parent_org}&orgName=#{org_name1}&user=#{user}&tags=#{tags}"
|
186
|
-
checksum = generating_checksum(URI.escape(checksum_tmp))
|
187
|
-
#pp "#{@api_address}list_sessions?#{tmp}&cheksum=#{checksum}"
|
137
|
+
checksum = generating_checksum(URI.escape(checksum_tmp))
|
188
138
|
url = URI.escape("#{@api_address}list_sessions?#{tmp}&checksum=#{checksum}")
|
189
139
|
|
190
140
|
x = Nokogiri::XML(open(url))
|
@@ -200,8 +150,109 @@ class Innowhite
|
|
200
150
|
end
|
201
151
|
end
|
202
152
|
|
153
|
+
# A call to schedule a session
|
154
|
+
#
|
155
|
+
#
|
156
|
+
|
157
|
+
def schedule_meeting(params = {})
|
158
|
+
@org_name ||= params[:orgName]
|
159
|
+
tags = params[:tags]
|
160
|
+
start_time = params[:startTime]
|
161
|
+
time_zone = params[:timeZone]
|
162
|
+
end_time = params[:endTime]
|
163
|
+
user = params[:user]
|
164
|
+
desc = params[:description]
|
165
|
+
room_id = set_room_id
|
166
|
+
|
167
|
+
address = join_room_helper(@server_address,@org_name, room_id, user,true)
|
168
|
+
create_schedule(room_id, user, tags,desc, @parent_org, address,start_time,end_time, time_zone)
|
169
|
+
end
|
170
|
+
|
171
|
+
def create_schedule(room_id,user,tags,desc, parent_org,address, start_time, end_time, time_zone)
|
172
|
+
checksum_tmp = "parentOrg=#{parent_org}&orgName=#{parent_org}"
|
173
|
+
checksum = generating_checksum(URI.escape(checksum_tmp))
|
174
|
+
address = join_room_helper(@server_address,@org_name, room_id, user,true)
|
175
|
+
res = RestClient.post("#{@api_address}create_schedule_meeting",
|
176
|
+
{:roomId => room_id, :user => user, :tags => tags,:desc => desc,:startTime => start_time,
|
177
|
+
:endTime => end_time, :timeZone => time_zone,
|
178
|
+
:parentOrg => parent_org, :address => address, :orgName => parent_org,
|
179
|
+
:checksum => checksum
|
180
|
+
}
|
181
|
+
)
|
182
|
+
return res
|
183
|
+
end
|
184
|
+
|
185
|
+
def get_scheduled_list(params={})
|
186
|
+
@org_name ||= params[:orgName]
|
187
|
+
checksum = main_cheksum(@parent_org, @org_name)
|
188
|
+
tags = params[:tags] if params[:tags]
|
189
|
+
|
190
|
+
par = url_generator(@parent_org, @org_name)
|
191
|
+
url = URI.escape("#{@api_address}get_scheduled_sessions?#{par}&checksum=#{checksum}&tags=#{tags}")
|
192
|
+
x = Nokogiri::XML(open(url))
|
193
|
+
ids = [], start_at = [], end_at = [], zone = []
|
194
|
+
desc = []
|
195
|
+
x.xpath('//web-session/session-id').each{|m| ids << m.text}
|
196
|
+
x.xpath('//web-session/session-desc').each{|m| desc << m.text}
|
197
|
+
x.xpath('//web-session/start-at').each{|m| start_at << m.text.to_time.to_i rescue 0}
|
198
|
+
x.xpath('//web-session/end-at').each{|m| end_at << m.text.to_time.to_i rescue 0}
|
199
|
+
x.xpath('//web-session/start-at').each{|m| zone << m.text.to_datetime.utc_offset rescue 0}
|
200
|
+
|
201
|
+
res = []
|
202
|
+
ids.each_with_index do |id, index|
|
203
|
+
res << {
|
204
|
+
:tags => tags, :orgName => @org_name,
|
205
|
+
:room_id => id,
|
206
|
+
:startTime => start_at[index], :timeZone => zone[index],
|
207
|
+
:endTime => end_at[index],
|
208
|
+
:moderatorName => "",
|
209
|
+
:room_desc => desc[index]
|
210
|
+
}
|
211
|
+
end
|
212
|
+
return res
|
213
|
+
end
|
214
|
+
|
215
|
+
|
216
|
+
def cancel_meeting(room_id)
|
217
|
+
checksum = main_cheksum(@parent_org, @org_name)
|
218
|
+
par = url_generator(@parent_org, @org_name)
|
219
|
+
url = URI.escape("#{@api_address}cancel_meeting?roomId=#{room_id}&#{par}&checksum=#{checksum}")
|
220
|
+
|
221
|
+
x = Nokogiri::XML(open(url))
|
222
|
+
return x.xpath("//success").map(&:text)
|
223
|
+
end
|
224
|
+
|
225
|
+
def update_schedule(params = {})
|
226
|
+
checksum = main_cheksum(@parent_org, @org_name)
|
227
|
+
room_id = params[:room_id]
|
228
|
+
start_time = params[:startTime] if params[:startTime]
|
229
|
+
time_zone = params[:timeZone] if params[:timeZone]
|
230
|
+
end_time = params[:endTime] if params[:endTime]
|
231
|
+
desc = params[:description] if params[:description]
|
232
|
+
tags = params[:tags]
|
233
|
+
|
234
|
+
res = RestClient.put("#{@api_address}update_schedule",
|
235
|
+
{:roomId => room_id, :tags => tags,:description => desc,
|
236
|
+
:parentOrg => @parent_org, :orgName => @org_name,
|
237
|
+
:checksum => checksum
|
238
|
+
}
|
239
|
+
)
|
240
|
+
end
|
241
|
+
|
242
|
+
|
243
|
+
|
203
244
|
private
|
204
245
|
|
246
|
+
def url_generator(parent_org,org_name)
|
247
|
+
url = "parentOrg=#{parent_org}&orgName=#{org_name}"
|
248
|
+
return url
|
249
|
+
end
|
250
|
+
def main_cheksum(parent_org, org_name)
|
251
|
+
checksum_tmp = url_generator(parent_org, org_name)
|
252
|
+
checksum = generating_checksum(URI.escape(checksum_tmp))
|
253
|
+
return checksum
|
254
|
+
end
|
255
|
+
|
205
256
|
def join_room_helper(server_addr, org_name, room_id,user, is_teacher)
|
206
257
|
action = "#{server_addr}JoinRoom?"
|
207
258
|
address = "parentOrg=#{@parent_org}&orgName=#{org_name}&roomId=#{room_id}&user=#{user}&roomLeader=#{is_teacher}"
|