clever 3.2.0 → 3.2.4

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: 86d6af37efac719fa831d86a65862a402eb5af65
4
- data.tar.gz: 46c1a1e4142338704353295934719e109b09e28f
3
+ metadata.gz: f84b168808a2e9b8995863bf0973666fe70c390b
4
+ data.tar.gz: dd0d8a0a716f4d3a7c74ab7ac5ff6c480c5e03cd
5
5
  SHA512:
6
- metadata.gz: e21034624a92171120aa45364bbdc347696c5a65377907703c1297ddf94ee06638884f9d8ba02b2ff2bb133e40947135322c3391207448a114769c483b6e6615
7
- data.tar.gz: 41d92685a37b57957ea89584ea60daa52950dfde939529d32daab129352c2e4f3a43ca6caa09debbbb8e71842b0cc6efbfb4f787a99c32cbe460ced858097197
6
+ metadata.gz: d7180693e83b281e5c67b3e54e794785730ce61a39f2d922e3dc2641c2217ff9e6232e7284dd0c96d4342913d417403156b60f28a9466091eb8b97db6ed4281c
7
+ data.tar.gz: '06051692792b1dae29f99962a93ac236d7e3e6e3b67dd72fb5253b34dd8c0341c663d0a6f637d3f78239db3f82905b764a217973e539d6a13be240d704963367'
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- clever (3.2.0)
4
+ clever (3.2.4)
5
5
  faraday
6
6
  faraday_middleware
7
7
 
data/lib/clever.rb CHANGED
@@ -24,6 +24,8 @@ require 'clever/types/token'
24
24
 
25
25
  module Clever
26
26
  API_URL = 'https://api.clever.com/v3.0'
27
+ ME_ENDPOINT = '/v3.0/me'
28
+ USER_TOKEN_ENDPOINT = 'https://clever.com/oauth/tokens'
27
29
  TOKENS_ENDPOINT = 'https://clever.com/oauth/tokens?owner_type=district'
28
30
  STUDENTS_ENDPOINT = '/v3.0/users?role=student'
29
31
  COURSES_ENDPOINT = '/v3.0/courses'
data/lib/clever/client.rb CHANGED
@@ -2,7 +2,7 @@
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
@@ -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
 
@@ -8,9 +8,8 @@ module Clever
8
8
  @email = attributes['email']
9
9
  @first_name = attributes['name']['first']
10
10
  @last_name = attributes['name']['last']
11
- @legacy_id = attributes.dig('roles', 'district_admin', 'legacy_id')
12
11
  @provider = 'clever'
13
- @sis_id = attributes.dig('roles', 'district_admin', 'credentials', 'sis_id')
12
+ @sis_id = attributes.dig('roles', 'district_admin', 'sis_id')
14
13
  @uid = attributes['id']
15
14
  @username = username(client)
16
15
  @role = 'admin'
@@ -8,9 +8,8 @@ module Clever
8
8
  @email = attributes['email']
9
9
  @first_name = attributes['name']['first']
10
10
  @last_name = attributes['name']['last']
11
- @legacy_id = attributes.dig('roles', 'staff', 'legacy_id')
12
11
  @provider = 'clever'
13
- @sis_id = attributes.dig('roles', 'staff', 'credentials', 'sis_id')
12
+ @sis_id = attributes.dig('roles', 'staff', 'sis_id')
14
13
  @uid = attributes['id']
15
14
  @username = username(client)
16
15
  @role = 'admin'
@@ -6,17 +6,15 @@ module Clever
6
6
  attr_reader :uid,
7
7
  :first_name,
8
8
  :last_name,
9
- :provider,
10
- :legacy_id
9
+ :provider
11
10
 
12
11
  def initialize(attributes = {}, client: nil)
13
12
  @district_username = attributes.dig('credentials', 'district_username')
14
13
  @email = attributes['email']
15
14
  @first_name = attributes['name']['first']
16
15
  @last_name = attributes['name']['last']
17
- @legacy_id = attributes.dig('roles', 'student', 'legacy_id')
18
16
  @provider = 'clever'
19
- @sis_id = attributes['sis_id']
17
+ @sis_id = attributes.dig('roles', 'student', 'sis_id')
20
18
  @uid = attributes['id']
21
19
  @username = username(client)
22
20
  end
@@ -8,7 +8,6 @@ module Clever
8
8
  :first_name,
9
9
  :last_name,
10
10
  :provider,
11
- :legacy_id,
12
11
  :role
13
12
 
14
13
  def initialize(attributes = {}, *, client: nil)
@@ -16,9 +15,8 @@ module Clever
16
15
  @email = attributes['email']
17
16
  @first_name = attributes['name']['first']
18
17
  @last_name = attributes['name']['last']
19
- @legacy_id = attributes.dig('roles', 'teacher', 'legacy_id')
20
18
  @provider = 'clever'
21
- @sis_id = attributes.dig('roles', 'teacher', 'credentials', 'sis_id')
19
+ @sis_id = attributes.dig('roles', 'teacher', 'sis_id')
22
20
  @uid = attributes['id']
23
21
  @username = username(client)
24
22
  @role = 'teacher'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Clever
4
- VERSION = '3.2.0'
4
+ VERSION = '3.2.4'
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: 3.2.0
4
+ version: 3.2.4
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-09 00:00:00.000000000 Z
11
+ date: 2021-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday