d2l_sdk 0.1.8 → 0.1.9

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.
@@ -108,10 +108,11 @@ end
108
108
 
109
109
  # Performs a delete request by creating an authenticated uri and using the
110
110
  # RestClient delete method and specifying the content_type as being JSON.
111
- def _delete(path, isD2l = true)
111
+ def _delete(path, isD2l = true, headers = {})
112
+ headers[:content_type] = :json
112
113
  auth_uri = path
113
114
  auth_uri = create_authenticated_uri(path, 'DELETE') if isD2l == true
114
- RestClient.delete(auth_uri, content_type: :json)
115
+ RestClient.delete(auth_uri, headers)
115
116
  end
116
117
 
117
118
  # based upon the specific code that is returned from the http method, this
@@ -182,18 +183,6 @@ def get_latest_product_version(product_code)
182
183
  end
183
184
  end
184
185
 
185
- # init products to newest versions.
186
- $le_ver = get_latest_product_version('le')
187
- $lp_ver = get_latest_product_version('lp')
188
- $ep_ver = get_latest_product_version('ep')
189
- #lti, rp, LR, ext,
190
- puts "versions set to:"
191
- versions = {
192
- "le_ver" => $le_ver,
193
- "lp_ver" => $lp_ver,
194
- "ep_ver" => $ep_ver
195
- }
196
- ap versions
197
186
  # retrieve all supported versions for all product components
198
187
  def get_versions
199
188
  path = "/d2l/api/versions/"
@@ -11,58 +11,6 @@ def delete_section(org_unit_id, section_id)
11
11
  _delete(path)
12
12
  end
13
13
 
14
- ##########
15
- # WesternOnline Specific GET Section ID by Code
16
- ##########
17
- def create_semester_code(star_num, course_date)
18
- "sec_#{course_date}_#{star_num}"
19
- end
20
-
21
- def get_section_by_section_code(code)
22
- _get("/d2l/api/lp/1.4/orgstructure/?orgUnitCode=#{code}")["Items"][0]
23
- end
24
-
25
- def get_section_id_by_section_code(code)
26
- get_section_by_section_code(code)["Identifier"]
27
- end
28
-
29
- def get_section_data_by_code(code)
30
- sect_id = get_section_by_section_code(code)["Identifier"]
31
- parent_id = get_org_unit_parents(sect_id)[0]["Identifier"]
32
- get_section_data(parent_id, sect_id)
33
- end
34
- =begin
35
- def get_section_by_offering_code(code)
36
- section_data = 0
37
- parent_course = nil
38
- courses = get_courses_by_code(code)
39
- if courses.size > 1 # If the course code matches two codes..should be CL then
40
- courses.each do |course| # iterate through each course...should be < 3
41
- if course["Code"].include? "cl_off"
42
- parent_course = course
43
- end
44
- end
45
- # ELSE IF no course with "cl_off" found: Not properly cross listed
46
- if parent_course == nil
47
- puts "More than two courses with same code index; No proper crosslisting"
48
- end
49
- end
50
- # get all sections of the course offering
51
- sections = get_org_unit_sections(parent_course["Identifier"])
52
- sections.each do |sect|
53
- if sect["Code"].include? code[-5..-1]
54
- section_data = sect
55
- end
56
- end
57
- return section_data
58
- end
59
-
60
- def get_section_id_by_section_code(code)
61
- get_section_data_by_code(code)["SectionId"]
62
- end
63
- =end
64
- ############
65
- ############
66
14
  # Retrieve all the sections for a provided org unit.
67
15
  def get_org_unit_sections(org_unit_id)
68
16
  path = "/d2l/api/lp/#{$lp_ver}/#{org_unit_id}/sections/"
@@ -193,6 +141,7 @@ def update_org_unit_section_properties(org_unit_id, section_property_data)
193
141
  # for the org unit’s updated section properties.
194
142
  end
195
143
 
144
+ # Update information for a section in a particular org unit.
196
145
  def update_org_unit_section_info(org_unit_id, section_id, section_data)
197
146
  payload = { 'Name' => '', # String
198
147
  'Code' => '', # String
@@ -205,3 +154,79 @@ def update_org_unit_section_info(org_unit_id, section_id, section_data)
205
154
  _put(path, payload)
206
155
  # returns the SectionData JSON block, in its Fetch form
207
156
  end
157
+
158
+ #########################################################
159
+ # WesternOnline Specific GET Section ID by Code##########
160
+ #########################################################
161
+ # NOTE: These are additional functions that were primarily made to work with
162
+ # the Western Illinois University brightspace instance. Most will work
163
+ # universally, but others may be of no use outside our specific instance.
164
+
165
+ # creates a properly formatted section code, based on WIU's standard
166
+ # section code.
167
+ # RETURNS: formatted section code
168
+ def create_section_code(star_num, course_date)
169
+ "sec_#{course_date}_#{star_num}"
170
+ end
171
+
172
+ # retrieves all sections with the same code.
173
+ # NOTE: As the code SHOULD be unique, this function assumes that the returned
174
+ # item is the requested item.
175
+ def get_section_by_section_code(code)
176
+ path = "/d2l/api/lp/#{$lp_ver}/orgstructure/?orgUnitCode=#{code}"
177
+ _get(path)["Items"][0]
178
+ # RETURNS: SectionData block
179
+ end
180
+
181
+ # Simple bridge function that allows for the retrieval of a section's ID
182
+ # based on its section code.
183
+ # NOTE: Again, As the code SHOULD be unique, this function assumes that the
184
+ # returned item is the requested item.
185
+ def get_section_id_by_section_code(code)
186
+ get_section_by_section_code(code)["Identifier"]
187
+ # RETURNS: D2LID of the section identified by its section code
188
+ end
189
+
190
+ # Simple bridge function allowing for retrieval of section data by using
191
+ # the section's code. As D2L does not allow for accessing the SectionData block
192
+ # without using a parent's id, this retrieves the parents id and allows for
193
+ # such functionality.
194
+ def get_section_data_by_code(code)
195
+ sect_id = get_section_by_section_code(code)["Identifier"]
196
+ parent_id = get_org_unit_parents(sect_id)[0]["Identifier"]
197
+ get_section_data(parent_id, sect_id)
198
+ end
199
+
200
+ =begin
201
+ # IDEA::
202
+ def get_section_by_offering_code(code)
203
+ section_data = 0
204
+ parent_course = nil
205
+ courses = get_courses_by_code(code)
206
+ if courses.size > 1 # If the course code matches two codes..should be CL then
207
+ courses.each do |course| # iterate through each course...should be < 3
208
+ if course["Code"].include? "cl_off"
209
+ parent_course = course
210
+ end
211
+ end
212
+ # ELSE IF no course with "cl_off" found: Not properly cross listed
213
+ if parent_course == nil
214
+ puts "More than two courses with same code index; No proper crosslisting"
215
+ end
216
+ end
217
+ # get all sections of the course offering
218
+ sections = get_org_unit_sections(parent_course["Identifier"])
219
+ sections.each do |sect|
220
+ if sect["Code"].include? code[-5..-1]
221
+ section_data = sect
222
+ end
223
+ end
224
+ return section_data
225
+ end
226
+
227
+ def get_section_id_by_section_code(code)
228
+ get_section_data_by_code(code)["SectionId"]
229
+ end
230
+ =end
231
+ ############
232
+ ############
@@ -4,6 +4,9 @@ require 'json-schema'
4
4
  ########################
5
5
  # SEMESTER:#############
6
6
  ########################
7
+ # NOTE: These functions are supplementary to the basic +org unit+ functions
8
+ # provided by the valence API. These simply provide a little more tailored
9
+ # functionality to this particular org unit type.
7
10
 
8
11
  # Checks if the created semester data conforms to the valence api for the
9
12
  # semester JSON object. If it does conform, then nothing happens and it
@@ -0,0 +1,14 @@
1
+ require_relative "requests"
2
+
3
+ # init products to newest versions.
4
+ $le_ver = get_latest_product_version('le')
5
+ $lp_ver = get_latest_product_version('lp')
6
+ $ep_ver = get_latest_product_version('ep')
7
+ #lti, rp, LR, ext,
8
+ puts "versions set to:"
9
+ versions = {
10
+ "le_ver" => $le_ver,
11
+ "lp_ver" => $lp_ver,
12
+ "ep_ver" => $ep_ver
13
+ }
14
+ ap versions
@@ -59,11 +59,11 @@ def create_user_data(user_data)
59
59
  end
60
60
 
61
61
  # Retrieves the whoami of the user authenticated through the config file.
62
- # returns: JSON whoami response
62
+ # RETURNS: JSON whoami response
63
63
  def get_whoami
64
64
  path = "/d2l/api/lp/#{$lp_ver}/users/whoami"
65
65
  _get(path)
66
- # returns a WhoAmIUser JSON block for the current user context
66
+ # RETURNS: a WhoAmIUser JSON block for the current user context
67
67
  end
68
68
 
69
69
  # Simple get users function that assists in retrieving users by particular
@@ -193,12 +193,12 @@ end
193
193
  # known as the Identifier of this user object. Upon retrieving the user, it
194
194
  # is then returned.
195
195
  #
196
- # returns: JSON user object.
196
+ # RETURNS: JSON user object.
197
197
  def get_user_by_user_id(user_id)
198
198
  # Retrieve data for a particular user
199
199
  path = "/d2l/api/lp/#{$lp_ver}/users/#{user_id}"
200
200
  _get(path)
201
- # returns a UserData JSON block
201
+ # RETURNS: a UserData JSON block
202
202
  end
203
203
 
204
204
  # Checks whether the updated user data conforms to the valence api for the
@@ -268,21 +268,108 @@ def delete_user_data(user_id)
268
268
  puts '[+] User data deleted successfully'.green
269
269
  end
270
270
 
271
- # Retrieve a list of all the enrolled user roles the calling user can view
272
- # in an org unit
273
- def get_enrolled_roles_in_org_unit(org_unit_id)
274
- # this only lists ones viewable by the CALLING user
275
- # also, only includes roles that are enrolled in the org unit
276
- path = "/d2l/api/#{$lp_ver}/#{org_unit_id}/roles/"
271
+ ########################
272
+ # ACTIVATION:###########
273
+ ########################
274
+ # REVIEW: Retrieve a particular user’s activation settings.
275
+ # RETURNS: a UserActivationData JSON block with the user’s current activation status.
276
+ def get_user_activation_settings(user_id)
277
+ path = "/d2l/api/lp/#{$lp_ver}/users/#{user_id}/activation"
277
278
  _get(path)
278
- # returns JSON array of Role data blocks
279
+ # RETURNS: a UserActivationData JSON block with the user’s current activation status.
280
+ end
281
+
282
+ # TODO: Update a particular user’s activation settings.
283
+ # RETURNS: ?
284
+ def update_user_activation_settings(user_id, user_activation_data)
285
+ # PUT /d2l/api/lp/(version)/users/(userId)/activation
286
+ # RETURNS: ?
287
+ end
288
+
289
+ ########################
290
+ # INTEGRATIONS:#########
291
+ ########################
292
+
293
+ # NOTE: UNSTABLE!
294
+ # TODO: Link a user to a Google Apps user account.
295
+ # RETURNS: ?
296
+ def link_user_google_apps_account(google_apps_linking_item)
297
+ # POST /d2l/api/gae/(version)/linkuser
298
+ end
299
+
300
+
301
+ ########################
302
+ # NOTIFICATIONS:########
303
+ ########################
304
+
305
+ # REVIEW: Delete the subscription for messages of a particular type,
306
+ # delivered by a particular carrier.
307
+ def delete_subscription(carrier_id, message_type_id)
308
+ path = "/d2l/api/lp/#{$lp_ver}/notifications/instant/carriers/#{carrier_id}/subscriptions/#{message_type_id}"
309
+ _delete(path)
310
+ end
311
+
312
+ # Retrieve all the carrier channels for delivering notification messages.
313
+ # RETURNS: a JSON array of CarrierOutput data blocks.
314
+ def get_all_notification_carrier_channels
315
+ path = "/d2l/api/lp/#{$lp_ver}/notifications/instant/carriers/"
316
+ _get(path)
317
+ end
318
+
319
+ # Retrieve all the current subscriptions for notification messages.
320
+ # RETURNS: a JSON array of SubscriptionOutput data blocks.
321
+ def get_all_subscriptions_by_carrier(carrier_id)
322
+ path = "/d2l/api/lp/#{$lp_ver}/notifications/instant/carriers/#{carrier_id}/subscriptions/"
323
+ _get(path)
324
+ end
325
+
326
+ # Subscribe to notification messages of a particular type, delivered by a particular carrier.
327
+ def subscribe_to_carrier_notification(carrier_id, message_type_id)
328
+ path = "/d2l/api/lp/#{$lp_ver}/notifications/instant/carriers/#{carrier_id}/subscriptions/#{message_type_id}"
329
+ _put(path, {})
279
330
  end
280
331
 
332
+ ########################
333
+ # PASSWORDS:############
334
+ ########################
335
+
336
+ # REVIEW: Clear a particular user’s password.
337
+ def delete_user_password(user_id)
338
+ path = "/d2l/api/lp/#{$lp_ver}/users/#{user_id}/password"
339
+ _delete(path)
340
+ end
341
+
342
+ # REVIEW: Reset a particular user’s password.
343
+ # INPUT: nil (no payload necessary)
344
+ # NOTE: Prompts the service to send a password-reset email to the provided user.
345
+ def reset_user_password(user_id)
346
+ path = "/d2l/api/lp/#{$lp_ver}/users/#{user_id}/password"
347
+ _post(path, {})
348
+ end
349
+
350
+ # REVIEW: Update a particular user’s password.
351
+ # NOTE: 400 errors are implicitly invalid password
352
+ def update_user_password(user_id, user_password_data)
353
+ if user_password_data.is_a? String
354
+ path = "/d2l/api/lp/#{$lp_ver}/users/#{user_id}/password"
355
+ payload = {"Password" => user_password_data}
356
+ _put(path, payload)
357
+ else
358
+ raise ArgumentError, "Argument 'user_password_data' is not a String"
359
+ end
360
+ end
361
+
362
+
363
+
364
+ ########################
365
+ # ROLES:################
366
+ ########################
367
+
281
368
  # retrieve list of all known user roles
282
369
  def get_all_user_roles
283
370
  path = "/d2l/api/lp/#{$lp_ver}/roles/"
284
371
  _get(path)
285
- # returns a JSON array of Role data blocks
372
+ # RETURNS: a JSON array of Role data blocks
286
373
  end
287
374
 
288
375
  # Retrieve a particular user role
@@ -292,19 +379,66 @@ def get_user_role(role_id)
292
379
  # returns a Role JSON data block
293
380
  end
294
381
 
382
+ # Retrieve a list of all the enrolled user roles the calling user can view
383
+ # in an org unit
384
+ def get_enrolled_roles_in_org_unit(org_unit_id)
385
+ # this only lists ones viewable by the CALLING user
386
+ # also, only includes roles that are enrolled in the org unit
387
+ path = "/d2l/api/#{$lp_ver}/#{org_unit_id}/roles/"
388
+ _get(path)
389
+ # returns JSON array of Role data blocks
390
+ end
391
+
392
+ # TODO: --UNSTABLE -- Create a new role copied from an existing role.
393
+ # INPUT: deep_copy_role_id = d2lID; role_copy_data = User.role_copy_data
394
+ # RETURN: a Role JSON data block representing the newly-created copy of the role.
395
+ def create_new_role_from_existing_role(deep_copy_role_id, role_copy_data)
396
+ # POST /d2l/api/lp/(version)/roles/
397
+ end
398
+
399
+
400
+ ########################
401
+ # PROFILES:#############
402
+ ########################
403
+
404
+ # REVIEW: Remove the current user’s profile image.
405
+ def remove_current_user_profile_image
406
+ path = "/d2l/api/lp/#{$lp_ver}/profile/myProfile/image"
407
+ _delete(path)
408
+ end
409
+
410
+ # REVIEW: Remove the profile image from a particular personal profile, by Profile ID.
411
+ def remove_profile_image_by_profile_id(profile_id)
412
+ path = "/d2l/api/lp/#{$lp_ver}/profile/#{profile_id}/image"
413
+ _delete(path)
414
+ end
415
+
416
+ # REVIEW: Remove the profile image from a particular personal profile, by User ID.
417
+ def remove_profile_image_by_user_id(user_id)
418
+ path = "/d2l/api/lp/#{$lp_ver}/profile/user/#{user_id}/image"
419
+ _delete(path)
420
+ end
295
421
 
296
422
  # retrieve personal profile info for the current user context
423
+ # Returns: UserProfile JSON data block
297
424
  def get_current_user_profile
298
425
  path = "/d2l/api/lp/#{$lp_ver}/profile/myProfile"
299
426
  _get(path)
300
- # Returns UserProfile JSON data block
427
+ # Returns: UserProfile JSON data block
301
428
  end
302
429
 
303
- # retrieve personal profile info of the specified user
304
- def get_user_profile_by_user_id(user_id)
305
- path = "/d2l/api/lp/#{$lp_ver}/profile/user/#{user_id}"
430
+ # Retrieve the current user’s profile image.
431
+ # INPUT: size (integer) determines the thumbnail size
432
+ # RETURNS: This action returns a file stream containing the current user’s
433
+ # profile image. Note that the back-end service may return a
434
+ # profile image larger than your provided size.
435
+ def get_current_user_profile_image(size = 0)
436
+ path = "/d2l/api/lp/#{$lp_ver}/profile/myProfile/image"
437
+ path += "?size=#{size}" if size != 0
306
438
  _get(path)
307
- # Returns UserProfile JSON data block
439
+ # RETURNS: This action returns a file stream containing the current user’s
440
+ # profile image. Note that the back-end service may return a
441
+ # profile image larger than your provided size.
308
442
  end
309
443
 
310
444
  # retrieve a particular personal profile, by Profile ID
@@ -314,107 +448,239 @@ def get_user_profile_by_profile_id(profile_id)
314
448
  # Returns UserProfile JSON data block
315
449
  end
316
450
 
451
+ # Retrieve a particular profile image, by Profile ID.
452
+ # RETURNS: This action returns a file stream containing the current user’s
453
+ # profile image. Note that the back-end service may return a
454
+ # profile image larger than your provided size.
317
455
  def get_profile_image(profile_id, size = 0)
318
456
  path = "/d2l/api/lp/#{$lp_ver}/profile/#{profile_id}/image"
319
457
  path += "?size=#{size}" if size != 0
320
458
  _get(path)
459
+ # RETURNS: This action returns a file stream containing the current user’s
460
+ # profile image. Note that the back-end service may return a
461
+ # profile image larger than your provided size.
321
462
  end
322
463
 
323
- def get_current_user_profile_image(size = 0)
324
- path = "/d2l/api/lp/#{$lp_ver}/profile/myProfile/image"
325
- path += "?size=#{size}" if size != 0
464
+ # Retrieve a particular personal profile, by User ID.
465
+ def get_user_profile_by_user_id(user_id)
466
+ path = "/d2l/api/lp/#{$lp_ver}/profile/user/#{user_id}"
326
467
  _get(path)
468
+ # Returns UserProfile JSON data block
327
469
  end
328
470
 
471
+
472
+ # Retrieve a particular profile image, by User ID.
473
+ # RETURNS: This action returns a file stream containing the current user’s
474
+ # profile image. Note that the back-end service may return a
475
+ # profile image larger than your provided size.
329
476
  def get_user_profile_image(user_id)
330
477
  path = "/d2l/api/lp/#{$lp_ver}/profile/user/#{user_id}"
331
478
  path += "?size=#{size}" if size != 0
332
479
  _get(path)
333
- end
334
- #####Notifications
335
- def get_all_notification_carrier_channels
336
- path = "/d2l/api/lp/#{$lp_ver}/notifications/instant/carriers/"
480
+ # RETURNS: This action returns a file stream containing the current user’s
481
+ # profile image. Note that the back-end service may return a
482
+ # profile image larger than your provided size.
483
+ end
484
+
485
+ # TODO: Update the personal profile image for the current user context.
486
+ # INPUT: Provide an uploaded image file using the simple file upload process;
487
+ # the content-disposition part header for the file part should have the
488
+ # name profileImage
489
+ # http://docs.valence.desire2learn.com/basic/fileupload.html#simple-uploads
490
+ # RETURNS: ?
491
+ def update_current_user_profile_image()
492
+ # POST /d2l/api/lp/(version)/profile/myProfile/image
493
+ # RETURNS: ?
494
+ end
495
+
496
+ # TODO: Update the profile image for the identified personal profile, by Profile ID.
497
+ # INPUT: Provide an uploaded image file using the simple file upload process;
498
+ # the content-disposition part header for the file part should have the
499
+ # name profileImage
500
+ # http://docs.valence.desire2learn.com/basic/fileupload.html#simple-uploads
501
+ # RETURNS: ?
502
+ def update_profile_image_by_profile_id
503
+ # POST /d2l/api/lp/(version)/profile/(profileId)/image
504
+ # RETURNS: ?
505
+ end
506
+
507
+ # TODO: Update the profile image for the identified personal profile, by User ID.
508
+ # INPUT: Provide an uploaded image file using the simple file upload process;
509
+ # the content-disposition part header for the file part should have the
510
+ # name profileImage
511
+ # http://docs.valence.desire2learn.com/basic/fileupload.html#simple-uploads
512
+ # RETURNS: ?
513
+ def update_profile_image_by_user_id
514
+ # POST /d2l/api/lp/(version)/profile/user/(userId)/image
515
+ # RETURNS: ?
516
+ end
517
+
518
+ # TODO: Update the personal profile data for the current user context.
519
+ # NOTE: block's data will replace all user profile data
520
+ # RETURNS: a UserProfile JSON data block for the updated current user profile.
521
+ def update_current_user_profile_data(user_profile_data)
522
+ # PUT /d2l/api/lp/(version)/profile/myProfile
523
+ end
524
+
525
+ # TODO: Update a particular personal profile, by Profile ID.
526
+ # NOTE: block's data will replace all user profile data
527
+ # RETURNS: a UserProfile JSON data block for the updated personal profile.
528
+ def update_profile_by_profile_id(profile_id, user_profile_data)
529
+ # PUT /d2l/api/lp/(version)/profile/(profileId)
530
+ # NOTE: Example of User.UserProfile JSON Data Block
531
+ # { "Nickname": <string>,
532
+ # "Birthday": {
533
+ # "Month": <number>,
534
+ # "Day": <number>
535
+ # },
536
+ # "HomeTown": <string>,
537
+ # "Email": <string>,
538
+ # "HomePage": <string>,
539
+ # "HomePhone": <string>,
540
+ # "BusinessPhone": <string>,
541
+ # "MobilePhone": <string>,
542
+ # "FaxNumber": <string>,
543
+ # "Address1": <string>,
544
+ # "Address2": <string>,
545
+ # "City": <string>,
546
+ # "Province": <string>,
547
+ # "PostalCode": <string>,
548
+ # "Country": <string>,
549
+ # "Company": <string>,
550
+ # "JobTitle": <string>,
551
+ # "HighSchool": <string>,
552
+ # "University": <string>,
553
+ # "Hobbies": <string>,
554
+ # "FavMusic": <string>,
555
+ # "FavTVShows": <string>,
556
+ # "FavMovies": <string>,
557
+ # "FavBooks": <string>,
558
+ # "FavQuotations": <string>,
559
+ # "FavWebSites": <string>,
560
+ # "FutureGoals": <string>,
561
+ # "FavMemory": <string>,
562
+ # "SocialMediaUrls": [ // Array of SocialMediaUrl blocks
563
+ # {
564
+ # "Name": <string>,
565
+ # "Url": <string:URL>
566
+ # },
567
+ # { <composite:SocialMediaUrl> }, ...
568
+ # ]
569
+ # }
570
+ # NOTE: The back-end service also expects a file names "profileImage"
571
+ # RETURNS: a UserProfile JSON data block for the updated personal profile.
572
+ end
573
+
574
+ #####################################
575
+ # IMS/LIS role configuration:########
576
+ #####################################
577
+
578
+ # NOTE: UNSTABLE
579
+ # REVIEW: retrieve list of known LIS roles
580
+ def get_lis_roles(lis_urn = "")
581
+ path = "/d2l/api/lp/#{$lp_ver}/imsconfig/roles/"
582
+ path += "#{lis_urn}" if lis_urn != ""
337
583
  _get(path)
584
+ # returns array of LIS role data blocks
338
585
  end
339
586
 
340
- def get_all_subscriptions_by_carrier(carrier_id)
341
- path = "/d2l/api/lp/#{$lp_ver}/notifications/instant/carriers/#{carrier_id}/subscriptions/"
587
+ # NOTE: UNSTABLE
588
+ # REVIEW: retrieve mappings between user roles and LIS roles
589
+ def get_user_role_lis_mappings(lis_urn = "", d2lid = 0)
590
+ path = "/d2l/api/lp/#{$lp_ver}/imsconfig/map/roles/"
591
+ path += "#{lis_urn}" if lis_urn != ""
592
+ path += "#{d2lid}" if d2lid != 0
342
593
  _get(path)
594
+ # returns JSON array of LIS role mapping data blocks
343
595
  end
344
596
 
345
- def subscribe_to_carrier_notification(carrier_id, message_type_id)
346
- path = "/d2l/api/lp/#{$lp_ver}/notifications/instant/carriers/#{carrier_id}/subscriptions/#{message_type_id}"
347
- _put(path,{})
597
+ # NOTE: UNSTABLE
598
+ # REVIEW: retrieve mapping between a user role and a LIS role
599
+ def get_user_role_lis_mappings(role_id, d2lid = 0)
600
+ path = "/d2l/api/lp/#{$lp_ver}/imsconfig/map/roles/#{role_id}"
601
+ path += "#{d2lid}" if d2lid != 0
602
+ _get(path)
603
+ # returns JSON array of LIS role mapping data blocks
348
604
  end
349
605
 
350
- #####LOCALES
351
- =begin
352
- # retrieve the locale account settings for a particular user.
353
- def get_locale_account_settings(user_id)
354
- path = "/d2l/api/lp/#{$lp_ver}/accountSettings/#{user_id}/locale/"
355
- _get(path)
356
- # returns Locale JSON block
606
+ # NOTE: UNSTABLE
607
+ # TODO: --UNSTABLE-- Map a user role to a set of LIS Roles.
608
+ # input: Mappings = String array
609
+ def map_user_role_to_lis_roles(role_id, mappings)
610
+ # PUT /d2l/api/lp/(version)/imsconfig/map/roles/(roleId)
357
611
  end
358
612
 
359
- # optional parameter 'bookmark' for querying with a paging offset
360
- # Retrieve the collection of all known locales.
361
- def get_all_locales(bookmark = '')
362
- path = "/d2l/api/lp/#{$lp_ver}/locales/"
613
+
614
+ ########################
615
+ # SETTINGS:#############
616
+ ########################
617
+ # NOTE: As the settings page only has 4 functions, these functions are simply
618
+ # appended to this, the most relevant file.
619
+
620
+ # REVIEW: Retrieve the current user’s locale account settings.
621
+ def get_current_user_locale_settings
622
+ path = "/d2l/api/lp/#{$lp_ver}/accountSettings/mySettings/locale/"
363
623
  _get(path)
364
- # returns paged result set containing Locale data blocks
624
+ # RETURNS: a Locale JSON block
365
625
  end
366
626
 
367
- # Retrieve the properties for a particular locale.
368
- def get_locale_properties(locale_id)
369
- path = "/d2l/api/lp/#{$lp_ver}/locales/#{locale_id}"
627
+ # REVIEW: retrieve the locale account settings for a particular user.
628
+ def get_locale_account_settings(user_id)
629
+ path = "/d2l/api/lp/#{$lp_ver}/accountSettings/#{user_id}/locale/"
370
630
  _get(path)
371
631
  # returns Locale JSON block
372
632
  end
373
633
 
374
- def is_valid_locale_id(locale_id)
375
634
 
376
635
 
636
+ # TODO: Add schema check for update_locale conforming to the D2L update_locale
637
+ # JSON data block of form: { "LocaleId" : <D2LID>}.
638
+ def is_valid_locale_id(locale_id)
639
+
377
640
  end
378
641
 
379
- # Update the current user's locale account settings
642
+ # REVIEW: Update the current users locale account settings.
643
+ # TODO: Add schema check for update_locale
644
+ # update_locale = { "LocaleId" : <D2LID>}
380
645
  def update_current_user_locale_account_settings(update_locale)
381
646
  payload = {"LocaleId" => 0}.merge!(update_locale)
382
647
  path = "/d2l/api/lp/#{$lp_ver}/accountSettings/mysettings/locale/"
383
648
  # requires UpdateSettings JSON data block
649
+ # update_locale = { "LocaleId" : <D2LID>}
384
650
  _put(path, payload)
385
651
  end
386
652
 
387
- def update_user_locale_account_settings(user_id)
653
+ # REVIEW: Update the locale account settings for a particular user.
654
+ # TODO: Add schema check for update_locale
655
+ # update_locale = { "LocaleId" : <D2LID>}
656
+ def update_user_locale_account_settings(user_id, update_locale)
388
657
  payload = {"LocaleId" => 0}.merge!(update_locale)
389
658
  path = "/d2l/api/lp/#{$lp_ver}/accountSettings/#{user_id}/locale/"
390
659
  # requires UpdateSettings JSON data block
660
+ # update_locale = { "LocaleId" : <D2LID>}
391
661
  _put(path, payload)
392
662
  end
393
663
 
664
+ ########################
665
+ # LOCALE:###############
666
+ ########################
667
+ # NOTE: As the locale page only has only 2 functions, these functions are simply
668
+ # appended to this, the most relevant file.
394
669
 
395
- ######IMS/LIS role configuration
396
- # retrieve list of known LIS roles
397
- def get_lis_roles(lis_urn = "")
398
- path = "/d2l/api/lp/#{$lp_ver}/imsconfig/roles/"
399
- path += "#{lis_urn}" if lis_urn != ""
400
- _get(path)
401
- # returns array of LIS role data blocks
402
- end
403
-
404
- # retrieve mappings between user roles and LIS roles
405
- def get_user_role_lis_mappings(lis_urn = "", d2lid = 0)
406
- path = "/d2l/api/lp/#{$lp_ver}/imsconfig/map/roles/"
407
- path += "#{lis_urn}" if lis_urn != ""
408
- path += "#{d2lid}" if d2lid != 0
670
+ # NOTE: UNSTABLE
671
+ # optional parameter 'bookmark' for querying with a paging offset
672
+ # Retrieve the collection of all known locales.
673
+ def get_all_locales(bookmark = '')
674
+ path = "/d2l/api/lp/#{$lp_ver}/locales/"
675
+ path += "?bookmark=#{bookmark}" if bookmark != ''
409
676
  _get(path)
410
- # returns JSON array of LIS role mapping data blocks
677
+ # returns paged result set containing Locale data blocks
411
678
  end
412
679
 
413
- # retrieve mapping between a user role and a LIS role
414
- def get_user_role_lis_mappings(role_id, d2lid = 0)
415
- path = "/d2l/api/lp/#{$lp_ver}/imsconfig/map/roles/#{role_id}"
416
- path += "#{d2lid}" if d2lid != 0
680
+ # NOTE: UNSTABLE
681
+ # Retrieve the properties for a particular locale.
682
+ def get_locale_properties(locale_id)
683
+ path = "/d2l/api/lp/#{$lp_ver}/locales/#{locale_id}"
417
684
  _get(path)
418
- # returns JSON array of LIS role mapping data blocks
685
+ # returns Locale JSON block
419
686
  end
420
- =end