school21_api_sdk 0.5.0 → 0.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8c369d9fa76c0c36cb3142d0807256d9be76d9b706aedc32207899f355721d0b
4
- data.tar.gz: 3b314e7f8a1235eadfe9ce7cd5147bc0889c4926169a3a29740613f72f2aeb94
3
+ metadata.gz: 2950a193b5d022a8dfb23e709e288945870b3832abde0dc22f22703f43ee54c1
4
+ data.tar.gz: 6aa77ab9e31bf92bd292d55a1299179e60ead0458e8f64c6b1e6c2065e80ed13
5
5
  SHA512:
6
- metadata.gz: ddaecba86f46485941eb2a9d508ff6a2961db296657bbc28cf3b31dee962af1986648d1226cf1e46425475ef48935b2716810d4d74b34a627eba5e637d00cb4c
7
- data.tar.gz: cf9e4fc8918d2b64e4361cf45a19bc8a6fc6f6e2c520f476e71b3e8c5025222bea1074a303971ff3f24ddd00e9c57b2e5d04f032bfd650c269b358e137fc9ebc
6
+ metadata.gz: 4d8868c9698e3d051260c0deafb4f9e499f07fbaafd8f4b6f4f426edf8cb1176b607a225623eb98671c7cfe93529e27ec42960e2488ec89e9dbd5c5800a983ef
7
+ data.tar.gz: ab328077173d485143a794a66ad4aaae303e856e0341102071126cca6139ad6f59162a0b38b8c9b983fe053a778df2ea8387f0ca45e6f2ed840b436faf3066d8
@@ -9,9 +9,9 @@ module School21
9
9
  def self.base_uri(server)
10
10
  case server
11
11
  when :api_v1
12
- 'https://edu-api.21-school.ru/services/21-school/api/v1'
12
+ 'https://platform.21-school.ru/services/21-school/api/v1'
13
13
  when :auth
14
- 'https://auth.sberclass.ru/auth/realms/EduPowerKeycloak/protocol/openid-connect'
14
+ 'https://auth.21-school.ru/auth/realms/EduPowerKeycloak/protocol/openid-connect'
15
15
  end
16
16
  end
17
17
 
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module School21
4
+ class AccessTokenError < StandardError; end
5
+
4
6
  module Authenticator
5
7
  def self.call
6
8
  return unless School21.config.access_token.expired?
@@ -10,7 +12,7 @@ module School21
10
12
  password: School21.config.credentials[:password]
11
13
  )
12
14
 
13
- raise 'Access Token Error' unless auth_api_response.success?
15
+ raise AccessTokenError unless auth_api_response.success?
14
16
 
15
17
  access_token = AccessToken.new(*auth_api_response.data.values_at(:access_token, :expires_in))
16
18
  bearer_auth_credentials = BearerAuthCredentials.new(access_token:)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module School21
4
- VERSION = '0.5.0'
4
+ VERSION = '0.6.0'
5
5
  end
data/lib/school21.rb CHANGED
@@ -39,17 +39,18 @@ module School21
39
39
  @config = nil
40
40
  end
41
41
 
42
- API_CLASSES = {
43
- auth: AuthApi,
44
- participants: ParticipantsApi,
45
- projects: ProjectsApi,
46
- campuses: CampusesApi,
47
- clusters: ClustersApi,
48
- graph: GraphApi
49
- }.freeze
50
-
51
- API_CLASSES.each do |name, klass|
52
- define_method("#{name}_api") do
42
+ API_CLASSES_MAPPINGS = [
43
+ AuthApi,
44
+ ParticipantsApi,
45
+ ProjectsApi,
46
+ CampusesApi,
47
+ ClustersApi,
48
+ GraphApi
49
+ ].freeze
50
+
51
+ API_CLASSES_MAPPINGS.each do |klass|
52
+ method_name = klass.name.underscore.split('/').last.to_sym
53
+ define_method(method_name) do
53
54
  klass.new
54
55
  end
55
56
  end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'test_helper'
4
+
5
+ describe 'Graph API Test' do
6
+ include AuthStub
7
+ include GraphStub
8
+
9
+ with_configured_client do
10
+ let(:graph_api_call) do
11
+ School21.graph_api.graph
12
+ end
13
+
14
+ it 'calls stub graph success' do
15
+ stubs = [
16
+ stub_token_success,
17
+ stub_graph_success
18
+ ]
19
+
20
+ graph_api_call
21
+
22
+ stubs.each { |stub| assert_requested(stub) }
23
+ end
24
+
25
+ it 'calls stub graph fail' do
26
+ stubs = [
27
+ stub_token_success,
28
+ stub_graph_fail
29
+ ]
30
+
31
+ graph_api_call
32
+
33
+ stubs.each { |stub| assert_requested(stub) }
34
+ end
35
+ end
36
+ end
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BaseStub
4
- BASE_AUTH_URL = 'https://auth.sberclass.ru'
5
- BASE_API_V1_URL = 'https://edu-api.21-school.ru/services/21-school/api/v1'
4
+ BASE_AUTH_URL = 'https://auth.21-school.ru'
5
+ BASE_API_V1_URL = 'https://platform.21-school.ru/services/21-school/api/v1'
6
6
 
7
7
  def base_stub_fail(http_method, url)
8
8
  stub_request(http_method, url)
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GraphStub
4
+ include BaseStub
5
+
6
+ STUBBED_GRAPH_URL = [BASE_API_V1_URL, '/graph'].join
7
+
8
+ def stub_graph_success
9
+ stub_request(:get, STUBBED_GRAPH_URL)
10
+ .to_return_json(body: { data: { user: { login: 'test_user' } } }) # Example success response
11
+ end
12
+
13
+ def stub_graph_fail
14
+ base_stub_fail(:get, STUBBED_GRAPH_URL)
15
+ end
16
+ end
@@ -12,7 +12,6 @@ module ParticipantsStub
12
12
  end
13
13
 
14
14
  def stub_participant_fail
15
- stub_request(:get, STUBBED_PARTICIPANT_URL)
16
- .to_return(status: [500, 'Internal Server Error'])
15
+ base_stub_fail(:get, STUBBED_PARTICIPANT_URL)
17
16
  end
18
17
  end
data/test/test_helper.rb CHANGED
@@ -10,6 +10,7 @@ require_relative 'support/shared_data'
10
10
  require_relative 'support/stubs/base_stub'
11
11
  require_relative 'support/stubs/auth_stub'
12
12
  require_relative 'support/stubs/participants_stub'
13
+ require_relative 'support/stubs/graph_stub'
13
14
 
14
15
  SimpleCov.start
15
16
  SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: school21_api_sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Yudin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-05-18 00:00:00.000000000 Z
11
+ date: 2025-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -123,10 +123,12 @@ files:
123
123
  - lib/school21/version.rb
124
124
  - test/auth_api_test.rb
125
125
  - test/configuration_test.rb
126
+ - test/graph_api_test.rb
126
127
  - test/participants_api_test.rb
127
128
  - test/support/shared_data.rb
128
129
  - test/support/stubs/auth_stub.rb
129
130
  - test/support/stubs/base_stub.rb
131
+ - test/support/stubs/graph_stub.rb
130
132
  - test/support/stubs/participants_stub.rb
131
133
  - test/test_helper.rb
132
134
  homepage: https://github.com/ikael21/school21_api_sdk
@@ -149,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
149
151
  - !ruby/object:Gem::Version
150
152
  version: '0'
151
153
  requirements: []
152
- rubygems_version: 3.5.17
154
+ rubygems_version: 3.5.9
153
155
  signing_key:
154
156
  specification_version: 4
155
157
  summary: School21 API SDK