granicus-platform-api 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/lib/granicus-platform-api/client.rb +26 -11
- data/lib/granicus-platform-api/version.rb +1 -1
- data/spec/granicus-platform-api_spec.rb +9 -1
- metadata +13 -13
data/Gemfile.lock
CHANGED
@@ -183,6 +183,11 @@ module GranicusPlatformAPI
|
|
183
183
|
def get_meta_data(meta_id)
|
184
184
|
call_soap_method(:get_meta_data,'//ns5:GetMetaDataResponse/MetaData', { :meta_data_id => meta_id })
|
185
185
|
end
|
186
|
+
|
187
|
+
# update metadata
|
188
|
+
def update_meta_data(meta_data)
|
189
|
+
call_soap_method(:update_meta_data,'//ns4:UpdateMetaDataResponse', { :meta_data => meta_data },true)
|
190
|
+
end
|
186
191
|
|
187
192
|
# return all of the folders
|
188
193
|
def get_folders
|
@@ -219,13 +224,13 @@ module GranicusPlatformAPI
|
|
219
224
|
call_soap_method(:get_server,'//ns5:GetServerResponse/server',{ :server_id => server_id })
|
220
225
|
end
|
221
226
|
|
222
|
-
private
|
227
|
+
#private
|
223
228
|
|
224
229
|
def call_soap_method(method,returnfilter,args={},debug=false)
|
225
230
|
response = @client.request :wsdl, method do
|
226
231
|
soap.namespaces['xmlns:granicus'] = "http://granicus.com/xsd"
|
227
232
|
soap.namespaces['xmlns:SOAP-ENC'] = "http://schemas.xmlsoap.org/soap/encoding/"
|
228
|
-
soap.body =
|
233
|
+
soap.body = prepare_hash args
|
229
234
|
if debug then
|
230
235
|
puts soap.body
|
231
236
|
end
|
@@ -241,36 +246,46 @@ module GranicusPlatformAPI
|
|
241
246
|
response
|
242
247
|
end
|
243
248
|
|
244
|
-
def
|
249
|
+
def prepare_hash(hash={})
|
245
250
|
attributes = {}
|
251
|
+
new_hash = {}
|
246
252
|
hash.each do |key,value|
|
247
253
|
case value.class.to_s
|
248
254
|
when /GranicusPlatformAPI::/, 'Hash'
|
249
|
-
|
255
|
+
new_hash[key] = prepare_hash value
|
250
256
|
when 'Array'
|
251
|
-
|
257
|
+
new_hash[key] = prepare_array value
|
258
|
+
else
|
259
|
+
new_hash[key] = value
|
252
260
|
end
|
253
261
|
attributes[key] = attribute_of value
|
254
262
|
end
|
255
|
-
|
263
|
+
new_hash.merge({ :attributes! => attributes })
|
256
264
|
end
|
257
265
|
|
258
266
|
def prepare_array(array)
|
259
|
-
array.
|
260
|
-
|
267
|
+
return { "item" => array } if array.count == 0
|
268
|
+
new_array = []
|
269
|
+
array.each do |item|
|
270
|
+
case item.class.to_s
|
261
271
|
when /GranicusPlatformAPI::/, 'Hash'
|
262
|
-
|
272
|
+
new_array << prepare_hash(item)
|
273
|
+
when 'Array'
|
274
|
+
new_array << prepare_array(item)
|
275
|
+
else
|
276
|
+
new_array << item
|
263
277
|
end
|
264
278
|
end
|
265
|
-
{ "item" =>
|
279
|
+
{ "item" => new_array, :attributes! => { "item" => attribute_of(array[0]) } }
|
266
280
|
end
|
267
281
|
|
268
282
|
def attribute_of(value)
|
269
283
|
case value.class.to_s
|
270
284
|
when 'Array'
|
285
|
+
return {"xsi:type" => 'SOAP-ENC:Array'} if value.count == 0
|
271
286
|
xsd_type = self.class.classmap[value[0].class.to_s.split('::').last]
|
272
287
|
if xsd_type.nil?
|
273
|
-
puts "Couldn't get xsd:type for #{value.class}"
|
288
|
+
puts "Couldn't get array xsd:type for #{value[0].class}"
|
274
289
|
{"xsi:type" => 'SOAP-ENC:Array'}
|
275
290
|
else
|
276
291
|
{"xsi:type" => 'SOAP-ENC:Array', "SOAP-ENC:arrayType" => "#{xsd_type}[#{value.count}]"}
|
@@ -143,7 +143,15 @@ describe GranicusPlatformAPI, "::Client MetaData Methods" do
|
|
143
143
|
it "should get the requested meta data" do
|
144
144
|
metadata = client.get_meta_data CLIP_META_ID
|
145
145
|
metadata.ID = CLIP_META_ID
|
146
|
-
|
146
|
+
end
|
147
|
+
it "should update the metadata" do
|
148
|
+
metadata = client.get_meta_data CLIP_META_ID
|
149
|
+
old_name = metadata.Name
|
150
|
+
metadata.Name = 'test'
|
151
|
+
client.update_meta_data metadata
|
152
|
+
client.get_meta_data(CLIP_META_ID).Name.should == 'test'
|
153
|
+
metadata.Name = old_name
|
154
|
+
client.update_meta_data metadata
|
147
155
|
end
|
148
156
|
end
|
149
157
|
|
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.
|
4
|
+
version: 0.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-06-28 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &2165464880 !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: *
|
24
|
+
version_requirements: *2165464880
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: simplecov
|
27
|
-
requirement: &
|
27
|
+
requirement: &2165464380 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 0.4.0
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2165464380
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: hashie
|
38
|
-
requirement: &
|
38
|
+
requirement: &2165463920 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 1.0.0
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2165463920
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: savon
|
49
|
-
requirement: &
|
49
|
+
requirement: &2165463460 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 0.9.2
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2165463460
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: savon
|
60
|
-
requirement: &
|
60
|
+
requirement: &2165463000 !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: *
|
68
|
+
version_requirements: *2165463000
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: hashie
|
71
|
-
requirement: &
|
71
|
+
requirement: &2165462540 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,7 +76,7 @@ dependencies:
|
|
76
76
|
version: 1.0.0
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *2165462540
|
80
80
|
description: Wrapper for the Granicus Open Platform API v1.x
|
81
81
|
email: javier@granicus.com
|
82
82
|
executables: []
|