clever 3.1.1 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/clever.rb +13 -11
- data/lib/clever/client.rb +19 -3
- data/lib/clever/types/{admin.rb → district_admin.rb} +1 -1
- data/lib/clever/types/school_admin.rb +20 -0
- 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: 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,21 +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/
|
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
|
-
TOKENS_ENDPOINT
|
27
|
-
STUDENTS_ENDPOINT
|
28
|
-
COURSES_ENDPOINT
|
29
|
-
SECTIONS_ENDPOINT
|
30
|
-
TEACHERS_ENDPOINT
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
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'
|
35
37
|
|
36
38
|
class DistrictNotFound < StandardError; end
|
37
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
|
@@ -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 teachers
|
57
|
+
%i(students courses teachers sections terms).each do |record_type|
|
58
58
|
define_method(record_type) do |record_uids = []|
|
59
59
|
authenticate
|
60
60
|
|
@@ -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
|
@@ -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']
|
@@ -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/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.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-06-
|
11
|
+
date: 2021-06-09 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
|