strongmind-platform-sdk 3.26.0 → 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: 10e1d9bf0e0f8f2485f4a924e604e40dd0172a95c4ef093d049ca1ea07af7c4e
4
- data.tar.gz: 9bf269afd5d8f0ebab8d456bd99207784e74cd6bc6d7816562c790646ce0a2b5
3
+ metadata.gz: 603801ca348502e639d6ab74b54d15cb30a97a64a083c92b8ae75646472c1867
4
+ data.tar.gz: a57d47261f65fc72919863dd982535e249a8ba1324aaeb6bed7a4ec8c2e7fb38
5
5
  SHA512:
6
- metadata.gz: 3af4a0ab8f12fde7e49f8d5fb59a661da2de5d02e08394632a14f6af5a70b5c182d21d552acdd1a4aeab620f4033c54b66347beee630ecc6f4ff03867ea1e14b
7
- data.tar.gz: e730ffda9d43615af99d581d2092b822c6b6b935ea8c678fdcf3d55d31ae18fa8f06367ed29e72565d6d5bd885f8c91d7033e440ec82ab80f961c82694c8594b
6
+ metadata.gz: f76e7caace946ced3b8bd1e39d1fedb03bb2e8125b1c5826c27eb95bfb905a7c4a87f91a5bfb853e9ed2705971450247b0c19abb369f3c15a79aad383c14f994
7
+ data.tar.gz: 9a76e71640aacd864aecca65125c12187f91e1f8075c0d13c7c4539774f6a99e854bd0751c5c76636601609ef779ba5649c2bc5a9d739825d180ccf973a2f7a0
data/Gemfile.lock CHANGED
@@ -203,7 +203,7 @@ GEM
203
203
  mutex_m (0.2.0)
204
204
  net-http (0.4.1)
205
205
  uri
206
- net-imap (0.5.5)
206
+ net-imap (0.5.6)
207
207
  date
208
208
  net-protocol
209
209
  net-pop (0.1.2)
@@ -4,26 +4,38 @@ 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
 
10
12
  @conn = Faraday.new(identity_base_url) do |conn|
11
13
  conn.request :authorization, 'Bearer', -> { @auth.auth_token }
12
14
  conn.request :retry
15
+ conn.request :json
16
+ conn.response :raise_error
13
17
  conn.response :json
14
18
  conn.adapter :net_http
15
19
  end
16
20
  end
17
21
 
18
- def with_rescue
19
- yield
20
- rescue ResourceNotFound => e
21
- puts e
22
+ def provision_identity(user_params)
23
+ response = post_payload('/api/accounts/WithProfile', user_params)
24
+ response.body
25
+ end
26
+
27
+ def post_payload(path, body)
28
+ with_rescue do
29
+ response = @conn.post(path, body)
30
+ response.body
31
+ end
22
32
  end
23
33
  end
24
34
 
25
35
  # Client for getting auth tokens from identity server
26
36
  class AuthClient
37
+ include ErrorHandleable
38
+
27
39
  attr_accessor :conn, :token
28
40
 
29
41
  def initialize(base_url, client_id, client_secret)
@@ -37,16 +49,6 @@ module PlatformSdk
37
49
  end
38
50
  end
39
51
 
40
- def with_rescue
41
- yield
42
- rescue Faraday::TimeoutError => e
43
- raise TimeoutError, e
44
- rescue Faraday::ServerError => e
45
- raise_error_with_payload(ServerError, e)
46
- rescue Faraday::ClientError => e
47
- raise_error_with_payload(ClientError, e)
48
- end
49
-
50
52
  def post_payload(path, body)
51
53
  with_rescue do
52
54
  response = @conn.post(path, body)
@@ -107,17 +109,6 @@ module PlatformSdk
107
109
  post_payload('/connect/token', request_body(grant_type: 'refresh_token', refresh_token:))
108
110
  end
109
111
 
110
- def raise_error_with_payload(exception_class, error)
111
- json_log = {
112
- exception: exception_class.new.class.name.demodulize,
113
- payload: error.response.dig(:request, :body),
114
- response_body: error.response[:body],
115
- status: error.response[:status]
116
- }.compact
117
- Rails.logger.info json_log.to_json if defined?(Rails)
118
- raise exception_class, error.response
119
- end
120
-
121
112
  private
122
113
 
123
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
@@ -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 = 0
6
+ PATCH = 2
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.0
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-02-04 00:00:00.000000000 Z
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