clever 3.1.1 → 3.2.3
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/.circleci/config.yml +1 -1
- data/Gemfile.lock +1 -1
- data/lib/clever.rb +15 -11
- data/lib/clever/client.rb +36 -4
- data/lib/clever/types/{admin.rb → district_admin.rb} +2 -2
- data/lib/clever/types/school_admin.rb +20 -0
- data/lib/clever/types/student.rb +1 -1
- data/lib/clever/types/teacher.rb +3 -2
- data/lib/clever/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6694d0cb1936ab84956d227272a9539ecc6a5791
|
4
|
+
data.tar.gz: a23ad0110f1459719445ac685af838c42b438ebc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab3e3447b9c05aaf6758e14ae0ce6e533a559fdac407c29cc548fc5acfca6ad05c719810a857b265514e5a4052a4a96abc7d0ac2b6f51b9159c615a1c50a816a
|
7
|
+
data.tar.gz: 74e9b01f178087d04f568bc79b667441439ae809e19697c7f78ba9518cc606f66b003f7f4574785cb458f24deac94b0765f81193229e6087143b3d2c559c2b7f
|
data/.circleci/config.yml
CHANGED
@@ -22,7 +22,7 @@ install_dependencies: &install_dependencies
|
|
22
22
|
command: |
|
23
23
|
echo 'export BUNDLER_VERSION=$(cat Gemfile.lock | tail -1 | tr -d " ")' >> $BASH_ENV
|
24
24
|
source $BASH_ENV
|
25
|
-
gem install bundler
|
25
|
+
gem install bundler -v '2.1.4'
|
26
26
|
bundle install --jobs=4 --retry=3 --path vendor/bundle
|
27
27
|
|
28
28
|
save_ruby_cache: &save_ruby_cache
|
data/Gemfile.lock
CHANGED
data/lib/clever.rb
CHANGED
@@ -17,21 +17,25 @@ 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/
|
20
|
+
require 'clever/types/district_admin'
|
21
|
+
require 'clever/types/school_admin'
|
21
22
|
require 'clever/types/term'
|
22
23
|
require 'clever/types/token'
|
23
24
|
|
24
25
|
module Clever
|
25
|
-
API_URL
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
26
|
+
API_URL = 'https://api.clever.com/v3.0'
|
27
|
+
ME_ENDPOINT = '/v3.0/me'
|
28
|
+
USER_TOKEN_ENDPOINT = 'https://clever.com/oauth/tokens'
|
29
|
+
TOKENS_ENDPOINT = 'https://clever.com/oauth/tokens?owner_type=district'
|
30
|
+
STUDENTS_ENDPOINT = '/v3.0/users?role=student'
|
31
|
+
COURSES_ENDPOINT = '/v3.0/courses'
|
32
|
+
SECTIONS_ENDPOINT = '/v3.0/sections'
|
33
|
+
TEACHERS_ENDPOINT = '/v3.0/users?role=teacher'
|
34
|
+
DISTRICT_ADMINS_ENDPOINT = '/v3.0/users?role=district_admin'
|
35
|
+
SCHOOL_ADMINS_ENDPOINT = '/v3.0/users?role=staff'
|
36
|
+
EVENTS_ENDPOINT = '/v1.2/events'
|
37
|
+
TERMS_ENDPOINT = '/v3.0/terms'
|
38
|
+
GRADES_ENDPOINT = 'https://grades-api.beta.clever.com/v1/grade'
|
35
39
|
|
36
40
|
class DistrictNotFound < StandardError; end
|
37
41
|
class ConnectionError < StandardError; end
|
data/lib/clever/client.rb
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
|
3
3
|
module Clever
|
4
4
|
class Client
|
5
|
-
attr_accessor :app_id, :app_token, :sync_id, :logger,
|
5
|
+
attr_accessor :app_id, :app_token, :sync_id, :logger, :redirect_uri,
|
6
6
|
:vendor_key, :vendor_secret, :username_source, :staff_username_source
|
7
7
|
|
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
|
@@ -38,6 +38,22 @@ module Clever
|
|
38
38
|
response
|
39
39
|
end
|
40
40
|
|
41
|
+
def user_uid_for_code(code)
|
42
|
+
response = connection.execute(USER_TOKEN_ENDPOINT,
|
43
|
+
:post,
|
44
|
+
nil,
|
45
|
+
{ code: code,
|
46
|
+
grant_type: 'authorization_code',
|
47
|
+
redirect_uri: redirect_uri })
|
48
|
+
|
49
|
+
fail ConnectionError, response.raw_body unless response.success?
|
50
|
+
|
51
|
+
connection.set_token(response.raw_body['access_token'])
|
52
|
+
|
53
|
+
response = connection.execute(ME_ENDPOINT, :get)
|
54
|
+
response&.body&.dig('id')
|
55
|
+
end
|
56
|
+
|
41
57
|
def most_recent_event
|
42
58
|
authenticate
|
43
59
|
|
@@ -54,7 +70,7 @@ module Clever
|
|
54
70
|
Paginator.fetch(connection, endpoint, :get, Types::Event, client: self).force
|
55
71
|
end
|
56
72
|
|
57
|
-
%i(students courses teachers
|
73
|
+
%i(students courses teachers sections terms).each do |record_type|
|
58
74
|
define_method(record_type) do |record_uids = []|
|
59
75
|
authenticate
|
60
76
|
|
@@ -69,6 +85,22 @@ module Clever
|
|
69
85
|
end
|
70
86
|
end
|
71
87
|
|
88
|
+
def admins(record_uids = [])
|
89
|
+
authenticate
|
90
|
+
|
91
|
+
district_admins = Paginator.fetch(connection, Clever::DISTRICT_ADMINS_ENDPOINT,
|
92
|
+
:get, Types::DistrictAdmin, client: self).force
|
93
|
+
|
94
|
+
school_admins = Paginator.fetch(connection, Clever::SCHOOL_ADMINS_ENDPOINT,
|
95
|
+
:get, Types::SchoolAdmin, client: self).force
|
96
|
+
|
97
|
+
admins = (district_admins + school_admins).uniq(&:uid)
|
98
|
+
|
99
|
+
return admins if record_uids.empty?
|
100
|
+
|
101
|
+
admins.select { |record| record_uids.to_set.include?(record.uid) }
|
102
|
+
end
|
103
|
+
|
72
104
|
# discard params to make the API behave the same as the one roster gem
|
73
105
|
def classrooms(*)
|
74
106
|
authenticate
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module Clever
|
4
4
|
module Types
|
5
|
-
class
|
5
|
+
class DistrictAdmin < Teacher
|
6
6
|
def initialize(attributes = {}, *, client: nil)
|
7
7
|
@district_username = attributes.dig('roles', 'district_admin', 'credentials', 'district_username')
|
8
8
|
@email = attributes['email']
|
@@ -10,7 +10,7 @@ module Clever
|
|
10
10
|
@last_name = attributes['name']['last']
|
11
11
|
@legacy_id = attributes.dig('roles', 'district_admin', 'legacy_id')
|
12
12
|
@provider = 'clever'
|
13
|
-
@sis_id = attributes.dig('roles', 'district_admin', '
|
13
|
+
@sis_id = attributes.dig('roles', 'district_admin', 'sis_id')
|
14
14
|
@uid = attributes['id']
|
15
15
|
@username = username(client)
|
16
16
|
@role = 'admin'
|
@@ -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', '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
@@ -16,7 +16,7 @@ module Clever
|
|
16
16
|
@last_name = attributes['name']['last']
|
17
17
|
@legacy_id = attributes.dig('roles', 'student', 'legacy_id')
|
18
18
|
@provider = 'clever'
|
19
|
-
@sis_id = attributes
|
19
|
+
@sis_id = attributes.dig('roles', 'student', 'sis_id')
|
20
20
|
@uid = attributes['id']
|
21
21
|
@username = username(client)
|
22
22
|
end
|
data/lib/clever/types/teacher.rb
CHANGED
@@ -18,7 +18,7 @@ module Clever
|
|
18
18
|
@last_name = attributes['name']['last']
|
19
19
|
@legacy_id = attributes.dig('roles', 'teacher', 'legacy_id')
|
20
20
|
@provider = 'clever'
|
21
|
-
@sis_id = attributes.dig('roles', 'teacher', '
|
21
|
+
@sis_id = attributes.dig('roles', 'teacher', 'sis_id')
|
22
22
|
@uid = attributes['id']
|
23
23
|
@username = username(client)
|
24
24
|
@role = 'teacher'
|
@@ -37,7 +37,8 @@ module Clever
|
|
37
37
|
first_name: @first_name,
|
38
38
|
last_name: @last_name,
|
39
39
|
username: @username,
|
40
|
-
provider: @provider
|
40
|
+
provider: @provider,
|
41
|
+
legacy_id: @legacy_id
|
41
42
|
}
|
42
43
|
end
|
43
44
|
|
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.2.3
|
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-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -192,12 +192,13 @@ 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
|
196
195
|
- lib/clever/types/base.rb
|
197
196
|
- lib/clever/types/classroom.rb
|
198
197
|
- lib/clever/types/course.rb
|
198
|
+
- lib/clever/types/district_admin.rb
|
199
199
|
- lib/clever/types/enrollment.rb
|
200
200
|
- lib/clever/types/event.rb
|
201
|
+
- lib/clever/types/school_admin.rb
|
201
202
|
- lib/clever/types/section.rb
|
202
203
|
- lib/clever/types/student.rb
|
203
204
|
- lib/clever/types/teacher.rb
|