granicus-platform-api 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,4 @@
1
+ require 'granicus-platform-api/entities'
1
2
  require 'granicus-platform-api/client'
2
3
  require 'granicus-platform-api/version'
3
4
 
@@ -4,7 +4,44 @@ require 'multi_xml'
4
4
 
5
5
  module GranicusPlatformAPI
6
6
  class Client
7
+
8
+ # mappings between soap types and our complex types
9
+ # this area should be rewritten to auto-generate data sets properly
10
+ # and refactored to separate standard xsd types from custom types in class
11
+ # map
12
+ def self.typegenerators
13
+ @@typegenerators
14
+ end
15
+
16
+ def self.typegenerators=(obj)
17
+ @@typegenerators = obj
18
+ end
19
+
20
+ self.typegenerators = {}
21
+
22
+ self.typegenerators["CameraData"] = lambda { CameraData.new }
23
+ self.typegenerators["EventData"] = lambda { EventData.new }
24
+ self.typegenerators["Attendee"] = lambda { Attendee.new }
25
+
26
+ # classmap for generating proper attributes! hash within savon calls
27
+ def self.classmap
28
+ @@classmap
29
+ end
7
30
 
31
+ def self.classmap=(obj)
32
+ @@classmap = obj
33
+ end
34
+
35
+ self.classmap = {}
36
+ self.classmap['Fixnum'] = "xsd:int"
37
+ self.classmap['String'] = "xsd:string"
38
+ self.classmap['TrueClass'] = 'xsd:boolean'
39
+ self.classmap['FalseClass'] = 'xsd:boolean'
40
+ self.classmap['Time'] = 'xsd:dateTime'
41
+ self.classmap['CameraData'] = 'granicus:CameraData'
42
+ self.classmap['EventData'] = 'granicus:EventData'
43
+ self.classmap['Attendee'] = 'granicus:Attendee'
44
+
8
45
  # create a connected client
9
46
  def initialize(granicus_site,username,password,options={})
10
47
  # set things up
@@ -18,213 +55,175 @@ module GranicusPlatformAPI
18
55
  @client = Savon::Client.new do |wsdl, http|
19
56
  wsdl.document = File.expand_path("../granicus-platform-api.xml", __FILE__)
20
57
  wsdl.endpoint = "http://#{granicus_site}/SDK/User/index.php"
21
- http.proxy = "http://localhost:8888"
22
-
58
+ http.proxy = options[:proxy]
23
59
  end
24
60
 
25
61
  # call login
26
- @client.request :wsdl, :login do
27
- soap.body = { :username => username, :password => password }
28
- end
29
-
62
+ call_soap_method(:login,'//ns4:LoginResponse/return',{:username => username, :password => password})
30
63
  end
31
64
 
32
65
  # return the current logged on user name
33
66
  def get_current_user_logon
34
- response = @client.request :wsdl, :get_current_user_logon
35
- doc = Nokogiri::XML(response.to_xml) do |config|
36
- config.noblanks
37
- end
38
- typecast_value_node doc.xpath('//ns4:GetCurrentUserLogonResponse/Logon', doc.root.namespaces)[0]
67
+ call_soap_method(:get_current_user_logon,'//ns4:GetCurrentUserLogonResponse/Logon')
39
68
  end
40
69
 
41
70
  # logout
42
71
  def logout
43
- response = @client.request :wsdl, :logout
44
- doc = Nokogiri::XML(response.to_xml) do |config|
45
- config.noblanks
46
- end
47
- typecast_value_node doc.xpath('//ns4:LogoutResponse', doc.root.namespaces)[0]
72
+ call_soap_method(:logout,'//ns4:LogoutResponse')
48
73
  end
49
74
 
50
75
  # return all of the cameras
51
76
  def get_cameras
52
- response = @client.request :wsdl, :get_cameras
53
-
54
- doc = Nokogiri::XML(response.to_xml) do |config|
55
- config.noblanks
56
- end
57
- typecast_value_node doc.xpath('//ns5:GetCamerasResponse/cameras', doc.root.namespaces)[0]
77
+ call_soap_method(:get_cameras,'//ns5:GetCamerasResponse/cameras')
58
78
  end
59
79
 
60
80
  # return the requested event
61
81
  def get_camera(camera_id)
62
- response = @client.request :wsdl, :get_camera do
63
- soap.body = { :camera_id => camera_id, :attributes! => {:camera_id => {"xsi:type" => "xsd:int"}} }
64
- end
65
-
66
- doc = Nokogiri::XML(response.to_xml) do |config|
67
- config.noblanks
68
- end
69
- typecast_value_node doc.xpath('//ns5:GetCameraResponse/camera', doc.root.namespaces)[0]
82
+ call_soap_method(:get_camera,'//ns5:GetCameraResponse/camera',{ :camera_id => camera_id })
70
83
  end
71
84
 
72
85
  # return all of the events
73
86
  def get_events
74
- response = @client.request :wsdl, :get_events
75
-
76
- doc = Nokogiri::XML(response.to_xml) do |config|
77
- config.noblanks
78
- end
79
- typecast_value_node doc.xpath('//ns5:GetEventsResponse/events', doc.root.namespaces)[0]
87
+ call_soap_method(:get_events,'//ns5:GetEventsResponse/events')
80
88
  end
81
89
 
82
90
  # return all of the events with matching foreign id
83
91
  def get_events_by_foreign_id(foreign_id)
84
- response = @client.request :wsdl, :get_events_by_foreign_id do
85
- soap.body = { :foreign_id => foreign_id, :attributes! => {:foreign_id => {"xsi:type" => "xsd:int"}} }
86
- end
87
-
88
- doc = Nokogiri::XML(response.to_xml) do |config|
89
- config.noblanks
90
- end
91
- typecast_value_node doc.xpath('//ns5:GetEventsByForeignIDResponse/events', doc.root.namespaces)[0]
92
+ call_soap_method(:get_events_by_foreign_id,'//ns5:GetEventsByForeignIDResponse/events',{ :foreign_id => foreign_id })
92
93
  end
93
94
 
94
95
  # return the requested event
95
96
  def get_event(event_id)
96
- response = @client.request :wsdl, :get_event do
97
- soap.body = { :event_id => event_id, :attributes! => {:event_id => {"xsi:type" => "xsd:int"}} }
98
- end
99
-
100
- doc = Nokogiri::XML(response.to_xml) do |config|
101
- config.noblanks
102
- end
103
- typecast_value_node doc.xpath('//ns5:GetEventResponse/event', doc.root.namespaces)[0]
97
+ call_soap_method(:get_event,'//ns5:GetEventResponse/event',{ :event_id => event_id })
98
+ end
99
+
100
+ # update an event
101
+ def update_event(event)
102
+ call_soap_method(:update_event,'//ns4:UpdateEventResponse',{ :event => event })
104
103
  end
105
104
 
106
105
  # return all of the event meta data
107
106
  def get_event_meta_data(event_id)
108
- response = @client.request :wsdl, :get_event_meta_data do
109
- soap.body = { :event_id => event_id, :attributes! => {:event_id => {"xsi:type" => "xsd:int"}} }
110
- end
111
-
112
- doc = Nokogiri::XML(response.to_xml) do |config|
113
- config.noblanks
114
- end
115
- typecast_value_node doc.xpath('//ns5:GetEventMetaDataResponse/metadata', doc.root.namespaces)[0]
107
+ call_soap_method(:get_event_meta_data,'//ns5:GetEventMetaDataResponse/metadata',{ :event_id => event_id })
116
108
  end
117
109
 
118
110
  # set the event agenda url
119
111
  def set_event_agenda_url(event_id,url)
120
- response = @client.request :wsdl, :set_event_agenda_url do
121
- soap.body = { :event_id => event_id,
122
- :url => url,
123
- :attributes! => {:event_id => {"xsi:type" => "xsd:int"}, :url => {"xsi:type" => "xsd:string"}} }
124
- end
125
- doc = Nokogiri::XML(response.to_xml) do |config|
126
- config.noblanks
127
- end
128
- typecast_value_node doc.xpath('//ns4:SetEventAgendaURLResponse', doc.root.namespaces)[0]
112
+ call_soap_method(:set_event_agenda_url,'//ns4:SetEventAgendaURLResponse',{ :event_id => event_id, :url => url })
129
113
  end
130
114
 
131
115
  # return all of the clip meta data
132
116
  def get_clip_meta_data(clip_id)
133
- response = @client.request :wsdl, :get_clip_meta_data do
134
- soap.body = { :clip_id => clip_id, :attributes! => {:clip_id => {"xsi:type" => "xsd:int"}} }
135
- end
136
-
137
- doc = Nokogiri::XML(response.to_xml) do |config|
138
- config.noblanks
139
- end
140
- typecast_value_node doc.xpath('//ns5:GetClipMetaDataResponse/metadata', doc.root.namespaces)[0]
117
+ call_soap_method(:get_clip_meta_data,'//ns5:GetClipMetaDataResponse/metadata',{ :clip_id => clip_id })
141
118
  end
142
119
 
143
120
  # return all of the folders
144
121
  def get_folders
145
- response = @client.request :wsdl, :get_folders
146
-
147
- doc = Nokogiri::XML(response.to_xml) do |config|
148
- config.noblanks
149
- end
150
- typecast_value_node doc.xpath('//ns5:GetFoldersResponse/folders', doc.root.namespaces)[0]
122
+ call_soap_method(:get_folders,'//ns5:GetFoldersResponse/folders')
151
123
  end
152
124
 
153
125
  # return all of the clips
154
126
  def get_clips(folder_id)
155
- response = @client.request :wsdl, :get_clips do
156
- soap.body = { :folder_id => folder_id, :attributes! => {:folder_id => {"xsi:type" => "xsd:int"}} }
157
- end
158
-
159
- doc = Nokogiri::XML(response.to_xml) do |config|
160
- config.noblanks
161
- end
162
- typecast_value_node doc.xpath('//ns5:GetClipsResponse/clips', doc.root.namespaces)[0]
127
+ call_soap_method(:get_clips,'//ns5:GetClipsResponse/clips',{ :folder_id => folder_id })
163
128
  end
164
129
 
165
130
  # return all of the clips with matching foreign id
166
131
  def get_clips_by_foreign_id(foreign_id)
167
- response = @client.request :wsdl, :get_clips_by_foreign_id do
168
- soap.body = { :foreign_id => foreign_id, :attributes! => {:foreign_id => {"xsi:type" => "xsd:int"}} }
169
- end
170
-
171
- doc = Nokogiri::XML(response.to_xml) do |config|
172
- config.noblanks
173
- end
174
- typecast_value_node doc.xpath('//ns5:GetClipsByForeignIDResponse/clips', doc.root.namespaces)[0]
132
+ call_soap_method(:get_clips_by_foreign_id,'//ns5:GetClipsByForeignIDResponse/clips',{ :foreign_id => foreign_id })
175
133
  end
176
134
 
177
135
  # return the requested clip
178
136
  def get_clip(clip_id)
179
- response = @client.request :wsdl, :get_clip do
180
- soap.body = { :clip_id => clip_id, :attributes! => {:clip_id => {"xsi:type" => "xsd:int"}} }
181
- end
182
-
183
- doc = Nokogiri::XML(response.to_xml) do |config|
184
- config.noblanks
185
- end
186
- typecast_value_node doc.xpath('//ns5:GetClipResponse/clip', doc.root.namespaces)[0]
137
+ call_soap_method(:get_clip,'//ns5:GetClipResponse/clip',{ :clip_id => clip_id })
187
138
  end
188
139
 
189
140
  # return the requested clip
190
141
  def get_clip_by_uid(clip_uid)
191
- response = @client.request :wsdl, :get_clip_by_uid do
192
- soap.body = { :clip_uid => clip_uid, :attributes! => {:clip_uid => {"xsi:type" => "xsd:string"}} }
193
- end
194
-
195
- doc = Nokogiri::XML(response.to_xml) do |config|
196
- config.noblanks
197
- end
198
- typecast_value_node doc.xpath('//ns5:GetClipByUIDResponse/clip', doc.root.namespaces)[0]
142
+ call_soap_method(:get_clip_by_uid,'//ns5:GetClipByUIDResponse/clip',{ :clip_uid => clip_uid })
199
143
  end
200
144
 
201
145
  # get servers
202
146
  def get_servers
203
- response = @client.request :wsdl, :get_servers
204
-
205
- doc = Nokogiri::XML(response.to_xml) do |config|
206
- config.noblanks
207
- end
208
- typecast_value_node doc.xpath('//ns5:GetServersResponse/servers', doc.root.namespaces)[0]
147
+ call_soap_method(:get_servers,'//ns5:GetServersResponse/servers')
209
148
  end
210
149
 
211
150
  # return the requested server
212
151
  def get_server(server_id)
213
- response = @client.request :wsdl, :get_server do
214
- soap.body = { :server_id => server_id, :attributes! => {:server_id => {"xsi:type" => "xsd:int"}} }
152
+ call_soap_method(:get_server,'//ns5:GetServerResponse/server',{ :server_id => server_id })
153
+ end
154
+
155
+ private
156
+
157
+ def call_soap_method(method,returnfilter,args={},debug=false)
158
+ response = @client.request :wsdl, method do
159
+ soap.namespaces['xmlns:granicus'] = "http://granicus.com/xsd"
160
+ soap.namespaces['xmlns:SOAP-ENC'] = "http://schemas.xmlsoap.org/soap/encoding/"
161
+ soap.body = prepare_request args
162
+ if debug then
163
+ puts soap.body
164
+ end
215
165
  end
216
166
 
217
167
  doc = Nokogiri::XML(response.to_xml) do |config|
218
168
  config.noblanks
219
169
  end
220
- typecast_value_node doc.xpath('//ns5:GetServerResponse/server', doc.root.namespaces)[0]
170
+ response = handle_response(doc.xpath(returnfilter, doc.root.namespaces)[0])
171
+ if debug
172
+ puts response
173
+ end
174
+ response
175
+ end
176
+
177
+ def prepare_request(hash={})
178
+ attributes = {}
179
+ hash.each do |key,value|
180
+ case value.class.to_s
181
+ when 'Hashie::Mash', /GranicusPlatformAPI::/, 'Hash'
182
+ hash[key] = prepare_request value
183
+ when 'Array'
184
+ hash[key] = prepare_array value
185
+ end
186
+ attributes[key] = attribute_of value
187
+ end
188
+ hash.merge!({ :attributes! => attributes })
189
+ end
190
+
191
+ def prepare_array(array)
192
+ array.each_index do |index|
193
+ case array[index].class.to_s
194
+ when 'Hashie::Mash', /GranicusPlatformAPI::/, 'Hash'
195
+ array[index] = prepare_request array[index]
196
+ end
197
+ end
198
+ { "item" => array, :attributes! => { "item" => attribute_of(array[0]) } }
199
+ end
200
+
201
+ def attribute_of(value)
202
+ case value.class.to_s
203
+ when 'Hashie::Mash','Hash'
204
+ nil
205
+ when 'Array'
206
+ xsd_type = self.class.classmap[value[0].class.to_s.split('::').last]
207
+ if xsd_type.nil?
208
+ puts "Couldn't get xsd:type for #{value.class}"
209
+ {"xsi:type" => 'SOAP-ENC:Array'}
210
+ else
211
+ {"xsi:type" => 'SOAP-ENC:Array', "SOAP-ENC:arrayType" => "#{xsd_type}[#{value.count}]"}
212
+ end
213
+ else
214
+ xsd_type = self.class.classmap[value.class.to_s.split('::').last]
215
+ if xsd_type.nil?
216
+ puts "Couldn't get xsd:type for #{value.class}"
217
+ nil
218
+ else
219
+ {"xsi:type" => xsd_type }
220
+ end
221
+ end
221
222
  end
222
223
 
223
- private
224
-
225
- def typecast_value_node(node)
224
+ def handle_response(node)
226
225
  if node.is_a? Nokogiri::XML::NodeSet or node.is_a? Array then
227
- return node.map {|el| typecast_value_node el }
226
+ return node.map {|el| handle_response el }
228
227
  end
229
228
  return node.to_s unless node['type']
230
229
  typespace,type = node['type'].split(':')
@@ -239,16 +238,23 @@ module GranicusPlatformAPI
239
238
  end
240
239
  when 'SOAP-ENC'
241
240
  if type == 'Array' then
242
- node.children.map {|element| typecast_value_node element }
241
+ node.children.map {|element| handle_response element }
243
242
  else
244
243
  puts "Unknown SOAP-ENC:type: #{type}"
245
244
  node.to_s
246
245
  end
247
246
  else
248
247
  # we have a custom type, make it hashie since we don't want true static typing
249
- value = ::Hashie::Mash.new
248
+ proc = self.class.typegenerators[type]
249
+ value = {}
250
+ unless proc.nil?
251
+ value = proc.call
252
+ else
253
+ puts "Unknown custom type: #{type}"
254
+ value = ::Hashie::Mash.new
255
+ end
250
256
  node.children.each do |value_node|
251
- value[value_node.name.snakecase] = typecast_value_node value_node
257
+ value[value_node.name] = handle_response value_node
252
258
  end
253
259
  value
254
260
  end
@@ -263,14 +269,6 @@ module GranicusPlatformAPI
263
269
  @@typecasts = obj
264
270
  end
265
271
 
266
- def self.available_typecasts
267
- @@available_typecasts
268
- end
269
-
270
- def self.available_typecasts=(obj)
271
- @@available_typecasts = obj
272
- end
273
-
274
272
  self.typecasts = {}
275
273
  self.typecasts["int"] = lambda { |v| v.nil? ? nil : v.to_i }
276
274
  self.typecasts["boolean"] = lambda { |v| v.nil? ? nil : (v.strip != "false") }
@@ -284,8 +282,5 @@ module GranicusPlatformAPI
284
282
  self.typecasts["string"] = lambda { |v| v.to_s }
285
283
  self.typecasts["yaml"] = lambda { |v| v.nil? ? nil : YAML.load(v) }
286
284
  self.typecasts["base64Binary"] = lambda { |v| v.unpack('m').first }
287
-
288
- self.available_typecasts = self.typecasts.keys
289
-
290
285
  end
291
286
  end
@@ -0,0 +1,62 @@
1
+ require 'hashie'
2
+
3
+ module GranicusPlatformAPI
4
+ class Attendee < Hashie::Dash
5
+ property :ID
6
+ property :Name
7
+ property :OrderID
8
+ property :Voting
9
+ property :Chair
10
+ end
11
+
12
+ class CameraData < Hashie::Dash
13
+ property :ID
14
+ property :Type
15
+ property :Name
16
+ property :InternalIP
17
+ proprety :ExternalIP
18
+ property :BroadcastPort
19
+ property :ControlPort
20
+ property :Identifier
21
+ end
22
+
23
+ class EventData < Hashie::Dash
24
+ property :ID
25
+ property :UID
26
+ property :ForeignID
27
+ property :Name
28
+ property :CameraID
29
+ property :FolderID
30
+ property :AgendaType
31
+ property :AgendaFile
32
+ property :PlayerTemplateID
33
+ property :ArchiveStatus
34
+ property :Duration
35
+ property :Broadcast
36
+ property :Record
37
+ property :AutoStart
38
+ property :StartTime
39
+ property :LastModified
40
+ property :Attendees
41
+ property :MotionTypes
42
+ property :Street1
43
+ property :Street2
44
+ property :City
45
+ property :State
46
+ property :Zip
47
+ property :AgendaTitle
48
+ property :MeetingTime
49
+ property :AgendaPostedDate
50
+ end
51
+
52
+ class FolderData < Hashie::Dash
53
+ property :ID
54
+ property :Name
55
+ property :Description
56
+ property :Type
57
+ property :PlayerTemplateID
58
+ property :CreatedDate
59
+ property :Views
60
+ property :Servers
61
+ end
62
+ end
@@ -1,3 +1,3 @@
1
1
  module GranicusPlatformAPI
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -0,0 +1,53 @@
1
+ <Attendees xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="granicus:Attendee[4]">
2
+ <item xsi:type="granicus:Attendee">
3
+ <ID xsi:type="xsd:int">346</ID>
4
+ <Name xsi:type="xsd:string">my test</Name>
5
+ <Voting xsi:type="xsd:boolean">true</Voting>
6
+ <Chair xsi:type="xsd:boolean">false</Chair>
7
+ <OrderID xsi:type="xsd:int">1</OrderID>
8
+ </item>
9
+ <item xsi:type="granicus:Attendee">
10
+ <ID xsi:type="xsd:int">347</ID>
11
+ <Name xsi:type="xsd:string">Foo Fighters</Name>
12
+ <Voting xsi:type="xsd:boolean">true</Voting>
13
+ <Chair xsi:type="xsd:boolean">false</Chair>
14
+ <OrderID xsi:type="xsd:int">2</OrderID>
15
+ </item>
16
+ <item xsi:type="granicus:Attendee">
17
+ <ID xsi:type="xsd:int">348</ID>
18
+ <Name xsi:type="xsd:string">another test</Name>
19
+ <Voting xsi:type="xsd:boolean">true</Voting>
20
+ <Chair xsi:type="xsd:boolean">false</Chair>
21
+ <OrderID xsi:type="xsd:int">3</OrderID>
22
+ </item>
23
+ <item xsi:type="granicus:Attendee">
24
+ <Name xsi:type="xsd:string">Foo Fighters</Name>
25
+ <Voting xsi:type="xsd:boolean">true</Voting>
26
+ <Chair xsi:type="xsd:boolean">true</Chair>
27
+ </item>
28
+ </Attendees>
29
+
30
+
31
+ <Attendees xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="ns4:Attendee[3]" SOAP-ENC:offset="[0]">
32
+ <item xsi:type="ns4:Attendee">
33
+ <ID xsi:type="xsd:int">349</ID>
34
+ <Name xsi:type="xsd:string">my test</Name>
35
+ <Voting xsi:type="xsd:boolean">true</Voting>
36
+ <Chair xsi:type="xsd:boolean">false</Chair>
37
+ <OrderID xsi:type="xsd:int">1</OrderID>
38
+ </item>
39
+ <item xsi:type="ns4:Attendee">
40
+ <ID xsi:type="xsd:int">352</ID>
41
+ <Name xsi:type="xsd:string">Foo Fighters</Name>
42
+ <Voting xsi:type="xsd:boolean">true</Voting>
43
+ <Chair xsi:type="xsd:boolean">false</Chair>
44
+ <OrderID xsi:type="xsd:int">2</OrderID>
45
+ </item>
46
+ <item xsi:type="ns4:Attendee">
47
+ <ID xsi:type="xsd:int">351</ID>
48
+ <Name xsi:type="xsd:string">another test</Name>
49
+ <Voting xsi:type="xsd:boolean">true</Voting>
50
+ <Chair xsi:type="xsd:boolean">false</Chair>
51
+ <OrderID xsi:type="xsd:int">3</OrderID>
52
+ </item>
53
+ </Attendees>
@@ -6,6 +6,7 @@ GRANICUS_PASSWORD = ENV['PASSWORD']
6
6
  CAMERA_ID = 3
7
7
  FOLDER_ID = 7
8
8
  EVENT_ID = 30
9
+ UPDATE_EVENT_ID = 35
9
10
  EVENT_META_ID = 1775
10
11
  CLIP_ID = 246
11
12
  CLIP_UID = '00000000-0000-0000-0000-000000000000'
@@ -15,7 +16,7 @@ CLIP_FOREIGN_ID = 1
15
16
  EVENT_FOREIGN_ID = 1
16
17
  SERVER_ID = 2
17
18
 
18
- client = GranicusPlatformAPI::Client.new GRANICUS_SITE, GRANICUS_LOGIN, GRANICUS_PASSWORD
19
+ client = GranicusPlatformAPI::Client.new GRANICUS_SITE, GRANICUS_LOGIN, GRANICUS_PASSWORD, {:proxy => 'http://localhost:8888'}
19
20
 
20
21
  # The projects method
21
22
  describe GranicusPlatformAPI, "::Client.login" do
@@ -28,7 +29,7 @@ end
28
29
  describe GranicusPlatformAPI, "::Client.get_cameras" do
29
30
  it "should get my cameras" do
30
31
  cameras = client.get_cameras
31
- found = cameras.find {|c| c.id == CAMERA_ID }
32
+ found = cameras.find {|c| c.ID == CAMERA_ID }
32
33
  found.should_not == nil
33
34
  end
34
35
  end
@@ -36,14 +37,14 @@ end
36
37
  describe GranicusPlatformAPI, "::Client.get_camera" do
37
38
  it "should get the requested camera" do
38
39
  camera = client.get_camera CAMERA_ID
39
- camera.id.should == CAMERA_ID
40
+ camera.ID.should == CAMERA_ID
40
41
  end
41
42
  end
42
43
 
43
44
  describe GranicusPlatformAPI, "::Client.get_events" do
44
45
  it "should get my events" do
45
46
  events = client.get_events
46
- found = events.find {|e| e.id == EVENT_ID }
47
+ found = events.find {|e| e.ID == EVENT_ID }
47
48
  found.should_not == nil
48
49
  end
49
50
  end
@@ -52,7 +53,7 @@ describe GranicusPlatformAPI, "::Client.get_events_by_foreign_id" do
52
53
  it "should get all events with matching foreign id" do
53
54
  events = client.get_events_by_foreign_id EVENT_FOREIGN_ID
54
55
  events.each do |event|
55
- event.foreign_id.should == EVENT_FOREIGN_ID
56
+ event.ForeignID.should == EVENT_FOREIGN_ID
56
57
  end
57
58
  end
58
59
  end
@@ -60,14 +61,37 @@ end
60
61
  describe GranicusPlatformAPI, "::Client.get_event" do
61
62
  it "should get the requested event" do
62
63
  event = client.get_event EVENT_ID
63
- event.id.should == EVENT_ID
64
+ event.ID.should == EVENT_ID
65
+ end
66
+ end
67
+
68
+ describe GranicusPlatformAPI, "::Client.update_event" do
69
+ it "should update a simple property on requested event" do
70
+ event = client.get_event UPDATE_EVENT_ID
71
+ event.ID.should == UPDATE_EVENT_ID
72
+ event.Name = 'my test'
73
+ client.update_event event
74
+ end
75
+
76
+ it "should add a complex property on requested event" do
77
+ event = client.get_event UPDATE_EVENT_ID
78
+ event.ID.should == UPDATE_EVENT_ID
79
+ event.Attendees << { 'Name' => "Foo Fighters", 'Voting' => true, 'Chair' => true }
80
+ client.update_event event
81
+ end
82
+
83
+ it "should update a complex property on requested event" do
84
+ event = client.get_event UPDATE_EVENT_ID
85
+ event.ID.should == UPDATE_EVENT_ID
86
+ event.Attendees[0].Name = 'my test'
87
+ client.update_event event
64
88
  end
65
89
  end
66
90
 
67
91
  describe GranicusPlatformAPI, "::Client.get_event_by_uid" do
68
92
  it "should get the requested event" do
69
93
  event = client.get_event_by_uid EVENT_UID
70
- event.id.should == EVENT_UID
94
+ event.UID.should == EVENT_UID
71
95
  end
72
96
  end
73
97
 
@@ -80,7 +104,7 @@ end
80
104
  describe GranicusPlatformAPI, "::Client.get_folders" do
81
105
  it "should get my folders" do
82
106
  folders = client.get_folders
83
- folders[0].id.should == FOLDER_ID
107
+ folders[0].ID.should == FOLDER_ID
84
108
  end
85
109
  end
86
110
 
@@ -88,7 +112,7 @@ describe GranicusPlatformAPI, "::Client.get_clips" do
88
112
  it "should get clips from the given folder" do
89
113
  clips = client.get_clips FOLDER_ID
90
114
  clips.each do |clip|
91
- clip.folder_id.should == FOLDER_ID
115
+ clip.FolderID.should == FOLDER_ID
92
116
  end
93
117
  end
94
118
  end
@@ -97,7 +121,7 @@ describe GranicusPlatformAPI, "::Client.get_clips_by_foreign_id" do
97
121
  it "should get all clips with matching foreign id" do
98
122
  clips = client.get_clips_by_foreign_id CLIP_FOREIGN_ID
99
123
  clips.each do |clip|
100
- clip.foreign_id.should == CLIP_FOREIGN_ID
124
+ clip.ForeignID.should == CLIP_FOREIGN_ID
101
125
  end
102
126
  end
103
127
  end
@@ -105,21 +129,21 @@ end
105
129
  describe GranicusPlatformAPI, "::Client.get_clip" do
106
130
  it "should get the requested clip" do
107
131
  clip = client.get_clip CLIP_ID
108
- clip.id.should == CLIP_ID
132
+ clip.ID.should == CLIP_ID
109
133
  end
110
134
  end
111
135
 
112
136
  describe GranicusPlatformAPI, "::Client.get_clip_by_uid" do
113
137
  it "should get the requested clip" do
114
138
  clip = client.get_clip_by_uid CLIP_UID
115
- clip.id.should == CLIP_UID
139
+ clip.ID.should == CLIP_UID
116
140
  end
117
141
  end
118
142
 
119
143
  describe GranicusPlatformAPI, "::Client.get_event_meta_data" do
120
144
  it "should get my event meta data" do
121
145
  metadata = client.get_event_meta_data EVENT_ID
122
- found = metadata.find {|m| m.id == EVENT_META_ID }
146
+ found = metadata.find {|m| m.ID == EVENT_META_ID }
123
147
  found.should_not == nil
124
148
  end
125
149
  end
@@ -127,7 +151,7 @@ end
127
151
  describe GranicusPlatformAPI, "::Client.get_clip_meta_data" do
128
152
  it "should get my clip meta data" do
129
153
  metadata = client.get_clip_meta_data CLIP_ID
130
- found = metadata.find {|m| m.id == CLIP_META_ID }
154
+ found = metadata.find {|m| m.ID == CLIP_META_ID }
131
155
  found.should_not == nil
132
156
  end
133
157
  end
@@ -135,7 +159,7 @@ end
135
159
  describe GranicusPlatformAPI, "::Client.get_servers" do
136
160
  it "should get all servers" do
137
161
  servers = client.get_servers
138
- found = servers.find {|s| s.id == SERVER_ID }
162
+ found = servers.find {|s| s.ID == SERVER_ID }
139
163
  found.should_not == nil
140
164
  end
141
165
  end
@@ -143,7 +167,7 @@ end
143
167
  describe GranicusPlatformAPI, "::Client.get_server" do
144
168
  it "should get the requested server" do
145
169
  server = client.get_server SERVER_ID
146
- server.id.should == SERVER_D
170
+ server.ID.should == SERVER_D
147
171
  end
148
172
  end
149
173
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: granicus-platform-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-06-26 00:00:00.000000000Z
12
+ date: 2011-06-27 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &2161339560 !ruby/object:Gem::Requirement
16
+ requirement: &2152688320 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '2.6'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *2161339560
24
+ version_requirements: *2152688320
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: hashie
27
- requirement: &2161339060 !ruby/object:Gem::Requirement
27
+ requirement: &2152687820 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.0.0
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *2161339060
35
+ version_requirements: *2152687820
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: savon
38
- requirement: &2161338600 !ruby/object:Gem::Requirement
38
+ requirement: &2156842740 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 0.9.2
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2161338600
46
+ version_requirements: *2156842740
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: multi_xml
49
- requirement: &2161338140 !ruby/object:Gem::Requirement
49
+ requirement: &2156842280 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 0.2.2
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2161338140
57
+ version_requirements: *2156842280
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: savon
60
- requirement: &2164389960 !ruby/object:Gem::Requirement
60
+ requirement: &2156841820 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 0.9.2
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *2164389960
68
+ version_requirements: *2156841820
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: hashie
71
- requirement: &2164389500 !ruby/object:Gem::Requirement
71
+ requirement: &2156841360 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 1.0.0
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *2164389500
79
+ version_requirements: *2156841360
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: multi_xml
82
- requirement: &2164389040 !ruby/object:Gem::Requirement
82
+ requirement: &2156840900 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ~>
@@ -87,7 +87,7 @@ dependencies:
87
87
  version: 0.2.2
88
88
  type: :runtime
89
89
  prerelease: false
90
- version_requirements: *2164389040
90
+ version_requirements: *2156840900
91
91
  description: Wrapper for the Granicus Open Platform API v1.x
92
92
  email: javier@granicus.com
93
93
  executables: []
@@ -104,8 +104,10 @@ files:
104
104
  - granicus-platform-api.gemspec
105
105
  - lib/granicus-platform-api.rb
106
106
  - lib/granicus-platform-api/client.rb
107
+ - lib/granicus-platform-api/entities.rb
107
108
  - lib/granicus-platform-api/granicus-platform-api.xml
108
109
  - lib/granicus-platform-api/version.rb
110
+ - spec/fixtures/requests.xml
109
111
  - spec/granicus-platform-api_spec.rb
110
112
  - spec/helper.rb
111
113
  homepage: http://github.com/gov20cto/granicus-platform-api
@@ -133,5 +135,6 @@ signing_key:
133
135
  specification_version: 3
134
136
  summary: Granicus Open Platform API 1.x Wrapper
135
137
  test_files:
138
+ - spec/fixtures/requests.xml
136
139
  - spec/granicus-platform-api_spec.rb
137
140
  - spec/helper.rb