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 +4 -4
- data/lib/school21/api/base_api.rb +2 -2
- data/lib/school21/auth/authenticator.rb +3 -1
- data/lib/school21/version.rb +1 -1
- data/lib/school21.rb +12 -11
- data/test/graph_api_test.rb +36 -0
- data/test/support/stubs/base_stub.rb +2 -2
- data/test/support/stubs/graph_stub.rb +16 -0
- data/test/support/stubs/participants_stub.rb +1 -2
- data/test/test_helper.rb +1 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2950a193b5d022a8dfb23e709e288945870b3832abde0dc22f22703f43ee54c1
|
4
|
+
data.tar.gz: 6aa77ab9e31bf92bd292d55a1299179e60ead0458e8f64c6b1e6c2065e80ed13
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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://
|
12
|
+
'https://platform.21-school.ru/services/21-school/api/v1'
|
13
13
|
when :auth
|
14
|
-
'https://auth.
|
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
|
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:)
|
data/lib/school21/version.rb
CHANGED
data/lib/school21.rb
CHANGED
@@ -39,17 +39,18 @@ module School21
|
|
39
39
|
@config = nil
|
40
40
|
end
|
41
41
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
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.
|
5
|
-
BASE_API_V1_URL = 'https://
|
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
|
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.
|
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-
|
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.
|
154
|
+
rubygems_version: 3.5.9
|
153
155
|
signing_key:
|
154
156
|
specification_version: 4
|
155
157
|
summary: School21 API SDK
|