clever 2.3.2 → 3.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2ff0b41f8f5609493aaf2935de074f048f4deb32
4
- data.tar.gz: 0630556066c95480e23759940dc631369deef2e9
3
+ metadata.gz: 5b544d8d4b80be8cd0b754f657c7ccfbeec9f2a4
4
+ data.tar.gz: 19e063bfda75ad232871c9564958d403b8f41e83
5
5
  SHA512:
6
- metadata.gz: c469ccfd3a5e2eef2575686cd2704822cba36532a458b9910e87bbb908ce6df7cce0ab58acf78fe5afb92902706920d3cdaa3ca22ab2e8e65934dec7e4a34e61
7
- data.tar.gz: dbb555be80c9b63fc4c2d1600dd0e6906a36a1c69de88817c92eed90904a2d219fb3c4501c7548c3fb1226526aab75ab06abfc67eb7e80c690399fbefd528a44
6
+ metadata.gz: 0754506c3b777034448ccbbc520eeb2ccaaca7501ffc239635662a24777a274aa62fe93d174c84f71adeafaaa6adc113e3fdd826b5aab50d2d2e195d83e66935
7
+ data.tar.gz: ca941ccd1a012dfa5727ba6535b755db11672a74a804764953a6007233f150b3fe4bae876c2f9022e843d13ee85aa07ce9d1c874ab65a7539849ee67eadbe881
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- clever (2.3.2)
4
+ clever (3.2.1)
5
5
  faraday
6
6
  faraday_middleware
7
7
 
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 = 'https://api.clever.com/v2.0'
25
- TOKENS_ENDPOINT = 'https://clever.com/oauth/tokens?owner_type=district'
26
- STUDENTS_ENDPOINT = '/v2.0/students'
27
- COURSES_ENDPOINT = '/v2.0/courses'
28
- SECTIONS_ENDPOINT = '/v2.0/sections'
29
- TEACHERS_ENDPOINT = '/v2.0/teachers'
30
- EVENTS_ENDPOINT = '/v1.2/events'
31
- TERMS_ENDPOINT = '/v2.0/terms'
32
- GRADES_ENDPOINT = 'https://grades-api.beta.clever.com/v1/grade'
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 = API_URL
12
- @tokens_endpoint = 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
@@ -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
- @uid = attributes['id']
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
- @district_username = attributes.dig('credentials', 'district_username')
17
+ @legacy_id = attributes.dig('roles', 'student', 'legacy_id')
18
+ @provider = 'clever'
16
19
  @sis_id = attributes['sis_id']
17
- @email = attributes['email']
20
+ @uid = attributes['id']
18
21
  @username = username(client)
19
- @provider = 'clever'
20
22
  end
21
23
 
22
24
  def username(client = nil)
@@ -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
- @uid = attributes['id']
14
- @email = attributes['email']
15
- @first_name = attributes['name']['first']
16
- @last_name = attributes['name']['last']
17
- @district_username = attributes.dig('credentials', 'district_username')
18
- @sis_id = attributes['sis_id']
19
- @username = username(client)
20
- @provider = 'clever'
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)
@@ -33,7 +37,8 @@ module Clever
33
37
  first_name: @first_name,
34
38
  last_name: @last_name,
35
39
  username: @username,
36
- provider: @provider
40
+ provider: @provider,
41
+ legacy_id: @legacy_id
37
42
  }
38
43
  end
39
44
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Clever
4
- VERSION = '2.3.2'
4
+ VERSION = '3.2.1'
5
5
  end
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.3.2
4
+ version: 3.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Julius
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-09-28 00:00:00.000000000 Z
11
+ date: 2021-06-10 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