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 +4 -4
- data/.travis.yml +1 -1
- data/CHANGELOG.md +4 -4
- data/README.md +0 -15
- data/bima-shark-sdk.gemspec +3 -4
- data/lib/shark/client/connection.rb +8 -6
- data/lib/shark/version.rb +1 -1
- data/lib/shark.rb +8 -21
- metadata +11 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c3d5438f91e3e0715d520cae493446b62571f4f63baa1dcf4b4ff1ce9a97380
|
4
|
+
data.tar.gz: 7d321474ad227eabb72a5c9f64806e2219a606ce9b804b1c36bf78b8e6176b48
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '078265caf5dd06022b0ae91356fd4bd9f8093a879c1191a55297280786be708950652563cf1d5ccb9df8a51c5b9bec7a66f7f8b534eb865ad6142b757310a216'
|
7
|
+
data.tar.gz: ae7031d4aee957a60d2791122b650a713c77b75fa0c661b84444830cc463c5f40ac69dda0f19ed296cf22d7acee21f76346973e523ccb8316bf16ce4ed178ab6
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
## Changelog
|
2
2
|
|
3
|
-
####
|
4
|
-
-
|
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
|
-
|
9
|
-
|
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
|
```
|
data/bima-shark-sdk.gemspec
CHANGED
@@ -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'
|
25
|
-
spec.add_dependency 'faraday'
|
26
|
-
spec.add_dependency 'json_api_client', '>= 1.
|
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 |
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
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
|
-
|
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
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
|
35
|
+
def self.with_service_token(token)
|
36
36
|
if token.is_a?(String)
|
37
|
-
|
37
|
+
self.service_token = token
|
38
38
|
elsif token.respond_to?(:jwt)
|
39
|
-
|
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.
|
46
|
+
self.service_token = nil
|
60
47
|
end
|
61
48
|
|
62
49
|
# @api public
|
63
|
-
def self.
|
64
|
-
Thread.current['shark-
|
50
|
+
def self.service_token
|
51
|
+
Thread.current['shark-service-token']
|
65
52
|
end
|
66
53
|
|
67
54
|
# @api private
|
68
|
-
def self.
|
69
|
-
Thread.current['shark-
|
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:
|
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
|
+
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:
|
28
|
+
name: faraday
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
44
30
|
requirements:
|
45
|
-
- - "
|
31
|
+
- - "~>"
|
46
32
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
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:
|
40
|
+
version: '2.0'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
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:
|
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:
|
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.
|
264
|
+
rubygems_version: 3.4.19
|
279
265
|
signing_key:
|
280
266
|
specification_version: 4
|
281
267
|
summary: ''
|