ruby-d2l 0.3.0 → 0.4.0
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/README.rdoc +3 -2
- data/VERSION +1 -1
- data/lib/ruby-d2l/auth.rb +1 -1
- data/lib/ruby-d2l/config.rb +0 -1
- data/lib/ruby-d2l/org_unit.rb +212 -8
- data/lib/ruby-d2l/tools.rb +23 -0
- data/lib/ruby-d2l/user.rb +137 -25
- data/lib/ruby-d2l.rb +8 -0
- data/ruby-d2l.gemspec +3 -2
- metadata +5 -4
data/README.rdoc
CHANGED
@@ -22,14 +22,15 @@ Then in your Ruby application you can use the configure block to set these value
|
|
22
22
|
config.username = "D2L_WEB_SERVICES_USERNAME"
|
23
23
|
config.password = "D2L_WEB_SERVICES_PASSWORD"
|
24
24
|
config.site_url = "D2L_INSTANCE_URL" (e.g. https://d2l.mysite.edu)
|
25
|
+
config.soap_logging = true (defaults to false unless set)
|
25
26
|
end
|
26
27
|
|
27
28
|
== Documentation
|
28
29
|
|
29
30
|
Code Example:
|
30
31
|
|
31
|
-
template = RubyD2L::OrgUnit.get_course_template_by_code(:template_code => "TEMPLATE_CODE")
|
32
|
-
ap template
|
32
|
+
template = RubyD2L::OrgUnit.get_course_template_by_code(:template_code => "TEMPLATE_CODE")
|
33
|
+
ap template
|
33
34
|
|
34
35
|
|
35
36
|
== Contributing to ruby-d2l
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.0
|
data/lib/ruby-d2l/auth.rb
CHANGED
data/lib/ruby-d2l/config.rb
CHANGED
data/lib/ruby-d2l/org_unit.rb
CHANGED
@@ -88,10 +88,65 @@ module RubyD2L
|
|
88
88
|
# ]
|
89
89
|
end
|
90
90
|
|
91
|
+
# = AddChildOrgUnit
|
92
|
+
# REQUIRED:: { :parent_id = "ID", :child_id => "ID" }
|
93
|
+
# RETURNS::
|
94
|
+
def self.add_child_org_unit(params={})
|
95
|
+
self.required_params(params, [:parent_id, :child_id])
|
96
|
+
|
97
|
+
params = {
|
98
|
+
:parent_id => "",
|
99
|
+
:child_id => ""
|
100
|
+
}.merge(params)
|
101
|
+
|
102
|
+
token = RubyD2L::Auth.get_token
|
103
|
+
|
104
|
+
the_xml = '<?xml version="1.0" encoding="utf-8"?>
|
105
|
+
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
106
|
+
<soap:Header>
|
107
|
+
<RequestHeader xmlns="http://www.desire2learn.com/services/common/xsd/common-v1_0">
|
108
|
+
<Version>1.0</Version>
|
109
|
+
<CorellationId>12345</CorellationId>
|
110
|
+
<AuthenticationToken>'+ token +'</AuthenticationToken>
|
111
|
+
</RequestHeader>
|
112
|
+
</soap:Header>
|
113
|
+
<soap:Body>
|
114
|
+
<AddChildOrgUnitRequest xmlns="http://www.desire2learn.com/services/oums/wsdl/OrgUnitManagementService-v1_0">
|
115
|
+
<OrgUnitId>
|
116
|
+
<Id xmlns="http://www.desire2learn.com/services/common/xsd/common-v1_0">'+ params[:parent_id] +'</Id>
|
117
|
+
<Source xmlns="http://www.desire2learn.com/services/common/xsd/common-v1_0">Desire2Learn</Source>
|
118
|
+
</OrgUnitId>
|
119
|
+
<ChildOrgUnitId>
|
120
|
+
<Id xmlns="http://www.desire2learn.com/services/common/xsd/common-v1_0">'+ params[:child_id] +'</Id>
|
121
|
+
<Source xmlns="http://www.desire2learn.com/services/common/xsd/common-v1_0">Desire2Learn</Source>
|
122
|
+
</ChildOrgUnitId>
|
123
|
+
</AddChildOrgUnitRequest>
|
124
|
+
</soap:Body>
|
125
|
+
</soap:Envelope>'
|
126
|
+
|
127
|
+
add_child = self.connect(RubyD2L.site_url).request :add_child_org_unit do
|
128
|
+
soap.xml = the_xml
|
129
|
+
end
|
130
|
+
|
131
|
+
if add_child.to_hash.include?(:add_child_org_unit_response)
|
132
|
+
response = add_chile.to_hash[:add_child_org_unit_response]
|
133
|
+
response_hash = Tools.get_all_values_nested(response)
|
134
|
+
if response_hash.keys.any? {|k| k.include? "business_errors"}
|
135
|
+
return response_hash.keep_if {|k,v| k.include? "business_errors"}
|
136
|
+
else
|
137
|
+
return response_hash
|
138
|
+
end
|
139
|
+
else
|
140
|
+
return false
|
141
|
+
end
|
142
|
+
|
143
|
+
end
|
144
|
+
|
145
|
+
|
91
146
|
# = CreateCourseOffering
|
92
|
-
# REQUIRED
|
93
|
-
# OPTIONAL
|
94
|
-
# NOT IMPLEMENTED
|
147
|
+
# REQUIRED:: { :offering_name => "NAME", :offering_code => "CODE" }
|
148
|
+
# OPTIONAL:: { :is_active => "true|false", :start_date => DateTime.to_s (e.g. YYYYMMDDThh:mm:ss), :end_date => DateTime.to_s (e.g. YYYYMMDDThh:mm:ss) }
|
149
|
+
# NOT IMPLEMENTED:: I don't use <Path>'+ @course_path +'</Path>. Add it if you need it.
|
95
150
|
def self.create_course_offering(params={})
|
96
151
|
self.required_params(params, [:offering_name, :offering_code, :template_id])
|
97
152
|
|
@@ -134,15 +189,21 @@ module RubyD2L
|
|
134
189
|
</soap:Body>
|
135
190
|
</soap:Envelope>'
|
136
191
|
|
137
|
-
|
192
|
+
create_offering = self.connect(RubyD2L.site_url).request :create_course_offering do
|
138
193
|
soap.xml = the_xml
|
139
194
|
end
|
140
195
|
|
196
|
+
response = create_offering.to_hash[:create_course_offering_response]
|
197
|
+
if response.include?(:course_offering)
|
198
|
+
return Tools.get_all_values_nested(response)
|
199
|
+
else
|
200
|
+
return false
|
201
|
+
end
|
141
202
|
end
|
142
203
|
|
143
204
|
# = CreateCourseTemplate
|
144
|
-
# REQUIRED
|
145
|
-
# OPTIONAL
|
205
|
+
# REQUIRED:: { :template_name => "NAME", :template_code => "CODE" }
|
206
|
+
# OPTIONAL:: { :is_active => "true|false", :start_date => DateTime.to_s (e.g. YYYYMMDDThh:mm:ss), :end_date => DateTime.to_s (e.g. YYYYMMDDThh:mm:ss) }
|
146
207
|
def self.create_course_template(params={})
|
147
208
|
self.required_params(params, [:template_name, :template_code])
|
148
209
|
|
@@ -179,11 +240,61 @@ module RubyD2L
|
|
179
240
|
template = self.connect(RubyD2L.site_url).request :create_course_template do
|
180
241
|
soap.xml = the_xml
|
181
242
|
end
|
182
|
-
|
243
|
+
|
244
|
+
response = template.to_hash[:create_course_template_response]
|
245
|
+
if response.include?(:course_template)
|
246
|
+
return Tools.get_all_values_nested(response)
|
247
|
+
else
|
248
|
+
return false
|
249
|
+
end
|
183
250
|
end
|
184
251
|
|
252
|
+
|
253
|
+
# = GetCourseOfferingByCode
|
254
|
+
# REQUIRED:: offering_code => "CODE"
|
255
|
+
# RETURNS:: false if not found, values hash if found
|
256
|
+
def self.get_course_offering_by_code(params={})
|
257
|
+
self.required_params(params, [:offering_code])
|
258
|
+
|
259
|
+
params = {
|
260
|
+
:offering_code => ""
|
261
|
+
}.merge(params)
|
262
|
+
|
263
|
+
token = RubyD2L::Auth.get_token
|
264
|
+
|
265
|
+
the_xml = '<?xml version="1.0" encoding="utf-8"?>
|
266
|
+
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
267
|
+
<soap:Header>
|
268
|
+
<RequestHeader xmlns="http://www.desire2learn.com/services/common/xsd/common-v1_0">
|
269
|
+
<Version>1.0</Version>
|
270
|
+
<CorellationId>12345</CorellationId>
|
271
|
+
<AuthenticationToken>'+ token +'</AuthenticationToken>
|
272
|
+
</RequestHeader>
|
273
|
+
</soap:Header>
|
274
|
+
<soap:Body>
|
275
|
+
<GetCourseOfferingByCodeRequest xmlns="http://www.desire2learn.com/services/oums/wsdl/OrgUnitManagementService-v1_0">
|
276
|
+
<Code>'+ params[:offering_code] +'</Code>
|
277
|
+
</GetCourseOfferingByCodeRequest>
|
278
|
+
</soap:Body>
|
279
|
+
</soap:Envelope>'
|
280
|
+
|
281
|
+
offering = self.connect(RubyD2L.site_url).request :get_course_offering_by_code do
|
282
|
+
soap.xml = the_xml
|
283
|
+
end
|
284
|
+
|
285
|
+
response = offering.to_hash[:get_course_offering_response]
|
286
|
+
if response.include?(:course_offering)
|
287
|
+
return Tools.get_all_values_nested(response)
|
288
|
+
else
|
289
|
+
return false
|
290
|
+
end
|
291
|
+
|
292
|
+
end
|
293
|
+
|
294
|
+
|
185
295
|
# = GetCourseTemplateByCode
|
186
|
-
# REQUIRED
|
296
|
+
# REQUIRED:: template_code => "CODE"
|
297
|
+
# RETURNS:: false if not found, values hash if found
|
187
298
|
def self.get_course_template_by_code(params={})
|
188
299
|
self.required_params(params, [:template_code])
|
189
300
|
|
@@ -213,8 +324,101 @@ module RubyD2L
|
|
213
324
|
soap.xml = the_xml
|
214
325
|
end
|
215
326
|
|
327
|
+
response = template.to_hash[:get_course_template_response]
|
328
|
+
if response.include?(:course_template)
|
329
|
+
return Tools.get_all_values_nested(response)
|
330
|
+
else
|
331
|
+
return false
|
332
|
+
end
|
216
333
|
end
|
217
334
|
|
335
|
+
# = GetChildCourseTemplates
|
336
|
+
# REQUIRED:: org_unit_id => "ID"
|
337
|
+
# RETURNS:: false if not found, values hash if found
|
338
|
+
def self.get_child_course_templates(params={})
|
339
|
+
self.required_params(params, [:org_unit_id])
|
340
|
+
|
341
|
+
params = {
|
342
|
+
:org_unit_id => ""
|
343
|
+
}.merge(params)
|
344
|
+
|
345
|
+
token = RubyD2L::Auth.get_token
|
346
|
+
|
347
|
+
the_xml = '<?xml version="1.0" encoding="utf-8"?>
|
348
|
+
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
349
|
+
<soap:Header>
|
350
|
+
<RequestHeader xmlns="http://www.desire2learn.com/services/common/xsd/common-v1_0">
|
351
|
+
<Version>1.0</Version>
|
352
|
+
<CorellationId>12345</CorellationId>
|
353
|
+
<AuthenticationToken>'+ token +'</AuthenticationToken>
|
354
|
+
</RequestHeader>
|
355
|
+
</soap:Header>
|
356
|
+
<soap:Body>
|
357
|
+
<GetChildCourseTemplatesRequest xmlns="http://www.desire2learn.com/services/oums/wsdl/OrgUnitManagementService-v1_0">
|
358
|
+
<OrgUnitId>
|
359
|
+
<Id xmlns="http://www.desire2learn.com/services/common/xsd/common-v1_0">'+ params[:org_unit_id] +'</Id>
|
360
|
+
<Source xmlns="http://www.desire2learn.com/services/common/xsd/common-v1_0">Desire2Learn</Source>
|
361
|
+
</OrgUnitId>
|
362
|
+
</GetChildCourseTemplatesRequest>
|
363
|
+
</soap:Body>
|
364
|
+
</soap:Envelope>'
|
365
|
+
|
366
|
+
child_templates = self.connect(RubyD2L.site_url).request :get_child_course_templates do
|
367
|
+
soap.xml = the_xml
|
368
|
+
end
|
369
|
+
|
370
|
+
response = child_templates.to_hash[:get_course_templates_response]
|
371
|
+
|
372
|
+
if response.include?(:child_org_units)
|
373
|
+
return Tools.get_all_values_nested(response)
|
374
|
+
else
|
375
|
+
return false
|
376
|
+
end
|
377
|
+
|
378
|
+
end
|
379
|
+
|
380
|
+
# = GetDepartmentByCode
|
381
|
+
# REQUIRED:: :org_unit_code => "CODE"
|
382
|
+
# RETURNS:: false if not found, values hash if found
|
383
|
+
def self.get_department_by_code(params={})
|
384
|
+
self.required_params(params, [:org_unit_code])
|
385
|
+
|
386
|
+
params = {
|
387
|
+
:org_unit_code => ""
|
388
|
+
}.merge(params)
|
389
|
+
|
390
|
+
token = RubyD2L::Auth.get_token
|
391
|
+
|
392
|
+
the_xml = '<?xml version="1.0" encoding="utf-8"?>
|
393
|
+
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
394
|
+
<soap:Header>
|
395
|
+
<RequestHeader xmlns="http://www.desire2learn.com/services/common/xsd/common-v1_0">
|
396
|
+
<Version>1.0</Version>
|
397
|
+
<CorellationId>12345</CorellationId>
|
398
|
+
<AuthenticationToken>'+ token +'</AuthenticationToken>
|
399
|
+
</RequestHeader>
|
400
|
+
</soap:Header>
|
401
|
+
<soap:Body>
|
402
|
+
<GetDepartmentByCodeRequest xmlns="http://www.desire2learn.com/services/oums/wsdl/OrgUnitManagementService-v1_0">
|
403
|
+
<Code>'+ params[:org_unit_code] +'</Code>
|
404
|
+
</GetDepartmentByCodeRequest>
|
405
|
+
</soap:Body>
|
406
|
+
</soap:Envelope>'
|
407
|
+
|
408
|
+
department = self.connect(RubyD2L.site_url).request :get_department_by_code do
|
409
|
+
soap.xml = the_xml
|
410
|
+
end
|
411
|
+
|
412
|
+
response = department.to_hash[:get_department_response]
|
413
|
+
if response.include?(:department)
|
414
|
+
return Tools.get_all_values_nested(response)
|
415
|
+
else
|
416
|
+
return false
|
417
|
+
end
|
418
|
+
|
419
|
+
end
|
420
|
+
|
421
|
+
|
218
422
|
def self.required_params(passed_params={},*args)
|
219
423
|
required_params = *args[0]
|
220
424
|
required_params.each do |key|
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class Tools
|
2
|
+
|
3
|
+
@path = []
|
4
|
+
|
5
|
+
@all_values = {}
|
6
|
+
|
7
|
+
def self.get_all_values_nested(nested_hash={})
|
8
|
+
nested_hash.each_pair do |k,v|
|
9
|
+
@path << k
|
10
|
+
case v
|
11
|
+
when Array, DateTime, FalseClass, Fixnum, NilClass, String, TrueClass then
|
12
|
+
@all_values.merge!({"#{@path.join(".")}" => "#{v}"})
|
13
|
+
@path.pop
|
14
|
+
when Hash then get_all_values_nested(v)
|
15
|
+
else raise ArgumentError, "Unhandled type #{v.class}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
@path.pop
|
19
|
+
|
20
|
+
return @all_values
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
data/lib/ruby-d2l/user.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require "savon"
|
2
|
-
|
3
1
|
module RubyD2L
|
4
2
|
class User
|
5
3
|
|
@@ -54,36 +52,150 @@ module RubyD2L
|
|
54
52
|
|
55
53
|
end
|
56
54
|
|
55
|
+
# = EnrollUser
|
56
|
+
# REQUIRED:: { :org_unit_id => "ID, ":user_id => "ID", :role_id => "ID" }
|
57
|
+
# RETURNS::
|
58
|
+
def self.enroll_user(params={})
|
59
|
+
self.required_params(params, [:org_unit_id, :user_id, :role_id])
|
60
|
+
|
61
|
+
params = {
|
62
|
+
:org_unit_id => "",
|
63
|
+
:user_id => "",
|
64
|
+
:role_id => ""
|
65
|
+
}.merge(params)
|
57
66
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
67
|
+
token = RubyD2L::Auth.get_token
|
68
|
+
|
69
|
+
the_xml = '<?xml version="1.0" encoding="utf-8"?>
|
70
|
+
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
71
|
+
<soap:Header>
|
72
|
+
<RequestHeader xmlns="http://www.desire2learn.com/services/common/xsd/common-v1_0">
|
73
|
+
<Version>1.0</Version>
|
74
|
+
<CorellationId>12345</CorellationId>
|
75
|
+
<AuthenticationToken>'+ token +'</AuthenticationToken>
|
76
|
+
</RequestHeader>
|
77
|
+
</soap:Header>
|
78
|
+
<soap:Body>
|
79
|
+
<EnrollUserRequest xmlns="http://www.desire2learn.com/services/ums/wsdl/UserManagementService-v1_0">
|
80
|
+
<OrgUnitId>
|
81
|
+
<Id xmlns="http://www.desire2learn.com/services/common/xsd/common-v1_0">'+ params[:org_unit_id] +'</Id>
|
82
|
+
<Source xmlns="http://www.desire2learn.com/services/common/xsd/common-v1_0">Desire2Learn</Source>
|
83
|
+
</OrgUnitId>
|
84
|
+
<UserId>
|
85
|
+
<Id xmlns="http://www.desire2learn.com/services/common/xsd/common-v1_0">'+ params[:user_id] +'</Id>
|
86
|
+
<Source xmlns="http://www.desire2learn.com/services/common/xsd/common-v1_0">Desire2Learn</Source>
|
87
|
+
</UserId>
|
88
|
+
<RoleId>
|
89
|
+
<Id xmlns="http://www.desire2learn.com/services/common/xsd/common-v1_0">'+ params[:role_id] +'</Id>
|
90
|
+
<Source xmlns="http://www.desire2learn.com/services/common/xsd/common-v1_0">Desire2Learn</Source>
|
91
|
+
</RoleId>
|
92
|
+
</EnrollUserRequest>
|
93
|
+
</soap:Body>
|
94
|
+
</soap:Envelope>'
|
95
|
+
|
96
|
+
enrollment = self.connect(RubyD2L.site_url).request :enroll_user do
|
97
|
+
soap.xml = the_xml
|
98
|
+
end
|
99
|
+
|
100
|
+
if enrollment.to_hash.include?(:enroll_user_response)
|
101
|
+
response = enrollment.to_hash[:enroll_user_response]
|
102
|
+
response_hash = Tools.get_all_values_nested(response)
|
103
|
+
if response_hash.keys.any? {|k| k.include? "business_errors"}
|
104
|
+
return response_hash.keep_if {|k,v| k.include? "business_errors"}
|
105
|
+
else
|
106
|
+
return response_hash
|
107
|
+
end
|
64
108
|
else
|
65
|
-
|
109
|
+
return false
|
66
110
|
end
|
111
|
+
|
112
|
+
end
|
113
|
+
|
114
|
+
# = EnrollUser
|
115
|
+
# REQUIRED:: N/A
|
116
|
+
# RETURNS:: Array of roles
|
117
|
+
def self.get_roles()
|
118
|
+
token = RubyD2L::Auth.get_token
|
119
|
+
|
120
|
+
the_xml = '<?xml version="1.0" encoding="utf-8"?>
|
121
|
+
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
122
|
+
<soap:Header>
|
123
|
+
<RequestHeader xmlns="http://www.desire2learn.com/services/common/xsd/common-v1_0">
|
124
|
+
<Version>1.0</Version>
|
125
|
+
<CorellationId>12345</CorellationId>
|
126
|
+
<AuthenticationToken>'+ token +'</AuthenticationToken>
|
127
|
+
</RequestHeader>
|
128
|
+
</soap:Header>
|
129
|
+
<soap:Body>
|
130
|
+
<GetRolesRequest xmlns="http://www.desire2learn.com/services/ums/wsdl/UserManagementService-v1_0" />
|
131
|
+
</soap:Body>
|
132
|
+
</soap:Envelope>'
|
133
|
+
|
134
|
+
roles = self.connect(RubyD2L.site_url).request :get_roles do
|
135
|
+
soap.xml = the_xml
|
136
|
+
end
|
137
|
+
|
138
|
+
response = roles.to_hash[:get_roles_response]
|
139
|
+
@role_info = []
|
140
|
+
if response.include?(:roles)
|
141
|
+
response[:roles][:role_info].each do |r|
|
142
|
+
@role_info << Tools.get_all_values_nested(r)
|
143
|
+
end
|
144
|
+
return @role_info
|
145
|
+
else
|
146
|
+
return false
|
147
|
+
end
|
148
|
+
end
|
67
149
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
150
|
+
|
151
|
+
|
152
|
+
def self.get_user_by_user_name(params={})
|
153
|
+
self.required_params(params, :user_name)
|
154
|
+
|
155
|
+
params = {
|
156
|
+
:user_name => ""
|
157
|
+
}.merge(params)
|
158
|
+
|
159
|
+
token = RubyD2L::Auth.get_token
|
160
|
+
|
161
|
+
the_xml = '<?xml version="1.0" encoding="utf-8"?>
|
162
|
+
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
163
|
+
<soap:Header>
|
164
|
+
<RequestHeader xmlns="http://www.desire2learn.com/services/common/xsd/common-v1_0">
|
165
|
+
<Version>1.0</Version>
|
166
|
+
<CorellationId>12345</CorellationId>
|
167
|
+
<AuthenticationToken>'+ token +'</AuthenticationToken>
|
168
|
+
</RequestHeader>
|
169
|
+
</soap:Header>
|
170
|
+
<soap:Body>
|
171
|
+
<GetUserByUserNameRequest xmlns="http://www.desire2learn.com/services/ums/wsdl/UserManagementService-v1_0">
|
172
|
+
<UserName>'+ params[:user_name] +'</UserName>
|
173
|
+
</GetUserByUserNameRequest>
|
174
|
+
</soap:Body>
|
175
|
+
</soap:Envelope>'
|
176
|
+
|
177
|
+
user = self.connect(RubyD2L.site_url).request :get_user_by_user_name do
|
178
|
+
soap.xml = the_xml
|
179
|
+
end
|
180
|
+
|
181
|
+
# ap user.to_hash
|
182
|
+
# exit
|
183
|
+
|
184
|
+
response = user.to_hash[:get_user_response]
|
185
|
+
if response.include?(:user)
|
186
|
+
return Tools.get_all_values_nested(response)
|
187
|
+
else
|
188
|
+
return false
|
84
189
|
end
|
190
|
+
|
85
191
|
end
|
86
192
|
|
193
|
+
def self.required_params(passed_params={},*args)
|
194
|
+
required_params = *args[0]
|
195
|
+
required_params.each do |key|
|
196
|
+
raise ArgumentError.new("MISSING PARAM -- :#{key} parameter is required!") unless passed_params.has_key?(key)
|
197
|
+
end
|
198
|
+
end
|
87
199
|
|
88
200
|
end
|
89
201
|
end
|
data/lib/ruby-d2l.rb
CHANGED
@@ -2,6 +2,7 @@ require "ruby-d2l/auth"
|
|
2
2
|
require "ruby-d2l/config"
|
3
3
|
require "ruby-d2l/grades"
|
4
4
|
require "ruby-d2l/org_unit"
|
5
|
+
require "ruby-d2l/tools"
|
5
6
|
require "ruby-d2l/user"
|
6
7
|
|
7
8
|
|
@@ -14,4 +15,11 @@ module RubyD2L
|
|
14
15
|
yield self if block_given?
|
15
16
|
end
|
16
17
|
|
18
|
+
Savon.configure do |config|
|
19
|
+
config.log = false
|
20
|
+
end
|
21
|
+
HTTPI.log = false
|
22
|
+
|
23
|
+
|
24
|
+
|
17
25
|
end
|
data/ruby-d2l.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{ruby-d2l}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.4.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Matt Mencel"]
|
12
|
-
s.date = %q{2011-12-
|
12
|
+
s.date = %q{2011-12-21}
|
13
13
|
s.description = %q{A Ruby SOAP client for accessing Desire2Learn Web Services (D2LWS)}
|
14
14
|
s.email = %q{mr-mencel@wiu.edu}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -29,6 +29,7 @@ Gem::Specification.new do |s|
|
|
29
29
|
"lib/ruby-d2l/config.rb",
|
30
30
|
"lib/ruby-d2l/grades.rb",
|
31
31
|
"lib/ruby-d2l/org_unit.rb",
|
32
|
+
"lib/ruby-d2l/tools.rb",
|
32
33
|
"lib/ruby-d2l/user.rb",
|
33
34
|
"ruby-d2l.gemspec",
|
34
35
|
"test/helper.rb",
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
7
|
+
- 4
|
8
8
|
- 0
|
9
|
-
version: 0.
|
9
|
+
version: 0.4.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Matt Mencel
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-12-
|
17
|
+
date: 2011-12-21 00:00:00 -06:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -108,6 +108,7 @@ files:
|
|
108
108
|
- lib/ruby-d2l/config.rb
|
109
109
|
- lib/ruby-d2l/grades.rb
|
110
110
|
- lib/ruby-d2l/org_unit.rb
|
111
|
+
- lib/ruby-d2l/tools.rb
|
111
112
|
- lib/ruby-d2l/user.rb
|
112
113
|
- ruby-d2l.gemspec
|
113
114
|
- test/helper.rb
|
@@ -126,7 +127,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
126
127
|
requirements:
|
127
128
|
- - ">="
|
128
129
|
- !ruby/object:Gem::Version
|
129
|
-
hash: -
|
130
|
+
hash: -3300350606523422764
|
130
131
|
segments:
|
131
132
|
- 0
|
132
133
|
version: "0"
|