clever 2.3.1 → 3.2.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 +13 -9
- data/lib/clever/client.rb +18 -2
- data/lib/clever/types/district_admin.rb +20 -0
- data/lib/clever/types/school_admin.rb +20 -0
- data/lib/clever/types/student.rb +7 -5
- data/lib/clever/types/teacher.rb +24 -9
- data/lib/clever/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 86d6af37efac719fa831d86a65862a402eb5af65
|
4
|
+
data.tar.gz: 46c1a1e4142338704353295934719e109b09e28f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e21034624a92171120aa45364bbdc347696c5a65377907703c1297ddf94ee06638884f9d8ba02b2ff2bb133e40947135322c3391207448a114769c483b6e6615
|
7
|
+
data.tar.gz: 41d92685a37b57957ea89584ea60daa52950dfde939529d32daab129352c2e4f3a43ca6caa09debbbb8e71842b0cc6efbfb4f787a99c32cbe460ced858097197
|
data/Gemfile.lock
CHANGED
data/lib/clever.rb
CHANGED
@@ -17,19 +17,23 @@ 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/district_admin'
|
21
|
+
require 'clever/types/school_admin'
|
20
22
|
require 'clever/types/term'
|
21
23
|
require 'clever/types/token'
|
22
24
|
|
23
25
|
module Clever
|
24
|
-
API_URL
|
25
|
-
TOKENS_ENDPOINT
|
26
|
-
STUDENTS_ENDPOINT
|
27
|
-
COURSES_ENDPOINT
|
28
|
-
SECTIONS_ENDPOINT
|
29
|
-
TEACHERS_ENDPOINT
|
30
|
-
|
31
|
-
|
32
|
-
|
26
|
+
API_URL = 'https://api.clever.com/v3.0'
|
27
|
+
TOKENS_ENDPOINT = 'https://clever.com/oauth/tokens?owner_type=district'
|
28
|
+
STUDENTS_ENDPOINT = '/v3.0/users?role=student'
|
29
|
+
COURSES_ENDPOINT = '/v3.0/courses'
|
30
|
+
SECTIONS_ENDPOINT = '/v3.0/sections'
|
31
|
+
TEACHERS_ENDPOINT = '/v3.0/users?role=teacher'
|
32
|
+
DISTRICT_ADMINS_ENDPOINT = '/v3.0/users?role=district_admin'
|
33
|
+
SCHOOL_ADMINS_ENDPOINT = '/v3.0/users?role=staff'
|
34
|
+
EVENTS_ENDPOINT = '/v1.2/events'
|
35
|
+
TERMS_ENDPOINT = '/v3.0/terms'
|
36
|
+
GRADES_ENDPOINT = 'https://grades-api.beta.clever.com/v1/grade'
|
33
37
|
|
34
38
|
class DistrictNotFound < StandardError; end
|
35
39
|
class ConnectionError < StandardError; end
|
data/lib/clever/client.rb
CHANGED
@@ -8,8 +8,8 @@ module Clever
|
|
8
8
|
attr_reader :api_url, :tokens_endpoint
|
9
9
|
|
10
10
|
def initialize
|
11
|
-
@api_url
|
12
|
-
@tokens_endpoint
|
11
|
+
@api_url = API_URL
|
12
|
+
@tokens_endpoint = TOKENS_ENDPOINT
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.configure
|
@@ -69,6 +69,22 @@ module Clever
|
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
|
+
def admins(record_uids = [])
|
73
|
+
authenticate
|
74
|
+
|
75
|
+
district_admins = Paginator.fetch(connection, Clever::DISTRICT_ADMINS_ENDPOINT,
|
76
|
+
:get, Types::DistrictAdmin, client: self).force
|
77
|
+
|
78
|
+
school_admins = Paginator.fetch(connection, Clever::SCHOOL_ADMINS_ENDPOINT,
|
79
|
+
:get, Types::SchoolAdmin, client: self).force
|
80
|
+
|
81
|
+
admins = (district_admins + school_admins).uniq(&:uid)
|
82
|
+
|
83
|
+
return admins if record_uids.empty?
|
84
|
+
|
85
|
+
admins.select { |record| record_uids.to_set.include?(record.uid) }
|
86
|
+
end
|
87
|
+
|
72
88
|
# discard params to make the API behave the same as the one roster gem
|
73
89
|
def classrooms(*)
|
74
90
|
authenticate
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Clever
|
4
|
+
module Types
|
5
|
+
class DistrictAdmin < 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
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Clever
|
4
|
+
module Types
|
5
|
+
class SchoolAdmin < Teacher
|
6
|
+
def initialize(attributes = {}, *, client: nil)
|
7
|
+
@district_username = attributes.dig('roles', 'staff', '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', 'staff', 'legacy_id')
|
12
|
+
@provider = 'clever'
|
13
|
+
@sis_id = attributes.dig('roles', 'staff', '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/student.rb
CHANGED
@@ -6,17 +6,19 @@ module Clever
|
|
6
6
|
attr_reader :uid,
|
7
7
|
:first_name,
|
8
8
|
:last_name,
|
9
|
-
:provider
|
9
|
+
:provider,
|
10
|
+
:legacy_id
|
10
11
|
|
11
12
|
def initialize(attributes = {}, client: nil)
|
12
|
-
@
|
13
|
+
@district_username = attributes.dig('credentials', 'district_username')
|
14
|
+
@email = attributes['email']
|
13
15
|
@first_name = attributes['name']['first']
|
14
16
|
@last_name = attributes['name']['last']
|
15
|
-
@
|
17
|
+
@legacy_id = attributes.dig('roles', 'student', 'legacy_id')
|
18
|
+
@provider = 'clever'
|
16
19
|
@sis_id = attributes['sis_id']
|
17
|
-
@
|
20
|
+
@uid = attributes['id']
|
18
21
|
@username = username(client)
|
19
|
-
@provider = 'clever'
|
20
22
|
end
|
21
23
|
|
22
24
|
def username(client = nil)
|
data/lib/clever/types/teacher.rb
CHANGED
@@ -7,17 +7,21 @@ module Clever
|
|
7
7
|
:email,
|
8
8
|
:first_name,
|
9
9
|
:last_name,
|
10
|
-
:provider
|
10
|
+
:provider,
|
11
|
+
:legacy_id,
|
12
|
+
:role
|
11
13
|
|
12
14
|
def initialize(attributes = {}, *, client: nil)
|
13
|
-
@
|
14
|
-
@email
|
15
|
-
@first_name
|
16
|
-
@last_name
|
17
|
-
@
|
18
|
-
@
|
19
|
-
@
|
20
|
-
@
|
15
|
+
@district_username = attributes.dig('roles', 'teacher', 'credentials', 'district_username')
|
16
|
+
@email = attributes['email']
|
17
|
+
@first_name = attributes['name']['first']
|
18
|
+
@last_name = attributes['name']['last']
|
19
|
+
@legacy_id = attributes.dig('roles', 'teacher', 'legacy_id')
|
20
|
+
@provider = 'clever'
|
21
|
+
@sis_id = attributes.dig('roles', 'teacher', 'credentials', 'sis_id')
|
22
|
+
@uid = attributes['id']
|
23
|
+
@username = username(client)
|
24
|
+
@role = 'teacher'
|
21
25
|
end
|
22
26
|
|
23
27
|
def username(client = nil)
|
@@ -26,6 +30,17 @@ module Clever
|
|
26
30
|
@username ||= presence(username_from(username_source))
|
27
31
|
end
|
28
32
|
|
33
|
+
def to_h
|
34
|
+
{
|
35
|
+
uid: @uid,
|
36
|
+
email: @email,
|
37
|
+
first_name: @first_name,
|
38
|
+
last_name: @last_name,
|
39
|
+
username: @username,
|
40
|
+
provider: @provider
|
41
|
+
}
|
42
|
+
end
|
43
|
+
|
29
44
|
private
|
30
45
|
|
31
46
|
def username_from(username_source)
|
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: 2.
|
4
|
+
version: 3.2.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:
|
11
|
+
date: 2021-06-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -195,8 +195,10 @@ files:
|
|
195
195
|
- lib/clever/types/base.rb
|
196
196
|
- lib/clever/types/classroom.rb
|
197
197
|
- lib/clever/types/course.rb
|
198
|
+
- lib/clever/types/district_admin.rb
|
198
199
|
- lib/clever/types/enrollment.rb
|
199
200
|
- lib/clever/types/event.rb
|
201
|
+
- lib/clever/types/school_admin.rb
|
200
202
|
- lib/clever/types/section.rb
|
201
203
|
- lib/clever/types/student.rb
|
202
204
|
- lib/clever/types/teacher.rb
|