strongmind-platform-sdk 3.17.1 → 3.19.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4335eb6c1fb9e9020ff274bab46912ab69020606d6fb08719289364560bc0262
4
- data.tar.gz: 1785d9e581f55ff36234c12d61aa1a401571614235e84d68b6f888cc190ea520
3
+ metadata.gz: a116ab2dded0c9438031825118549bba4f66437bba41e21a05f5b10eee34f0f9
4
+ data.tar.gz: cf95cc4393e3718a60f57a41348f11be5b2a5e7e850ba0476a69e9d0a6a604e3
5
5
  SHA512:
6
- metadata.gz: f51c2653bc1f9710ed179c68d0a9446ec0cd56367a67fb1b035ac38dca9fa35b63ded88cec19d66698e5f8a11150e2ddbc3933f665f26dfd791e125c1d5bbb4d
7
- data.tar.gz: 82c0775e20df6a4b473d43faefec40cbfe6664cf20123a23ac6a4c5a934b069944b570cd18aaac21647c54ee9a55dd06ba25f45f332554a5d2950b9f3c8f170b
6
+ metadata.gz: 6789b299100a35dc404bd7d9628949efe05e12c3eedf1642f3dd22d419e43c7f16555f6ac1ffe245e338b06fbb10a22fbb4a1ef2cdec81efb44fb5272402ad55
7
+ data.tar.gz: bc04bdfc93c81a2a5c843f70b34d8dc1d7a224771bd31ed17bb3bfed3bf0c9cc60cc85f8f872f6d2e4e1eb2e7dbb11f3b1f217d6982add5599f2a230972ac102
data/.rubocop.yml CHANGED
@@ -3,7 +3,7 @@ AllCops:
3
3
 
4
4
  Style/StringLiterals:
5
5
  Enabled: true
6
- EnforcedStyle: double_quotes
6
+ EnforcedStyle: single_quotes
7
7
 
8
8
  Style/StringLiteralsInInterpolation:
9
9
  Enabled: true
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- strongmind-platform-sdk (3.17.1)
4
+ strongmind-platform-sdk (3.19.0)
5
5
  activesupport (~> 7.1)
6
6
  aws-sdk-secretsmanager (~> 1.66)
7
7
  faraday (~> 2.5, >= 2.5.2)
@@ -95,7 +95,7 @@ GEM
95
95
  public_suffix (>= 2.0.2, < 6.0)
96
96
  ast (2.4.2)
97
97
  aws-eventstream (1.3.0)
98
- aws-partitions (1.930.0)
98
+ aws-partitions (1.931.0)
99
99
  aws-sdk-cloudwatch (1.91.0)
100
100
  aws-sdk-core (~> 3, >= 3.193.0)
101
101
  aws-sigv4 (~> 1.1)
@@ -14,7 +14,7 @@ module PlatformSdk
14
14
 
15
15
  def pipeline_payload(action)
16
16
  {
17
- "noun": pipeline_noun,
17
+ "noun": self.class.pipeline_noun,
18
18
  "identifiers": pipeline_identifiers,
19
19
  "meta": pipeline_meta,
20
20
  "data": pipeline_data(action),
@@ -23,8 +23,8 @@ module PlatformSdk
23
23
  }
24
24
  end
25
25
 
26
- def pipeline_noun
27
- "StrongMind.Central.#{self.class.name}"
26
+ def self.pipeline_noun
27
+ raise NotImplementedError, 'You must implement the pipeline_noun class method'
28
28
  end
29
29
 
30
30
  def pipeline_identifiers
@@ -77,20 +77,6 @@ module PlatformSdk
77
77
  Time.at(JWT.decode(jwt, nil, false)[0]["exp"])
78
78
  end
79
79
 
80
- def refresh_token_if_expired(jwt:, refresh_token:)
81
- raise ArgumentError if refresh_token.nil? || jwt.nil?
82
- return unless token_expired?(jwt)
83
-
84
- refresh_token(refresh_token)
85
- end
86
-
87
- def refresh_token(refresh_token)
88
- raise ArgumentError if refresh_token.nil?
89
-
90
- post_payload("/connect/token", request_body(
91
- grant_type: "refresh_token", refresh_token:))
92
- end
93
-
94
80
  def refresh_session(session: {})
95
81
  raise ArgumentError if session[:access_token].nil? || session[:refresh_token].nil?
96
82
 
@@ -103,6 +89,19 @@ module PlatformSdk
103
89
  session[:refresh_token] = refreshed_tokens[:refresh_token]
104
90
  end
105
91
 
92
+ def refresh_token_if_expired(jwt:, refresh_token:)
93
+ raise ArgumentError if refresh_token.nil? || jwt.nil?
94
+ return unless token_expired?(jwt)
95
+
96
+ new_refresh_token(refresh_token)
97
+ end
98
+
99
+ def new_refresh_token(refresh_token)
100
+ raise ArgumentError if refresh_token.nil?
101
+
102
+ post_payload("/connect/token", request_body(grant_type: "refresh_token", refresh_token:))
103
+ end
104
+
106
105
  def raise_error_with_payload(exception_class, error)
107
106
  json_log = {
108
107
  exception: exception_class.new.class.name.demodulize,
@@ -110,7 +109,7 @@ module PlatformSdk
110
109
  response_body: error.response[:body],
111
110
  status: error.response[:status]
112
111
  }.compact
113
- Rails.logger.info json_log.to_json if respond_to?(:Rails)
112
+ Rails.logger.info json_log.to_json if defined?(Rails)
114
113
  raise exception_class, error.response
115
114
  end
116
115
 
@@ -3,7 +3,7 @@ module PlatformSdk
3
3
  RSpec.shared_examples "DataPipelineable" do | data = nil|
4
4
  let(:pipeline_payload) do
5
5
  {
6
- "noun": "StrongMind.Central.#{described_class.name}",
6
+ "noun": described_class.pipeline_noun,
7
7
  "identifiers": { "id": record.id },
8
8
  "meta": { "source": 'strongmind-central' },
9
9
  "data": data || default_data,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PlatformSdk
4
- VERSION = "3.17.1"
4
+ VERSION = "3.19.0"
5
5
  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.17.1
4
+ version: 3.19.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Platform Team
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-05-16 00:00:00.000000000 Z
11
+ date: 2024-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday