bima-shark-sdk 2.5.0 → 3.0.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: 8ab74483354f85310c09fe0f53a00143fbd8042e81b0ed8d7226d77909ff2e24
4
- data.tar.gz: 4c2d6b001cd4dfbd451c59c2e27368b55ecca753fd0a63f4a4350216b790be91
3
+ metadata.gz: 5c3d5438f91e3e0715d520cae493446b62571f4f63baa1dcf4b4ff1ce9a97380
4
+ data.tar.gz: 7d321474ad227eabb72a5c9f64806e2219a606ce9b804b1c36bf78b8e6176b48
5
5
  SHA512:
6
- metadata.gz: 26060a07b63c8f2c37a5fe505a5e4aee3bb907ebe1a75340ae4676b05dbdc3377d2e6175ef12fe62e019d98f77680df720527b947f8ffd4e1e0ccb4066ce44fa
7
- data.tar.gz: 13f5e6dd6a7b1b83c98f8e40232349e6d8eaa30f60058363d838491596eb06ee2f8a37cf08868ea71316bd77b5d08c90d5bbd7c151db5120fce8fcf2edb91e24
6
+ metadata.gz: '078265caf5dd06022b0ae91356fd4bd9f8093a879c1191a55297280786be708950652563cf1d5ccb9df8a51c5b9bec7a66f7f8b534eb865ad6142b757310a216'
7
+ data.tar.gz: ae7031d4aee957a60d2791122b650a713c77b75fa0c661b84444830cc463c5f40ac69dda0f19ed296cf22d7acee21f76346973e523ccb8316bf16ce4ed178ab6
data/.travis.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  language: ruby
2
- # cache: bundler
2
+ cache: bundler
3
3
  rvm:
4
4
  - 2.7.6
5
5
  - 3.0.2
data/CHANGELOG.md CHANGED
@@ -1,12 +1,12 @@
1
1
  ## Changelog
2
2
 
3
- #### 2.5.0
4
- - Extend `with_service_token` with `with_auth_token` which allows to send custom `Authorization` header, not only `Bearer`
3
+ #### 3.0.0
4
+ - new minimum requirements are `Ruby 3.0` and `faraday 2.0`
5
5
  - remove `Shark::Subscription`
6
6
 
7
7
  #### 2.4.4
8
- * lowest supported Ruby version is 2.7
9
- * add `recipient` to `Shark::DoubleOptIn::Execution`
8
+ - lowest supported Ruby version is 2.7
9
+ - add `recipient` to `Shark::DoubleOptIn::Execution`
10
10
 
11
11
  #### 2.4.3
12
12
  - allow `Shark::MailingService::Mailer#mail` to use separate layouts
data/README.md CHANGED
@@ -42,21 +42,6 @@ Shark::MailingService.use_shark_mailer do |mailer|
42
42
  end
43
43
  ```
44
44
 
45
- To sign your requests with custom tokens, for instance with JWT:
46
- ```ruby
47
- def deliver
48
- access_id = 'access_id'
49
- secret_key = 'secret_key'
50
-
51
- signature = JWT.encode({ exp: Time.now.to_i + (1 * 60) }, secret_key, 'HS256')
52
-
53
- Shark.with_auth_token("JWT #{access_id}:#{signature}") do
54
- super
55
- end
56
- end
57
-
58
- ```
59
-
60
45
  ## Testing
61
46
 
62
47
  ```
@@ -21,10 +21,9 @@ Gem::Specification.new do |spec|
21
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
22
  spec.require_paths = ['lib']
23
23
 
24
- spec.add_dependency 'activesupport', '>= 4.1.0'
25
- spec.add_dependency 'faraday'
26
- spec.add_dependency 'json_api_client', '>= 1.10.0'
27
- spec.add_dependency 'net-http-persistent'
24
+ spec.add_dependency 'activesupport'
25
+ spec.add_dependency 'faraday', '~> 2.0'
26
+ spec.add_dependency 'json_api_client', '>= 1.23.0'
28
27
  spec.add_dependency 'rack'
29
28
 
30
29
  spec.add_development_dependency 'bundler'
@@ -12,11 +12,11 @@ module Shark
12
12
  params: options[:params] || {}
13
13
  }
14
14
 
15
- @connection = Faraday.new do |faraday|
16
- faraday.use Shark::Middleware::ComposeRequest
17
- faraday.use Shark::Middleware::Status
18
- faraday.use JsonApiClient::Middleware::ParseJson
19
- faraday.adapter :net_http_persistent
15
+ @connection = Faraday.new do |conn|
16
+ conn.use Shark::Middleware::ComposeRequest
17
+ conn.use Shark::Middleware::Status
18
+ conn.response :json, content_type: /\bjson$/
19
+ conn.adapter Faraday.default_adapter
20
20
  end
21
21
  end
22
22
 
@@ -38,7 +38,9 @@ module Shark
38
38
  request_headers = connection_options_headers.merge(headers || {})
39
39
  request_params = connection_options_params.merge(params || {})
40
40
 
41
- request_headers['Authorization'] = Shark.auth_token if Shark.auth_token.present?
41
+ if Shark.service_token.present?
42
+ request_headers['Authorization'] = "Bearer #{Shark.service_token}"
43
+ end
42
44
 
43
45
  @connection.send(request_action) do |request|
44
46
  request.url(url)
data/lib/shark/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Shark
4
- VERSION = '2.5.0'
4
+ VERSION = '3.0.0'
5
5
  end
data/lib/shark.rb CHANGED
@@ -32,41 +32,28 @@ module Shark
32
32
  # @param token [String] The service token for the authorization header
33
33
  # @param block [Block] The block where service token authorization will be set for
34
34
  # @api public
35
- def self.with_service_token(token, &block)
35
+ def self.with_service_token(token)
36
36
  if token.is_a?(String)
37
- auth_token = "Bearer #{token}"
37
+ self.service_token = token
38
38
  elsif token.respond_to?(:jwt)
39
- auth_token = "Bearer #{token.jwt}"
39
+ self.service_token = token.jwt
40
40
  else
41
41
  raise ArgumentError, 'Parameter :token must be kind of String.'
42
42
  end
43
43
 
44
- with_auth_token(auth_token, &block)
45
- end
46
-
47
- # Within the given block, add the authorization header token to all api requests.
48
- #
49
- # @param token [String] The token for the authorization header
50
- # @param block [Block] The block where authorization token will be set for
51
- # @api public
52
- def self.with_auth_token(token)
53
- raise ArgumentError, 'Parameter :token must be kind of String.' unless token.is_a?(String)
54
-
55
- self.auth_token = token
56
-
57
44
  yield
58
45
  ensure
59
- self.auth_token = nil
46
+ self.service_token = nil
60
47
  end
61
48
 
62
49
  # @api public
63
- def self.auth_token
64
- Thread.current['shark-auth-token']
50
+ def self.service_token
51
+ Thread.current['shark-service-token']
65
52
  end
66
53
 
67
54
  # @api private
68
- def self.auth_token=(value)
69
- Thread.current['shark-auth-token'] = value
55
+ def self.service_token=(value)
56
+ Thread.current['shark-service-token'] = value
70
57
  end
71
58
 
72
59
  #
metadata CHANGED
@@ -1,31 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bima-shark-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - bima-team@justrelate.com
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-11-04 00:00:00.000000000 Z
11
+ date: 2024-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: 4.1.0
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: 4.1.0
27
- - !ruby/object:Gem::Dependency
28
- name: faraday
29
15
  requirement: !ruby/object:Gem::Requirement
30
16
  requirements:
31
17
  - - ">="
@@ -39,33 +25,33 @@ dependencies:
39
25
  - !ruby/object:Gem::Version
40
26
  version: '0'
41
27
  - !ruby/object:Gem::Dependency
42
- name: json_api_client
28
+ name: faraday
43
29
  requirement: !ruby/object:Gem::Requirement
44
30
  requirements:
45
- - - ">="
31
+ - - "~>"
46
32
  - !ruby/object:Gem::Version
47
- version: 1.10.0
33
+ version: '2.0'
48
34
  type: :runtime
49
35
  prerelease: false
50
36
  version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
- - - ">="
38
+ - - "~>"
53
39
  - !ruby/object:Gem::Version
54
- version: 1.10.0
40
+ version: '2.0'
55
41
  - !ruby/object:Gem::Dependency
56
- name: net-http-persistent
42
+ name: json_api_client
57
43
  requirement: !ruby/object:Gem::Requirement
58
44
  requirements:
59
45
  - - ">="
60
46
  - !ruby/object:Gem::Version
61
- version: '0'
47
+ version: 1.23.0
62
48
  type: :runtime
63
49
  prerelease: false
64
50
  version_requirements: !ruby/object:Gem::Requirement
65
51
  requirements:
66
52
  - - ">="
67
53
  - !ruby/object:Gem::Version
68
- version: '0'
54
+ version: 1.23.0
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: rack
71
57
  requirement: !ruby/object:Gem::Requirement
@@ -275,7 +261,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
275
261
  - !ruby/object:Gem::Version
276
262
  version: '0'
277
263
  requirements: []
278
- rubygems_version: 3.5.17
264
+ rubygems_version: 3.4.19
279
265
  signing_key:
280
266
  specification_version: 4
281
267
  summary: ''