bima-shark-sdk 3.0.0 → 3.1.1
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 +4 -4
- data/.travis.yml +1 -1
- data/CHANGELOG.md +6 -0
- data/README.md +15 -0
- data/bin/console +0 -6
- data/lib/shark/client/connection.rb +1 -3
- data/lib/shark/configuration.rb +1 -0
- data/lib/shark/version.rb +1 -1
- data/lib/shark.rb +20 -7
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d78520920a648b39f4efce4f0f09cf03ae7c1b9ae65022311dfc8d6f7e557f82
|
4
|
+
data.tar.gz: 10d37b688c20efe9010f33e0734cbb0fbe5c45eef667c037e4614fb5e132bcd9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79cba1cf92c07d7f73a2344b7de0c6c70d8fe03e0722c7331adcece266d348f4976ac980ad12e3c09d3fcb47f20bbb573bb48b7ac1218353e1de031ebdd8ca63
|
7
|
+
data.tar.gz: 9f6242f47a12c9f7a9761f2eeae415d930546c76346c01390482c024afbf42cb70eb92fd8132855589d3b604bebb0936e9190555bb86e40f6dafd60e7a53b095
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
## Changelog
|
2
2
|
|
3
|
+
#### 3.1.1
|
4
|
+
- Extend Shark::Configuration with `access_id` and `secret_key`
|
5
|
+
|
6
|
+
#### 3.1.0
|
7
|
+
- Extend `with_service_token` with `with_auth_token` which allows to send custom `Authorization` header, not only `Bearer`
|
8
|
+
|
3
9
|
#### 3.0.0
|
4
10
|
- new minimum requirements are `Ruby 3.0` and `faraday 2.0`
|
5
11
|
- remove `Shark::Subscription`
|
data/README.md
CHANGED
@@ -42,6 +42,21 @@ 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
|
+
|
45
60
|
## Testing
|
46
61
|
|
47
62
|
```
|
data/bin/console
CHANGED
@@ -7,17 +7,11 @@ require 'shark'
|
|
7
7
|
# You can add fixtures and/or initialization code here to make experimenting
|
8
8
|
# with your gem easier. You can also use a different console, if you like.
|
9
9
|
|
10
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
-
# require "pry"
|
12
|
-
# Pry.start
|
13
|
-
|
14
|
-
# TODO
|
15
10
|
Shark.configure do |config|
|
16
11
|
config.contact_service.site = 'https://contactservice-development.bundesimmo.de/api/'
|
17
12
|
config.survey_service.site = 'https://milacrm-development.bundesimmo.de/api/v1/'
|
18
13
|
config.form_service.site = 'https://formservice-development.bundesimmo.de/api/v1/'
|
19
14
|
config.notification_service.site = 'https://api-development.bundesimmo.de/notification-service/'
|
20
|
-
config.subscription_service.site = 'https://api-development.bundesimmo.de/subscription-service/'
|
21
15
|
end
|
22
16
|
|
23
17
|
require 'irb'
|
@@ -38,9 +38,7 @@ module Shark
|
|
38
38
|
request_headers = connection_options_headers.merge(headers || {})
|
39
39
|
request_params = connection_options_params.merge(params || {})
|
40
40
|
|
41
|
-
if Shark.
|
42
|
-
request_headers['Authorization'] = "Bearer #{Shark.service_token}"
|
43
|
-
end
|
41
|
+
request_headers['Authorization'] = Shark.auth_token if Shark.auth_token.present?
|
44
42
|
|
45
43
|
@connection.send(request_action) do |request|
|
46
44
|
request.url(url)
|
data/lib/shark/configuration.rb
CHANGED
data/lib/shark/version.rb
CHANGED
data/lib/shark.rb
CHANGED
@@ -34,26 +34,39 @@ module Shark
|
|
34
34
|
# @api public
|
35
35
|
def self.with_service_token(token)
|
36
36
|
if token.is_a?(String)
|
37
|
-
|
37
|
+
auth_token = "Bearer #{token}"
|
38
38
|
elsif token.respond_to?(:jwt)
|
39
|
-
|
39
|
+
auth_token = "Bearer #{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)
|
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
|
+
|
44
57
|
yield
|
45
58
|
ensure
|
46
|
-
self.
|
59
|
+
self.auth_token = nil
|
47
60
|
end
|
48
61
|
|
49
62
|
# @api public
|
50
|
-
def self.
|
51
|
-
Thread.current['shark-
|
63
|
+
def self.auth_token
|
64
|
+
Thread.current['shark-auth-token']
|
52
65
|
end
|
53
66
|
|
54
67
|
# @api private
|
55
|
-
def self.
|
56
|
-
Thread.current['shark-
|
68
|
+
def self.auth_token=(value)
|
69
|
+
Thread.current['shark-auth-token'] = value
|
57
70
|
end
|
58
71
|
|
59
72
|
#
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bima-shark-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.1.1
|
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-11-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -261,7 +261,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
261
261
|
- !ruby/object:Gem::Version
|
262
262
|
version: '0'
|
263
263
|
requirements: []
|
264
|
-
rubygems_version: 3.
|
264
|
+
rubygems_version: 3.2.22
|
265
265
|
signing_key:
|
266
266
|
specification_version: 4
|
267
267
|
summary: ''
|