strongmind-platform-sdk 3.26.1 → 3.26.3

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: 904e2317257e40d33b87128a2dc52727f0e3deecf97ea1e3fd4a394b8bd2acfc
4
- data.tar.gz: f1f7d1bdb6e5f5a2159f23aefde1c64f3548bd2a9948990ce9849d1a07c73558
3
+ metadata.gz: 5b72f5aed8f81adbafa5c1de65cbc5c5706899e0bb3c3b0b2275f2cabe8471d2
4
+ data.tar.gz: d5847ab48d206497fb1618b2127c471c521b0205ddb2b3fe788791ecc08c85e1
5
5
  SHA512:
6
- metadata.gz: b0d15c0c42bed2199d26099462d71e2bc058afefd03b7f7e922c51773b8e774539f4419d400d72912bf2e598aa151de2ef2d763a482ef16e04d915afa7afff72
7
- data.tar.gz: 7f4c54fff042a92776a42c76e057e0308d2bc3ba1902fcbca12f2ae8f67bffa834e4837a05b82090f8aed1066ca3f94b7d9179c340a905df8acd7cd54a3034fe
6
+ metadata.gz: 4c5e4d30d75bf5f6ba883c3d1d206dd51ca070ae0ec8cecde97b320a1b235d5346358d731988af58a0d43e10776659c3fb951b5198a53ab2235fa3a93e405b59
7
+ data.tar.gz: 07a7e4c660793fd69697282a2c1844d93f3c4133ce451c75ae7d6aa149c0694e27d06726a9cd08417deba490b7e9f03178f9b4e7cac36df85e61401e61f95e4a
@@ -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,28 @@ 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 = @conn.post('/api/accounts/WithProfile', user_params)
21
- response.body
23
+ post_payload('/api/accounts/WithProfile', user_params)
22
24
  end
23
25
 
24
- def with_rescue
25
- yield
26
- rescue ResourceNotFound => e
27
- puts e
26
+ def post_payload(path, body)
27
+ with_rescue do
28
+ response = @conn.post(path, body)
29
+ response.body
30
+ end
28
31
  end
29
32
  end
30
33
 
31
34
  # Client for getting auth tokens from identity server
32
35
  class AuthClient
36
+ include ErrorHandleable
37
+
33
38
  attr_accessor :conn, :token
34
39
 
35
40
  def initialize(base_url, client_id, client_secret)
@@ -43,16 +48,6 @@ module PlatformSdk
43
48
  end
44
49
  end
45
50
 
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
51
  def post_payload(path, body)
57
52
  with_rescue do
58
53
  response = @conn.post(path, body)
@@ -113,17 +108,6 @@ module PlatformSdk
113
108
  post_payload('/connect/token', request_body(grant_type: 'refresh_token', refresh_token:))
114
109
  end
115
110
 
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
111
  private
128
112
 
129
113
  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
@@ -6,6 +6,7 @@ require "faraday/net_http"
6
6
  require "json"
7
7
  require "jwt"
8
8
 
9
+ require "platform_sdk/identity/error_handleable"
9
10
  require "platform_sdk/identity/clients"
10
11
 
11
12
  module PlatformSdk
@@ -3,7 +3,7 @@
3
3
  module PlatformSdk
4
4
  MAJOR = 3
5
5
  MINOR = 26
6
- PATCH = 1
6
+ PATCH = 3
7
7
 
8
8
  VERSION = "#{PlatformSdk::MAJOR}.#{PlatformSdk::MINOR}.#{PlatformSdk::PATCH}"
9
9
  end
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.1
4
+ version: 3.26.3
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 00:00:00.000000000 Z
11
+ date: 2025-03-13 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