strongmind-platform-sdk 3.26.1 → 3.26.2
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 603801ca348502e639d6ab74b54d15cb30a97a64a083c92b8ae75646472c1867
|
4
|
+
data.tar.gz: a57d47261f65fc72919863dd982535e249a8ba1324aaeb6bed7a4ec8c2e7fb38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f76e7caace946ced3b8bd1e39d1fedb03bb2e8125b1c5826c27eb95bfb905a7c4a87f91a5bfb853e9ed2705971450247b0c19abb369f3c15a79aad383c14f994
|
7
|
+
data.tar.gz: 9a76e71640aacd864aecca65125c12187f91e1f8075c0d13c7c4539774f6a99e854bd0751c5c76636601609ef779ba5649c2bc5a9d739825d180ccf973a2f7a0
|
@@ -4,6 +4,8 @@ module PlatformSdk
|
|
4
4
|
module Identity
|
5
5
|
# Client for making calls to the Identity Server API
|
6
6
|
class Client
|
7
|
+
include ErrorHandleable
|
8
|
+
|
7
9
|
def initialize(identity_base_url, client_id, client_secret, auth_client = nil)
|
8
10
|
@auth = auth_client.nil? ? AuthClient.new(identity_base_url, client_id, client_secret) : auth_client
|
9
11
|
|
@@ -11,25 +13,29 @@ module PlatformSdk
|
|
11
13
|
conn.request :authorization, 'Bearer', -> { @auth.auth_token }
|
12
14
|
conn.request :retry
|
13
15
|
conn.request :json
|
16
|
+
conn.response :raise_error
|
14
17
|
conn.response :json
|
15
18
|
conn.adapter :net_http
|
16
19
|
end
|
17
20
|
end
|
18
21
|
|
19
22
|
def provision_identity(user_params)
|
20
|
-
response =
|
23
|
+
response = post_payload('/api/accounts/WithProfile', user_params)
|
21
24
|
response.body
|
22
25
|
end
|
23
26
|
|
24
|
-
def
|
25
|
-
|
26
|
-
|
27
|
-
|
27
|
+
def post_payload(path, body)
|
28
|
+
with_rescue do
|
29
|
+
response = @conn.post(path, body)
|
30
|
+
response.body
|
31
|
+
end
|
28
32
|
end
|
29
33
|
end
|
30
34
|
|
31
35
|
# Client for getting auth tokens from identity server
|
32
36
|
class AuthClient
|
37
|
+
include ErrorHandleable
|
38
|
+
|
33
39
|
attr_accessor :conn, :token
|
34
40
|
|
35
41
|
def initialize(base_url, client_id, client_secret)
|
@@ -43,16 +49,6 @@ module PlatformSdk
|
|
43
49
|
end
|
44
50
|
end
|
45
51
|
|
46
|
-
def with_rescue
|
47
|
-
yield
|
48
|
-
rescue Faraday::TimeoutError => e
|
49
|
-
raise TimeoutError, e
|
50
|
-
rescue Faraday::ServerError => e
|
51
|
-
raise_error_with_payload(ServerError, e)
|
52
|
-
rescue Faraday::ClientError => e
|
53
|
-
raise_error_with_payload(ClientError, e)
|
54
|
-
end
|
55
|
-
|
56
52
|
def post_payload(path, body)
|
57
53
|
with_rescue do
|
58
54
|
response = @conn.post(path, body)
|
@@ -113,17 +109,6 @@ module PlatformSdk
|
|
113
109
|
post_payload('/connect/token', request_body(grant_type: 'refresh_token', refresh_token:))
|
114
110
|
end
|
115
111
|
|
116
|
-
def raise_error_with_payload(exception_class, error)
|
117
|
-
json_log = {
|
118
|
-
exception: exception_class.new.class.name.demodulize,
|
119
|
-
payload: error.response.dig(:request, :body),
|
120
|
-
response_body: error.response[:body],
|
121
|
-
status: error.response[:status]
|
122
|
-
}.compact
|
123
|
-
Rails.logger.info json_log.to_json if defined?(Rails)
|
124
|
-
raise exception_class, error.response
|
125
|
-
end
|
126
|
-
|
127
112
|
private
|
128
113
|
|
129
114
|
def request_body(grant_type: 'client_credentials', refresh_token: nil)
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PlatformSdk
|
4
|
+
module Identity
|
5
|
+
# Error handling for Identity SDK
|
6
|
+
module ErrorHandleable
|
7
|
+
def with_rescue
|
8
|
+
yield
|
9
|
+
rescue Faraday::TimeoutError => e
|
10
|
+
raise TimeoutError, e
|
11
|
+
rescue Faraday::ServerError => e
|
12
|
+
raise_error_with_payload(ServerError, e)
|
13
|
+
rescue Faraday::ClientError => e
|
14
|
+
raise_error_with_payload(ClientError, e)
|
15
|
+
end
|
16
|
+
|
17
|
+
def raise_error_with_payload(exception_class, error)
|
18
|
+
json_log = {
|
19
|
+
exception: exception_class.new.class.name.demodulize,
|
20
|
+
payload: error.response.dig(:request, :body),
|
21
|
+
response_body: error.response[:body],
|
22
|
+
status: error.response[:status]
|
23
|
+
}.compact
|
24
|
+
Rails.logger.info json_log.to_json if defined?(Rails)
|
25
|
+
raise exception_class, error.response
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/platform_sdk/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: strongmind-platform-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.26.
|
4
|
+
version: 3.26.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Platform Team
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-03-
|
11
|
+
date: 2025-03-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -274,6 +274,7 @@ files:
|
|
274
274
|
- lib/platform_sdk/id_mapper/models/partner.rb
|
275
275
|
- lib/platform_sdk/identity.rb
|
276
276
|
- lib/platform_sdk/identity/clients.rb
|
277
|
+
- lib/platform_sdk/identity/error_handleable.rb
|
277
278
|
- lib/platform_sdk/jira.rb
|
278
279
|
- lib/platform_sdk/jira/service_management_client.rb
|
279
280
|
- lib/platform_sdk/jobs/send_noun_to_pipeline_job.rb
|