oneroster 2.3.6 → 2.3.10

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: 12d6aa35d7eac60a9e611302845be1ed8072e0dca2bedd11282e6bcc23cc1dfc
4
- data.tar.gz: af958aebb8a105f98eb17ab33a42cd065ced816917a76245591f01634a3909cd
3
+ metadata.gz: 231447994bb3bfc7fbb87334a6888270cbb99ef0e1b1a23438411a30ae7f4085
4
+ data.tar.gz: c03f5c959ffc3d5244bc82cbc8f969617443561efd0fdbeb0f6e04f4f14875de
5
5
  SHA512:
6
- metadata.gz: 9d297d5100333fefe6749270f6e44620ad38b0dde3ae3cc399d73aa51c4c933eb9a87796262a0f6c93844dd8c71451f60964ac31a3ffff02734dc4c82287277e
7
- data.tar.gz: 45d8e0c74996efe2b1e75de72a9ba57a6282ebaaf315a5bf274067a82614b935124c0aa02b9b0b0c581f53e7b2956c330cdfecb4687442e76a6969ec2e596469
6
+ metadata.gz: 02a8a15a2a483fb1dace9bfca0aa004201f91feed8fa2cff442d079333fb016b11656ab27e6ff814f0858bafaadc53cc1dc6f2656c5f47c36fe74d2dd36a68e6
7
+ data.tar.gz: a89ceb563113c819edc848960b761dfc8ae055da5fa69236be84e0d364a238d2b46b9365dae78f2bc26ba17531a2375718b9160c04ffadc38a6819501238c947
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- oneroster (2.3.6)
4
+ oneroster (2.3.10)
5
5
  dry-inflector
6
6
  faraday
7
7
  faraday_middleware
@@ -4,7 +4,7 @@ module OneRoster
4
4
  class Client
5
5
  attr_accessor :app_id, :app_token, :api_url, :token_url, :roster_app,
6
6
  :app_secret, :logger, :vendor_key,
7
- :username_source, :oauth_strategy, :staff_username_source
7
+ :username_source, :oauth_strategy, :staff_username_source, :token_content_type
8
8
 
9
9
  attr_reader :authenticated
10
10
 
@@ -36,6 +36,17 @@ module OneRoster
36
36
  end
37
37
  end
38
38
 
39
+ def admins(record_uids = [])
40
+ authenticate
41
+
42
+ records = Paginator.fetch(connection, ADMINS_ENDPOINT, :get, Admin, client: self).force
43
+
44
+ return records if record_uids.empty?
45
+
46
+ record_uids_set = record_uids.to_set
47
+ records.select { |record| record_uids_set.include?(record.uid) }
48
+ end
49
+
39
50
  def classrooms(course_codes = [])
40
51
  authenticate
41
52
 
@@ -134,9 +145,9 @@ module OneRoster
134
145
  scope: 'https://purl.imsglobal.org/spec/or/v1p1/scope/roster-core.readonly' }
135
146
 
136
147
  if roster_app == 'infinite_campus'
137
- connection.execute(url, :post, credential_params)
148
+ connection.execute(url, :post, credential_params, nil, token_content_type)
138
149
  elsif roster_app == 'synergy'
139
- connection.execute(url, :post, nil, credential_params)
150
+ connection.execute(url, :post, nil, credential_params, token_content_type)
140
151
  else
141
152
  connection.execute(url, :post)
142
153
  end
@@ -10,8 +10,8 @@ module OneRoster
10
10
  @oauth_strategy = oauth_strategy
11
11
  end
12
12
 
13
- def execute(path, method = :get, params = nil, body = nil)
14
- Response.new(raw_request(path, method, params, body))
13
+ def execute(path, method = :get, params = nil, body = nil, content_type = nil)
14
+ Response.new(raw_request(path, method, params, body, content_type))
15
15
  end
16
16
 
17
17
  def set_auth_headers(token, cookie)
@@ -37,31 +37,37 @@ module OneRoster
37
37
 
38
38
  private
39
39
 
40
- def raw_request(path, method, params, body)
40
+ def raw_request(path, method, params, body, content_type = nil)
41
41
  p "request #{path} #{params}"
42
42
 
43
43
  connection.public_send(method) do |request|
44
44
  request.options.open_timeout = OPEN_TIMEOUT
45
45
  request.options.timeout = TIMEOUT
46
46
  request.url path, params
47
- request.headers['Content-Type'] = content_type
47
+ request.headers['Content-Type'] = content_type || set_content_type
48
48
  request.headers['Cookie'] = @cookie
49
- request.body = render_body(body)
49
+ request.body = render_body(body, content_type)
50
50
  end
51
51
  end
52
52
 
53
- def content_type
53
+ def set_content_type
54
54
  return 'application/x-www-form-urlencoded' if @client.roster_app == 'synergy'
55
55
 
56
56
  'application/json'
57
57
  end
58
58
 
59
- def render_body(body)
60
- return URI.encode_www_form(body) if !body.nil? && @client.roster_app == 'synergy'
59
+ def render_body(body, content_type)
60
+ return URI.encode_www_form(body) if should_encode_body?(body, content_type)
61
61
 
62
62
  body
63
63
  end
64
64
 
65
+ def should_encode_body?(body, content_type)
66
+ return false if body.nil?
67
+
68
+ @client.roster_app == 'synergy' || content_type == 'application/x-www-form-urlencoded'
69
+ end
70
+
65
71
  def oauth_connection
66
72
  Faraday.new(@client.api_url) do |connection|
67
73
  connection.request :oauth,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OneRoster
4
- VERSION = '2.3.6'
4
+ VERSION = '2.3.10'
5
5
  end
data/lib/one_roster.rb CHANGED
@@ -29,17 +29,19 @@ module OneRoster
29
29
 
30
30
  STUDENTS_ENDPOINT = 'ims/oneroster/v1p1/students'
31
31
  TEACHERS_ENDPOINT = 'ims/oneroster/v1p1/teachers'
32
+ ADMINS_ENDPOINT = "ims/oneroster/v1p1/users?filter=role='administrator'"
32
33
  COURSES_ENDPOINT = 'ims/oneroster/v1p1/courses'
33
34
  CLASSES_ENDPOINT = 'ims/oneroster/v1p1/classes'
34
35
  ENROLLMENTS_ENDPOINT = 'ims/oneroster/v1p1/enrollments'
35
36
  ACADEMIC_SESSIONS_ENDPOINT = 'ims/oneroster/v1p1/academicSessions'
36
37
 
37
38
  RESPONSE_TYPE_MAP = {
38
- 'teachers' => 'users',
39
- 'academicSessions' => 'academicSessions',
40
- 'students' => 'users',
41
- 'courses' => 'courses',
42
- 'classes' => 'classes',
43
- 'enrollments' => 'enrollments'
39
+ 'users' => 'users',
40
+ 'teachers' => 'users',
41
+ 'students' => 'users',
42
+ 'academicSessions' => 'academicSessions',
43
+ 'courses' => 'courses',
44
+ 'classes' => 'classes',
45
+ 'enrollments' => 'enrollments'
44
46
  }.freeze
45
47
  end
@@ -0,0 +1,16 @@
1
+ module OneRoster
2
+ module Types
3
+ class Admin < Teacher
4
+ def initialize(attributes = {}, *, client: nil)
5
+ @uid = attributes['sourcedId']
6
+ @email = attributes['email']
7
+ @first_name = attributes['givenName']
8
+ @last_name = attributes['familyName']
9
+ @api_username = attributes['username']
10
+ @username = username(client)
11
+ @provider = 'oneroster'
12
+ @role = 'admin'
13
+ end
14
+ end
15
+ end
16
+ end
data/lib/types/teacher.rb CHANGED
@@ -17,6 +17,7 @@ module OneRoster
17
17
  @api_username = attributes['username']
18
18
  @username = username(client)
19
19
  @provider = 'oneroster'
20
+ @role = 'teacher'
20
21
  end
21
22
 
22
23
  def username(client = nil)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oneroster
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.6
4
+ version: 2.3.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Julius
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-08-28 00:00:00.000000000 Z
11
+ date: 2023-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -235,6 +235,7 @@ files:
235
235
  - lib/one_roster/paginator.rb
236
236
  - lib/one_roster/response.rb
237
237
  - lib/one_roster/version.rb
238
+ - lib/types/admin.rb
238
239
  - lib/types/application.rb
239
240
  - lib/types/base.rb
240
241
  - lib/types/class.rb