strongmind-platform-sdk 3.19.34 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3d2b3880d5a6f1de5a449454d2c4277e1ac98a49280e22f49981e2d444853806
4
- data.tar.gz: d1b7b96c9927352eb25cecebb5a3da178e8a9e445f9f5309916b7d44b57afc5e
3
+ metadata.gz: a06afbab9954bea9a3a155a4088f90347aff9ee86bb833bb73424bb6f3e679d9
4
+ data.tar.gz: 485c42c5319d710f1bdff3bb488a8e7bfa746a0179786037d9398736d129c59c
5
5
  SHA512:
6
- metadata.gz: b267771ba72e4398202d97879059244e9a5e2c4b25ad56c69575f06191b3360cff7871821e8125d552ca8502b0aa7fc31a59a24a4a8007c0ebfce4e5cb739eef
7
- data.tar.gz: 923a3c3a152f421da844de81df80ad96bc7db261669d379d4a01f4ba5b28bdb3ae7dfd648e0c68a4272ea14e81e387211339f6ab7ae3f9dabb8c266ddbcc6fdd
6
+ metadata.gz: 84b6330f496aa1a05b1445a52de0eb257828b4cc42db271611ecc28ab1faf01b30300a57938095cee0daa089b38b1752fecc6e28a1f1fdbe13111caaaf596094
7
+ data.tar.gz: b9da1277238e4581f5f863009f1dd6740a6b3b738fd0c2ccb679593b9e4345275dc51fe3c285e2651ac2f8b86a39b4dd1b0f5891ffdf58b6f5968b5356aa8994
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- strongmind-platform-sdk (3.19.34)
4
+ strongmind-platform-sdk (3.19.36)
5
5
  activesupport (~> 7.1)
6
6
  asset_sync
7
7
  aws-sdk-secretsmanager (~> 1.66)
@@ -8,7 +8,7 @@ module PlatformSdk
8
8
  module CanvasApiWrapper
9
9
  # DataPipeline::Client
10
10
  class Client
11
- attr_reader :host, :token, :connection, :multipart_connection
11
+ attr_reader :host, :token, :connection
12
12
 
13
13
  PAGE_SIZE = 10
14
14
 
@@ -18,10 +18,6 @@ module PlatformSdk
18
18
  @host = "https://#{domain}"
19
19
  @token = token
20
20
  @connection = Faraday.new(url: host, headers: { 'Authorization' => "Bearer #{token}" })
21
- @multipart_connection = Faraday.new(url: host, headers: { 'Authorization' => "Bearer #{token}" }) do |f|
22
- f.request :multipart
23
- f.adapter :net_http
24
- end
25
21
  end
26
22
 
27
23
  # @param course_id [Integer]
@@ -410,7 +406,7 @@ module PlatformSdk
410
406
  # @note prerequisite_ids should be a valid module_id, sending and empty array removes all prerequisites.
411
407
  def put_module_prerequesites(course_id:, module_id:, prerequisite_ids:)
412
408
  uri = "/api/v1/courses/#{course_id}/modules/#{module_id}"
413
- response = @multipart_connection.put(uri) do |req|
409
+ response = @connection.put(uri) do |req|
414
410
  req.headers['Content-Type'] = 'application/x-www-form-urlencoded'
415
411
  req.body = { 'module[prerequisite_module_ids]' => prerequisite_ids }
416
412
  end
@@ -427,6 +423,56 @@ module PlatformSdk
427
423
  end
428
424
  end
429
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
+
430
476
  private
431
477
 
432
478
  # @param headers [Faraday::Utils::Headers]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PlatformSdk
4
- VERSION = '3.19.34'
4
+ VERSION = '3.19.36'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: strongmind-platform-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.19.34
4
+ version: 3.19.36
5
5
  platform: ruby
6
6
  authors:
7
7
  - Platform Team
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-09-09 00:00:00.000000000 Z
11
+ date: 2024-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday