strongmind-platform-sdk 3.19.35 → 3.19.36
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/platform_sdk/canvas_api/client.rb +50 -0
- data/lib/platform_sdk/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a06afbab9954bea9a3a155a4088f90347aff9ee86bb833bb73424bb6f3e679d9
|
4
|
+
data.tar.gz: 485c42c5319d710f1bdff3bb488a8e7bfa746a0179786037d9398736d129c59c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84b6330f496aa1a05b1445a52de0eb257828b4cc42db271611ecc28ab1faf01b30300a57938095cee0daa089b38b1752fecc6e28a1f1fdbe13111caaaf596094
|
7
|
+
data.tar.gz: b9da1277238e4581f5f863009f1dd6740a6b3b738fd0c2ccb679593b9e4345275dc51fe3c285e2651ac2f8b86a39b4dd1b0f5891ffdf58b6f5968b5356aa8994
|
data/Gemfile.lock
CHANGED
@@ -423,6 +423,56 @@ module PlatformSdk
|
|
423
423
|
end
|
424
424
|
end
|
425
425
|
|
426
|
+
# @param course_id [Integer]
|
427
|
+
# @param module_id [Integer]
|
428
|
+
# @param body [Hash]
|
429
|
+
# @option body [String] 'module_item[title]' The name of the module_item and associated content
|
430
|
+
# @option body [String] 'module_item[type]' Allowed: ExternalUrl, ExternalTool
|
431
|
+
# @option body [Integer] 'module_item[content_id]' The id of the content to link to the module_item. Required
|
432
|
+
# @option body [Integer] 'module_item[position]' The position of this item in the module (1-based). Default 0
|
433
|
+
# @option body [String] 'module_item[external_url]' External url that the item points to. Required for: ExternalUrl, ExternalTool.
|
434
|
+
# @option body [String] 'module_item[completion_requirement][type]' Allowed: must_view, must_contribute, must_submit, must_mark_done.
|
435
|
+
def post_module_item(course_id:, module_id:, body:)
|
436
|
+
uri = "/api/v1/courses/#{course_id}/modules/#{module_id}/items"
|
437
|
+
response = @connection.post(uri) do |req|
|
438
|
+
req.headers['Content-Type'] = 'application/x-www-form-urlencoded'
|
439
|
+
req.body = body
|
440
|
+
end
|
441
|
+
handle_rate_limiting response
|
442
|
+
result = MultiJson.load response.body, symbolize_keys: true
|
443
|
+
if success?(response.status)
|
444
|
+
result
|
445
|
+
else
|
446
|
+
error_messages = String.new
|
447
|
+
result[:errors]&.each do |error|
|
448
|
+
error_messages << "#{error[:message]} "
|
449
|
+
end
|
450
|
+
raise "Error creating module item: #{error_messages}"
|
451
|
+
end
|
452
|
+
end
|
453
|
+
|
454
|
+
# @param course_id [Integer]
|
455
|
+
# @param module_id [Integer]
|
456
|
+
# @param module_item_id [Integer]
|
457
|
+
def put_publish_module_item(course_id:, module_id:, module_item_id:)
|
458
|
+
uri = "/api/v1/courses/#{course_id}/modules/#{module_id}/items/#{module_item_id}"
|
459
|
+
response = @connection.put(uri) do |req|
|
460
|
+
req.headers['Content-Type'] = 'application/x-www-form-urlencoded'
|
461
|
+
req.body = { 'module_item[published]' => true }
|
462
|
+
end
|
463
|
+
handle_rate_limiting response
|
464
|
+
result = MultiJson.load response.body, symbolize_keys: true
|
465
|
+
if success?(response.status)
|
466
|
+
result
|
467
|
+
else
|
468
|
+
error_messages = String.new
|
469
|
+
result[:errors]&.each do |error|
|
470
|
+
error_messages << "#{error[:message]} "
|
471
|
+
end
|
472
|
+
raise "Error publishing module item: #{error_messages}"
|
473
|
+
end
|
474
|
+
end
|
475
|
+
|
426
476
|
private
|
427
477
|
|
428
478
|
# @param headers [Faraday::Utils::Headers]
|
data/lib/platform_sdk/version.rb
CHANGED