bima-shark-sdk 2.3.1 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/shark/configuration.rb +0 -7
- data/lib/shark/consent.rb +5 -8
- data/lib/shark/contact.rb +8 -0
- data/lib/shark/contract.rb +28 -0
- data/lib/shark/rspec/helpers.rb +0 -1
- data/lib/shark/version.rb +1 -1
- data/lib/shark.rb +1 -0
- metadata +3 -5
- data/lib/shark/rspec/fake_consent_service/object_cache.rb +0 -44
- data/lib/shark/rspec/fake_consent_service/request.rb +0 -53
- data/lib/shark/rspec/fake_consent_service.rb +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5cd9e83af8c7d48a3ca87715aa3743e6195a3e85
|
4
|
+
data.tar.gz: 2fe2155fa9f5e1619791a6c988b7d77aaa22a61d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96753859d7e2363bbadab88a43699da4c953c62289e2121a42486997aa35d5558496affc6ef478e94699df38c5508c0eac195e0d54641d92c4886a50ffd15d39
|
7
|
+
data.tar.gz: 309c64b4042225ef5f345bd48fbc573a0fb9daeaaf74f411b7994622786dbd3d93dfa0097ce1d4e32125da146f32b8385f3ccb9ce218efaefa9f2c92afb0dcb8
|
data/CHANGELOG.md
CHANGED
data/lib/shark/configuration.rb
CHANGED
@@ -13,12 +13,6 @@ module Shark
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
module ConsentService
|
17
|
-
module Resource
|
18
|
-
mattr_accessor :site
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
16
|
module DoubleOptIn
|
23
17
|
class ExceededNumberOfVerificationRequestsError < Error; end
|
24
18
|
class RequestedUnverifiedExecutionError < Error; end
|
@@ -78,7 +72,6 @@ module Shark
|
|
78
72
|
def initialize
|
79
73
|
@asset_service = AssetService::Resource
|
80
74
|
@contact_service = ContactService::Resource
|
81
|
-
@consent_service = ConsentService::Resource
|
82
75
|
@double_opt_in = DoubleOptIn::Resource
|
83
76
|
@form_service = Service.new
|
84
77
|
@mailing_service = Service.new
|
data/lib/shark/consent.rb
CHANGED
@@ -2,27 +2,24 @@
|
|
2
2
|
|
3
3
|
module Shark
|
4
4
|
class Consent < Base
|
5
|
-
extend
|
5
|
+
extend ContactService::Resource
|
6
6
|
|
7
|
-
|
8
|
-
raise Shark::ActionNotSupportedError,
|
9
|
-
'Shark::ConsentService::Consent.all is not supported'
|
10
|
-
end
|
7
|
+
belongs_to :contact
|
11
8
|
|
12
9
|
def update_attributes(_attributes = {})
|
13
10
|
raise Shark::ActionNotSupportedError,
|
14
|
-
'Shark::
|
11
|
+
'Shark::Consent#update_attributes is not supported'
|
15
12
|
end
|
16
13
|
|
17
14
|
def destroy
|
18
15
|
raise Shark::ActionNotSupportedError,
|
19
|
-
'Shark::
|
16
|
+
'Shark::Consent#destroy is not supported'
|
20
17
|
end
|
21
18
|
|
22
19
|
def save
|
23
20
|
if self['id'].present?
|
24
21
|
raise Shark::ActionNotSupportedError,
|
25
|
-
'Shark::
|
22
|
+
'Shark::Consent#save is not supported for persisted consents'
|
26
23
|
else
|
27
24
|
super
|
28
25
|
end
|
data/lib/shark/contact.rb
CHANGED
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Shark
|
4
|
+
class Contract < Base
|
5
|
+
extend ContactService::Resource
|
6
|
+
|
7
|
+
belongs_to :contact
|
8
|
+
|
9
|
+
def update_attributes(_attributes = {})
|
10
|
+
raise Shark::ActionNotSupportedError,
|
11
|
+
'Shark::Contract#update_attributes is not supported'
|
12
|
+
end
|
13
|
+
|
14
|
+
def destroy
|
15
|
+
raise Shark::ActionNotSupportedError,
|
16
|
+
'Shark::Contract#destroy is not supported'
|
17
|
+
end
|
18
|
+
|
19
|
+
def save
|
20
|
+
if self['id'].present?
|
21
|
+
raise Shark::ActionNotSupportedError,
|
22
|
+
'Shark::Contract#save is not supported for persisted consents'
|
23
|
+
else
|
24
|
+
super
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/shark/rspec/helpers.rb
CHANGED
@@ -5,7 +5,6 @@ require_relative 'helpers/cache_helper'
|
|
5
5
|
require_relative 'fake_asset_service'
|
6
6
|
require_relative 'fake_contact_service'
|
7
7
|
require_relative 'fake_notification_service'
|
8
|
-
require_relative 'fake_consent_service'
|
9
8
|
require_relative 'fake_subscription_service'
|
10
9
|
require_relative 'fake_double_opt_in'
|
11
10
|
require_relative 'fake_mailing_service'
|
data/lib/shark/version.rb
CHANGED
data/lib/shark.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bima-shark-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Huy Dinh
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2022-01-
|
13
|
+
date: 2022-01-10 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -199,6 +199,7 @@ files:
|
|
199
199
|
- lib/shark/consent.rb
|
200
200
|
- lib/shark/contact.rb
|
201
201
|
- lib/shark/contact_log.rb
|
202
|
+
- lib/shark/contract.rb
|
202
203
|
- lib/shark/double_opt_in/execution.rb
|
203
204
|
- lib/shark/double_opt_in/request.rb
|
204
205
|
- lib/shark/error.rb
|
@@ -235,9 +236,6 @@ files:
|
|
235
236
|
- lib/shark/rspec/fake_asset_service/object_cache.rb
|
236
237
|
- lib/shark/rspec/fake_asset_service/public_id.rb
|
237
238
|
- lib/shark/rspec/fake_asset_service/request.rb
|
238
|
-
- lib/shark/rspec/fake_consent_service.rb
|
239
|
-
- lib/shark/rspec/fake_consent_service/object_cache.rb
|
240
|
-
- lib/shark/rspec/fake_consent_service/request.rb
|
241
239
|
- lib/shark/rspec/fake_contact_service.rb
|
242
240
|
- lib/shark/rspec/fake_contact_service/object_cache.rb
|
243
241
|
- lib/shark/rspec/fake_contact_service/request.rb
|
@@ -1,44 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Shark
|
4
|
-
module RSpec
|
5
|
-
module FakeConsentService
|
6
|
-
class ObjectCache
|
7
|
-
include Singleton
|
8
|
-
attr_accessor :objects
|
9
|
-
|
10
|
-
def initialize
|
11
|
-
@objects = []
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.clear
|
15
|
-
instance.objects = []
|
16
|
-
end
|
17
|
-
|
18
|
-
def add(payload_data)
|
19
|
-
id = payload_data['attributes']['legal_subject_id']
|
20
|
-
existing_object = objects.detect { |o| o['id'] == id }
|
21
|
-
|
22
|
-
items = (existing_object.present? && existing_object['attributes']['items']) || {}
|
23
|
-
|
24
|
-
(payload_data['attributes']['items'] || {}).each do |name, attrs|
|
25
|
-
items[name] = attrs.merge({ 'updated_at' => Time.now })
|
26
|
-
end
|
27
|
-
|
28
|
-
objects.delete_if { |o| o['id'] == id }
|
29
|
-
|
30
|
-
object = {
|
31
|
-
'id' => id,
|
32
|
-
'attributes' => {
|
33
|
-
'items' => items
|
34
|
-
},
|
35
|
-
'type' => 'consents'
|
36
|
-
}
|
37
|
-
|
38
|
-
objects.push(object)
|
39
|
-
object
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
@@ -1,53 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'webmock/rspec'
|
4
|
-
|
5
|
-
module Shark
|
6
|
-
module RSpec
|
7
|
-
module FakeConsentService
|
8
|
-
class Request
|
9
|
-
include Singleton
|
10
|
-
|
11
|
-
def self.setup
|
12
|
-
instance = self.instance
|
13
|
-
instance.stub_requests
|
14
|
-
end
|
15
|
-
|
16
|
-
def stub_requests
|
17
|
-
WebMock.stub_request(:post, %r{^#{host}/consents}).to_return do |request|
|
18
|
-
log_info "[Shark][ConsentService] Faking POST request with body: #{request.body}"
|
19
|
-
|
20
|
-
payload_data = JSON.parse(request.body)['data']
|
21
|
-
object_data = ObjectCache.instance.add(payload_data)
|
22
|
-
|
23
|
-
SharkSpec.fake_response(200, data: object_data)
|
24
|
-
end
|
25
|
-
|
26
|
-
WebMock.stub_request(:get, %r{^#{host}/consents/.+}).to_return do |request|
|
27
|
-
log_info '[Shark][ConsentService] Faking GET request'
|
28
|
-
|
29
|
-
id = request.uri.path.split('/')[2]
|
30
|
-
|
31
|
-
object_data = ObjectCache.instance.objects.detect do |object|
|
32
|
-
object['id'] == id
|
33
|
-
end
|
34
|
-
|
35
|
-
if object_data.present?
|
36
|
-
SharkSpec.fake_response(200, data: object_data)
|
37
|
-
else
|
38
|
-
SharkSpec.fake_response(404, errors: [])
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def host
|
44
|
-
Shark.configuration.consent_service.site
|
45
|
-
end
|
46
|
-
|
47
|
-
def log_info(message)
|
48
|
-
Shark.logger.info message
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'fake_consent_service/object_cache'
|
4
|
-
require_relative 'fake_consent_service/request'
|
5
|
-
|
6
|
-
module Shark
|
7
|
-
module RSpec
|
8
|
-
module FakeConsentService
|
9
|
-
def self.setup
|
10
|
-
ObjectCache.clear
|
11
|
-
Request.setup
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.reset
|
15
|
-
ObjectCache.clear
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|