ruby-d2l 0.4.5 → 0.4.6

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.4
1
+ 0.4.6
@@ -30,7 +30,7 @@ module RubyD2L
30
30
  username = RubyD2L.username
31
31
  password = RubyD2L.password
32
32
  # RETURNS THE AUTH TOKEN
33
- response = self.connect(RubyD2L.site_url).request :authenticate do
33
+ response = self.connect(RubyD2L.site_url).request :authenticate do
34
34
  soap.xml = '<?xml version="1.0" encoding="utf-8"?>
35
35
  <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/">
36
36
  <soap:Body>
@@ -42,6 +42,7 @@ module RubyD2L
42
42
  </soap:Body>
43
43
  </soap:Envelope>'
44
44
  end
45
+
45
46
  token = response.to_hash[:authenticate_response][:token]
46
47
 
47
48
  end
@@ -253,6 +253,59 @@ module RubyD2L
253
253
  end
254
254
  end
255
255
 
256
+ # = CreateSemester
257
+ # REQUIRED:: { :semester_name => "NAME", :semester_code => "CODE" }
258
+ # 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) }
259
+ def self.create_semester(params={})
260
+ self.required_params(params, [:semester_name, :semester_code, :path])
261
+
262
+ params = {
263
+ :semester_name => "",
264
+ :semester_code => "",
265
+ :path => "",
266
+ :is_active => "true",
267
+ :start_date => DateTime.now.to_s,
268
+ :end_date => DateTime.now.to_s
269
+ }.merge(params)
270
+
271
+ token = RubyD2L::Auth.get_token
272
+
273
+ the_xml = '<?xml version="1.0" encoding="utf-8"?>
274
+ <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/">
275
+ <soap:Header>
276
+ <RequestHeader xmlns="http://www.desire2learn.com/services/common/xsd/common-v1_0">
277
+ <Version>1.0</Version>
278
+ <CorellationId>12345</CorellationId>
279
+ <AuthenticationToken>'+ token +'</AuthenticationToken>
280
+ </RequestHeader>
281
+ </soap:Header>
282
+ <soap:Body>
283
+ <CreateSemesterRequest xmlns="http://www.desire2learn.com/services/oums/wsdl/OrgUnitManagementService-v1_0">
284
+ <Name>'+ params[:semester_name] +'</Name>
285
+ <Code>'+ params[:semester_code] +'</Code>
286
+ <Path>'+ params[:path] +'</Path>
287
+ <IsActive>'+ params[:is_active] +'</IsActive>
288
+ <StartDate>'+ params[:start_date] +'</StartDate>
289
+ <EndDate>'+ params[:end_date] +'</EndDate>
290
+ </CreateSemesterRequest>
291
+ </soap:Body>
292
+ </soap:Envelope>'
293
+
294
+ esc_xml = the_xml.gsub("&", "&amp;")
295
+
296
+ template = self.connect(RubyD2L.site_url).request :create_semester do
297
+ soap.xml = esc_xml
298
+ end
299
+
300
+ response = template.to_hash[:create_semester_response]
301
+ puts response
302
+ if response.include?(:semester)
303
+ return Tools.get_all_values_nested(response)
304
+ else
305
+ return false
306
+ end
307
+ end
308
+
256
309
 
257
310
  # = GetCourseOfferingByCode
258
311
  # REQUIRED:: offering_code => "CODE"
@@ -423,6 +476,48 @@ module RubyD2L
423
476
 
424
477
  end
425
478
 
479
+ # = GetSemesterByCode
480
+ # REQUIRED:: :org_unit_code => "CODE"
481
+ # RETURNS:: false if not found, values hash if found
482
+ def self.get_semester_by_code(params={})
483
+ self.required_params(params, [:semester_code])
484
+
485
+ params = {
486
+ :semester_code => ""
487
+ }.merge(params)
488
+
489
+ token = RubyD2L::Auth.get_token
490
+
491
+ the_xml = '<?xml version="1.0" encoding="utf-8"?>
492
+ <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/">
493
+ <soap:Header>
494
+ <RequestHeader xmlns="http://www.desire2learn.com/services/common/xsd/common-v1_0">
495
+ <Version>1.0</Version>
496
+ <CorellationId>12345</CorellationId>
497
+ <AuthenticationToken>'+ token +'</AuthenticationToken>
498
+ </RequestHeader>
499
+ </soap:Header>
500
+ <soap:Body>
501
+ <GetSemesterByCodeRequest xmlns="http://www.desire2learn.com/services/oums/wsdl/OrgUnitManagementService-v1_0">
502
+ <Code>'+ params[:semester_code] +'</Code>
503
+ </GetSemesterByCodeRequest>
504
+ </soap:Body>
505
+ </soap:Envelope>'
506
+
507
+ semester = self.connect(RubyD2L.site_url).request :get_semester_by_code do
508
+ soap.xml = the_xml
509
+ end
510
+
511
+ response = semester.to_hash[:get_semester_response]
512
+
513
+ if response.include?(:semester)
514
+ return Tools.get_all_values_nested(response)
515
+ else
516
+ return false
517
+ end
518
+
519
+ end
520
+
426
521
 
427
522
  def self.required_params(passed_params={},*args)
428
523
  required_params = *args[0]
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "ruby-d2l"
8
- s.version = "0.4.5"
8
+ s.version = "0.4.6"
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"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-d2l
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
4
+ version: 0.4.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -131,7 +131,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
131
131
  version: '0'
132
132
  segments:
133
133
  - 0
134
- hash: -1128893145341774477
134
+ hash: -4552532641680965546
135
135
  required_rubygems_version: !ruby/object:Gem::Requirement
136
136
  none: false
137
137
  requirements: