clever 3.0.0 → 3.1.0
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/clever.rb +3 -1
- data/lib/clever/client.rb +14 -1
- data/lib/clever/types/admin.rb +20 -0
- data/lib/clever/types/teacher.rb +5 -3
- data/lib/clever/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77dbd6fdbbf2b13bdf7d7011c19f03d90db8ab4e
|
4
|
+
data.tar.gz: c98d3ea989e3c3cdfd0bd8114a412965c232c586
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36c9a1621dedd554ff8959ec6f4477baa48a5832dde56fd4d64201fdb5bca3d8b02d502f443beff52978908164e9286b4897cc5aa546cf5b4f153764a381cf5e
|
7
|
+
data.tar.gz: 8de9b79585e796b400544747294ddbd4fd23e1688df9875497270004b80c988d6745147556ca23eb70c0b729c5c85f5a7d143b131ed173779220cd8c9c03810d
|
data/Gemfile.lock
CHANGED
data/lib/clever.rb
CHANGED
@@ -17,6 +17,7 @@ require 'clever/types/event'
|
|
17
17
|
require 'clever/types/student'
|
18
18
|
require 'clever/types/section'
|
19
19
|
require 'clever/types/teacher'
|
20
|
+
require 'clever/types/admin'
|
20
21
|
require 'clever/types/term'
|
21
22
|
require 'clever/types/token'
|
22
23
|
|
@@ -26,7 +27,8 @@ module Clever
|
|
26
27
|
STUDENTS_ENDPOINT = '/v3.0/users?role=student'
|
27
28
|
COURSES_ENDPOINT = '/v3.0/courses'
|
28
29
|
SECTIONS_ENDPOINT = '/v3.0/sections'
|
29
|
-
TEACHERS_ENDPOINT = '/v3.0/users'
|
30
|
+
TEACHERS_ENDPOINT = '/v3.0/users?role=teacher'
|
31
|
+
ADMINS_ENDPOINT = '/v3.0/users?role=district_admin'
|
30
32
|
EVENTS_ENDPOINT = '/v1.2/events'
|
31
33
|
TERMS_ENDPOINT = '/v3.0/terms'
|
32
34
|
GRADES_ENDPOINT = 'https://grades-api.beta.clever.com/v1/grade'
|
data/lib/clever/client.rb
CHANGED
@@ -54,7 +54,7 @@ module Clever
|
|
54
54
|
Paginator.fetch(connection, endpoint, :get, Types::Event, client: self).force
|
55
55
|
end
|
56
56
|
|
57
|
-
%i(students courses
|
57
|
+
%i(students courses sections terms).each do |record_type|
|
58
58
|
define_method(record_type) do |record_uids = []|
|
59
59
|
authenticate
|
60
60
|
|
@@ -69,6 +69,19 @@ module Clever
|
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
|
+
def teachers(record_uids = [])
|
73
|
+
authenticate
|
74
|
+
|
75
|
+
teachers = Paginator.fetch(connection, Clever::TEACHERS_ENDPOINT, :get, Types::Teacher, client: self).force
|
76
|
+
admins = Paginator.fetch(connection, Clever::ADMINS_ENDPOINT, :get, Types::Admin, client: self).force
|
77
|
+
|
78
|
+
records = (admins + teachers).uniq(&:uid)
|
79
|
+
|
80
|
+
return records if record_uids.empty?
|
81
|
+
|
82
|
+
records.select { |record| record_uids.to_set.include?(record.uid) }
|
83
|
+
end
|
84
|
+
|
72
85
|
# discard params to make the API behave the same as the one roster gem
|
73
86
|
def classrooms(*)
|
74
87
|
authenticate
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Clever
|
4
|
+
module Types
|
5
|
+
class Admin < Teacher
|
6
|
+
def initialize(attributes = {}, *, client: nil)
|
7
|
+
@district_username = attributes.dig('roles', 'district_admin', 'credentials', 'district_username')
|
8
|
+
@email = attributes['email']
|
9
|
+
@first_name = attributes['name']['first']
|
10
|
+
@last_name = attributes['name']['last']
|
11
|
+
@legacy_id = attributes.dig('roles', 'district_admin', 'legacy_id')
|
12
|
+
@provider = 'clever'
|
13
|
+
@sis_id = attributes.dig('roles', 'district_admin', 'credentials', 'sis_id')
|
14
|
+
@uid = attributes['id']
|
15
|
+
@username = username(client)
|
16
|
+
@role = 'admin'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/clever/types/teacher.rb
CHANGED
@@ -8,18 +8,20 @@ module Clever
|
|
8
8
|
:first_name,
|
9
9
|
:last_name,
|
10
10
|
:provider,
|
11
|
-
:legacy_id
|
11
|
+
:legacy_id,
|
12
|
+
:role
|
12
13
|
|
13
14
|
def initialize(attributes = {}, *, client: nil)
|
14
|
-
@district_username = attributes.dig('credentials', 'district_username')
|
15
|
+
@district_username = attributes.dig('roles', 'teacher', 'credentials', 'district_username')
|
15
16
|
@email = attributes['email']
|
16
17
|
@first_name = attributes['name']['first']
|
17
18
|
@last_name = attributes['name']['last']
|
18
19
|
@legacy_id = attributes.dig('roles', 'teacher', 'legacy_id')
|
19
20
|
@provider = 'clever'
|
20
|
-
@sis_id = attributes
|
21
|
+
@sis_id = attributes.dig('roles', 'teacher', 'credentials', 'sis_id')
|
21
22
|
@uid = attributes['id']
|
22
23
|
@username = username(client)
|
24
|
+
@role = 'teacher'
|
23
25
|
end
|
24
26
|
|
25
27
|
def username(client = nil)
|
data/lib/clever/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clever
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Julius
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-06-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -192,6 +192,7 @@ files:
|
|
192
192
|
- lib/clever/connection.rb
|
193
193
|
- lib/clever/paginator.rb
|
194
194
|
- lib/clever/response.rb
|
195
|
+
- lib/clever/types/admin.rb
|
195
196
|
- lib/clever/types/base.rb
|
196
197
|
- lib/clever/types/classroom.rb
|
197
198
|
- lib/clever/types/course.rb
|