innowhite 0.1.3 → 0.1.4

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.
Files changed (3) hide show
  1. data/innowhite.gemspec +1 -1
  2. data/lib/innowhite.rb +136 -11
  3. metadata +8 -7
data/innowhite.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{innowhite}
5
- s.version = "0.1.3"
5
+ s.version = "0.1.4"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = [%q{bainur}]
data/lib/innowhite.rb CHANGED
@@ -1,31 +1,70 @@
1
1
  require 'open-uri'
2
2
  require 'nokogiri'
3
+ require 'rest-client'
4
+ require 'pp'
3
5
  class Innowhite
4
6
 
5
7
  attr_accessor :mod_name, :org_name, :sub, :server_address, :private_key
6
8
 
7
- def initialize(mod_name, org_name = nil)
9
+ def initialize
8
10
  load_settings
9
- @mod_name = mod_name.gsub(/ /,'')
10
- @org_name = org_name.nil? ? @parent_org : org_name
11
+ #@mod_name = mod_name.gsub(/ /,'')
12
+ #@org_name = org_name.nil? ? @parent_org : org_name
11
13
  end
12
14
 
13
15
  def load_settings
14
16
  settings = YAML.load_file('config/innowhite.yml')
15
17
  @server_address = settings["innowhite"]["server_address"]
18
+ @api_address = settings["innowhite"]["api_address"]
16
19
  @private_key = settings["innowhite"]["private_key"]
17
20
  @parent_org = settings["innowhite"]["organization"]
21
+ @org_name = @parent_org
18
22
  end
19
23
 
20
- def create_room
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
+ def create_room(params = {})
39
+ params[:parentOrg] ||= @parent_org
40
+ params[:orgName] ||= @org_name
41
+ user = params[:user]
42
+ tags = params[:tags]
43
+ desc = params[:desc]
44
+ parent_org = params[:parentOrg]
21
45
  room_id = set_room_id
22
- address = join_room_helper(@server_address,@org_name, room_id, @mod_name,true)
23
- return {:address => address, :room_id => room_id}
46
+ address = join_room_helper(@server_address,@org_name, room_id, user,true)
47
+ res = create_room_info(room_id,user,tags,desc, parent_org,address)
48
+ res = res.include?("Missing")
49
+ if res == true
50
+ return "Failed to fetch, maybe you have entered wrong username / organization name .."
51
+ else
52
+ return {:address => address, :room_id => room_id}
53
+ end
54
+ end
55
+
56
+ def create_room_info(room_id,user,tags,desc, parent_org,address)
57
+ res = RestClient.post("#{@api_address}create_room_info",
58
+ {:roomId => room_id, :user => user, :tags => tags,:desc => desc,
59
+ :parentOrg => parent_org, :address => address, :orgName => parent_org}
60
+ )
61
+ return res
24
62
  end
25
63
 
26
64
  def set_room_id
27
65
  room_id = ""
28
- doc = Nokogiri::XML(open("#{@server_address}CreateRoom?parentOrg=#{@parent_org}&orgName=#{@org_name}&user=#{@mod_name}&checksum=#{generate_checksum(@parent_org,@org_name, @mod_name)}"))
66
+ url = "#{@server_address}CreateRoom?parentOrg=#{@parent_org}&orgName=#{@org_name}&user=#{@mod_name}&checksum=#{generate_checksum(@parent_org,@org_name, @mod_name)}"
67
+ doc = Nokogiri::XML(open(url))
29
68
  status = doc.xpath('//returnStatus').text.gsub("\n","") rescue ""
30
69
  if status.include?('SUCCESS')
31
70
  room_id = doc.xpath('//roomId').text.gsub("\n","").to_i
@@ -42,15 +81,98 @@ class Innowhite
42
81
  end
43
82
 
44
83
  def join_meeting(room_id, user)
84
+ url = "#{@api_address}exist_session?roomId=#{room_id}"
85
+ doc = Nokogiri::XML(open(url))
86
+ missing = false
87
+ if doc.text.blank?
88
+ missing = true
89
+ end
45
90
  address = join_room_helper(@server_address,@org_name, room_id, user, false)
46
- return address
91
+ if missing
92
+ return "Room is not exist / Expired"
93
+ else
94
+ return address
95
+ end
96
+
47
97
  end
98
+ #
99
+ # def get_sessions(status)
100
+ # ids = []
101
+ # descs = []
102
+ # res = []
103
+ # url = URI.escape("http://innowhite.com/get_active_session?orgName=#{@org_name}&status=#{status}")
104
+ #
105
+ # x = Nokogiri::XML(open(url))
106
+ # x.xpath('//web-session/session-id').each{|m| ids << m.text}
107
+ # x.xpath('//web-session/session-desc').each{|m| descs << m.text}
108
+ #
109
+ # ids.each_with_index do |id, index|
110
+ # res << {:id => id, :description => descs[index]}
111
+ # end
112
+ # return res
113
+ # end
114
+
115
+ # def get_sessions(parent_org = nil, org_name1 = nil,user = nil,tag = nil)
116
+ # parent_org ||= @parent_org
117
+ # org_name1 = parent_org if org_name1.nil?
118
+ # ids = []
119
+ # descs = []
120
+ # res = []
121
+ # tmp = "parentOrg=#{parent_org}&orgName=#{org_name1}&user=#{user}&tags=#{tag}"
122
+ # checksum = generating_checksum(URI.escape(tmp))
123
+ # pp "#{@api_address}list_sessions?#{tmp}&cheksum=#{checksum}"
124
+ # url = URI.escape("#{@api_address}list_sessions?#{tmp}&cheksum=#{checksum}")
125
+ #
126
+ # x = Nokogiri::XML(open(url))
127
+ # x.xpath('//web-session/session-id').each{|m| ids << m.text}
128
+ # x.xpath('//web-session/session-desc').each{|m| descs << m.text}
129
+ #
130
+ # ids.each_with_index do |id, index|
131
+ # res << {:id => id, :description => descs[index]}
132
+ # end
133
+ # return res
134
+ # end
135
+ def past_sessions(params = {})
136
+ begin
137
+ params[:parentOrg] ||= @parent_org
138
+ org_name1 = params[:parentOrg] if params[:orgName].nil?
139
+ ids = []
140
+ parent_org = params[:parentOrg]
141
+ user = params[:user]
142
+ tags = params[:tags]
143
+ descs = []
144
+ res = []
145
+ tmp = "parentOrg=#{parent_org}&orgName=#{org_name1}&user=#{user}&tags=#{tags}"
146
+ checksum = generating_checksum(URI.escape(tmp))
147
+ pp "#{@api_address}list_sessions?#{tmp}&cheksum=#{checksum}"
148
+ url = URI.escape("#{@api_address}past_sessions?#{tmp}&cheksum=#{checksum}")
149
+
150
+ x = Nokogiri::XML(open(url))
151
+ x.xpath('//web-session/session-id').each{|m| ids << m.text}
152
+ x.xpath('//web-session/session-desc').each{|m| descs << m.text}
48
153
 
49
- def get_sessions(status)
154
+ ids.each_with_index do |id, index|
155
+ res << {:id => id, :description => descs[index]}
156
+ end
157
+ return res
158
+ rescue => e
159
+ return "Error fetching sessions #{e.inspect}"
160
+ end
161
+ end
162
+ def get_sessions(params = {})
163
+ begin
164
+ params[:parentOrg] ||= @parent_org
165
+ org_name1 = params[:parentOrg] if params[:orgName].nil?
50
166
  ids = []
167
+ parent_org = params[:parentOrg]
168
+ user = params[:user]
169
+ tags = params[:tags]
51
170
  descs = []
52
171
  res = []
53
- url = URI.escape("http://innowhite.com/get_active_session?orgName=#{@org_name}&status=#{status}")
172
+ tmp = "parentOrg=#{parent_org}&orgName=#{org_name1}&user=#{user}&tags=#{tags}"
173
+ checksum = generating_checksum(URI.escape(tmp))
174
+ pp "#{@api_address}list_sessions?#{tmp}&cheksum=#{checksum}"
175
+ url = URI.escape("#{@api_address}list_sessions?#{tmp}&cheksum=#{checksum}")
54
176
 
55
177
  x = Nokogiri::XML(open(url))
56
178
  x.xpath('//web-session/session-id').each{|m| ids << m.text}
@@ -60,6 +182,9 @@ class Innowhite
60
182
  res << {:id => id, :description => descs[index]}
61
183
  end
62
184
  return res
185
+ rescue => e
186
+ return "Error fetching sessions #{e.inspect}"
187
+ end
63
188
  end
64
189
 
65
190
  private
@@ -83,4 +208,4 @@ class Innowhite
83
208
  "parentOrg=#{parent_org}&orgName=#{org_name}&user=#{user_name}#{@private_key}"
84
209
  end
85
210
 
86
- end
211
+ end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: innowhite
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ hash: 19
5
+ prerelease:
5
6
  segments:
6
7
  - 0
7
8
  - 1
8
- - 3
9
- version: 0.1.3
9
+ - 4
10
+ version: 0.1.4
10
11
  platform: ruby
11
12
  authors:
12
13
  - bainur
@@ -14,8 +15,7 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2011-08-11 00:00:00 -04:00
18
- default_executable:
18
+ date: 2011-08-11 00:00:00 Z
19
19
  dependencies: []
20
20
 
21
21
  description: Innowhite Api
@@ -33,7 +33,6 @@ files:
33
33
  - lib/innowhite.rb
34
34
  - Manifest
35
35
  - innowhite.gemspec
36
- has_rdoc: true
37
36
  homepage: http://github.com/bainur/innowhite
38
37
  licenses: []
39
38
 
@@ -52,6 +51,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
52
51
  requirements:
53
52
  - - ">="
54
53
  - !ruby/object:Gem::Version
54
+ hash: 3
55
55
  segments:
56
56
  - 0
57
57
  version: "0"
@@ -60,6 +60,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
60
60
  requirements:
61
61
  - - ">="
62
62
  - !ruby/object:Gem::Version
63
+ hash: 11
63
64
  segments:
64
65
  - 1
65
66
  - 2
@@ -67,7 +68,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
67
68
  requirements: []
68
69
 
69
70
  rubyforge_project: innowhite
70
- rubygems_version: 1.3.7
71
+ rubygems_version: 1.8.6
71
72
  signing_key:
72
73
  specification_version: 3
73
74
  summary: Innowhite Api