bima-shark-sdk 2.4.3 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +1 -1
- data/.travis.yml +2 -2
- data/CHANGELOG.md +8 -0
- data/bima-shark-sdk.gemspec +3 -4
- data/lib/shark/client/connection.rb +5 -5
- data/lib/shark/configuration.rb +0 -8
- data/lib/shark/double_opt_in/execution.rb +2 -2
- data/lib/shark/mailing_service/mailer.rb +0 -2
- data/lib/shark/rspec/helpers.rb +0 -1
- data/lib/shark/version.rb +1 -1
- data/lib/shark.rb +0 -1
- metadata +14 -33
- data/lib/shark/rspec/fake_subscription_service/object_cache.rb +0 -54
- data/lib/shark/rspec/fake_subscription_service/request.rb +0 -100
- data/lib/shark/rspec/fake_subscription_service.rb +0 -19
- data/lib/shark/subscription.rb +0 -43
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
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/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
## Changelog
|
2
2
|
|
3
|
+
#### 3.0.0
|
4
|
+
- new minimum requirements are `Ruby 3.0` and `faraday 2.0`
|
5
|
+
- remove `Shark::Subscription`
|
6
|
+
|
7
|
+
#### 2.4.4
|
8
|
+
- lowest supported Ruby version is 2.7
|
9
|
+
- add `recipient` to `Shark::DoubleOptIn::Execution`
|
10
|
+
|
3
11
|
#### 2.4.3
|
4
12
|
- allow `Shark::MailingService::Mailer#mail` to use separate layouts
|
5
13
|
- rename `Shark::MailingService::Mailers::BaseMailer` to `Shark::MailingService::Mailer`
|
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
|
|
data/lib/shark/configuration.rb
CHANGED
@@ -29,12 +29,6 @@ module Shark
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
module SubscriptionService
|
33
|
-
module Resource
|
34
|
-
mattr_accessor :site
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
32
|
module SurveyService
|
39
33
|
module Resource
|
40
34
|
mattr_accessor :site
|
@@ -65,7 +59,6 @@ module Shark
|
|
65
59
|
attr_reader :form_service
|
66
60
|
attr_reader :survey_service
|
67
61
|
attr_reader :notification_service
|
68
|
-
attr_reader :subscription_service
|
69
62
|
attr_reader :asset_service
|
70
63
|
attr_reader :mailing_service
|
71
64
|
|
@@ -76,7 +69,6 @@ module Shark
|
|
76
69
|
@form_service = Service.new
|
77
70
|
@mailing_service = Service.new
|
78
71
|
@notification_service = NotificationService::Resource
|
79
|
-
@subscription_service = SubscriptionService::Resource
|
80
72
|
@survey_service = SurveyService::Resource
|
81
73
|
end
|
82
74
|
end
|
@@ -5,7 +5,7 @@ module Shark
|
|
5
5
|
class Execution < Base
|
6
6
|
extend DoubleOptIn::Resource
|
7
7
|
|
8
|
-
attr_accessor :payload, :request_type
|
8
|
+
attr_accessor :payload, :request_type, :recipient
|
9
9
|
|
10
10
|
def self.verify(verification_token)
|
11
11
|
response = connection.run(:post, "/executions/#{verification_token}/verify")
|
@@ -37,7 +37,7 @@ module Shark
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def initialize(data)
|
40
|
-
%w[payload request_type].each do |key|
|
40
|
+
%w[payload request_type recipient].each do |key|
|
41
41
|
public_send("#{key}=", data['attributes'][key])
|
42
42
|
end
|
43
43
|
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_subscription_service'
|
9
8
|
require_relative 'fake_double_opt_in'
|
10
9
|
require_relative 'fake_mailing_service'
|
11
10
|
require_relative 'fake_survey_service'
|
data/lib/shark/version.rb
CHANGED
data/lib/shark.rb
CHANGED
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
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
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
|
@@ -244,9 +230,6 @@ files:
|
|
244
230
|
- lib/shark/rspec/fake_mailing_service/request.rb
|
245
231
|
- lib/shark/rspec/fake_notification_service.rb
|
246
232
|
- lib/shark/rspec/fake_notification_service/request.rb
|
247
|
-
- lib/shark/rspec/fake_subscription_service.rb
|
248
|
-
- lib/shark/rspec/fake_subscription_service/object_cache.rb
|
249
|
-
- lib/shark/rspec/fake_subscription_service/request.rb
|
250
233
|
- lib/shark/rspec/fake_survey_service.rb
|
251
234
|
- lib/shark/rspec/fake_survey_service/object_cache.rb
|
252
235
|
- lib/shark/rspec/fake_survey_service/request.rb
|
@@ -257,14 +240,13 @@ files:
|
|
257
240
|
- lib/shark/rspec/helpers/fixtures.rb
|
258
241
|
- lib/shark/rspec/helpers/form_service_helper.rb
|
259
242
|
- lib/shark/rspec/helpers/response.rb
|
260
|
-
- lib/shark/subscription.rb
|
261
243
|
- lib/shark/survey.rb
|
262
244
|
- lib/shark/survey_participant.rb
|
263
245
|
- lib/shark/version.rb
|
264
246
|
homepage: https://github.com/infopark-customers/bima-shark-sdk
|
265
247
|
licenses: []
|
266
248
|
metadata: {}
|
267
|
-
post_install_message:
|
249
|
+
post_install_message:
|
268
250
|
rdoc_options: []
|
269
251
|
require_paths:
|
270
252
|
- lib
|
@@ -279,9 +261,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
279
261
|
- !ruby/object:Gem::Version
|
280
262
|
version: '0'
|
281
263
|
requirements: []
|
282
|
-
|
283
|
-
|
284
|
-
signing_key:
|
264
|
+
rubygems_version: 3.4.19
|
265
|
+
signing_key:
|
285
266
|
specification_version: 4
|
286
267
|
summary: ''
|
287
268
|
test_files: []
|
@@ -1,54 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Shark
|
4
|
-
module RSpec
|
5
|
-
module FakeSubscriptionService
|
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.delete('id')
|
20
|
-
|
21
|
-
if id && !objects.find { |subscription| subscription['id'] == id }
|
22
|
-
object = {
|
23
|
-
id: id,
|
24
|
-
attributes: payload_data
|
25
|
-
}
|
26
|
-
|
27
|
-
objects << object
|
28
|
-
else
|
29
|
-
objects << {
|
30
|
-
id: SecureRandom.uuid,
|
31
|
-
attributes: payload_data
|
32
|
-
}
|
33
|
-
end
|
34
|
-
objects.last
|
35
|
-
end
|
36
|
-
|
37
|
-
def add_multiple(payload_data)
|
38
|
-
added = []
|
39
|
-
payload_data.each { |subscription| added << add(subscription) }
|
40
|
-
added.compact
|
41
|
-
end
|
42
|
-
|
43
|
-
def remove(id)
|
44
|
-
objects.delete_if { |subscription| subscription[:id] == id }
|
45
|
-
end
|
46
|
-
|
47
|
-
def remove_multiple(payload_data)
|
48
|
-
payload_data.each { |subscription| remove(subscription['id']) }
|
49
|
-
objects
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
@@ -1,100 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'webmock/rspec'
|
4
|
-
|
5
|
-
module Shark
|
6
|
-
module RSpec
|
7
|
-
module FakeSubscriptionService
|
8
|
-
class Request
|
9
|
-
include Singleton
|
10
|
-
|
11
|
-
ALLOWED_FILTERS = %w[name subscriberId].freeze
|
12
|
-
|
13
|
-
def self.setup
|
14
|
-
instance = self.instance
|
15
|
-
instance.stub_requests
|
16
|
-
end
|
17
|
-
|
18
|
-
def stub_requests
|
19
|
-
WebMock.stub_request(:post, %r{^#{host}/subscriptions}).to_return do |request|
|
20
|
-
log_info "Faking POST request with body: #{request.body}"
|
21
|
-
|
22
|
-
payload_data = JSON.parse(request.body)['data']['attributes']
|
23
|
-
|
24
|
-
object_data = ObjectCache.instance.add(payload_data)
|
25
|
-
|
26
|
-
SharkSpec.fake_response(201, data: object_data)
|
27
|
-
end
|
28
|
-
|
29
|
-
WebMock.stub_request(
|
30
|
-
:post,
|
31
|
-
%r{^#{host}/subscriptions/bulk_creation}
|
32
|
-
).to_return do |request|
|
33
|
-
log_info "Faking POST request with body: #{request.body}"
|
34
|
-
|
35
|
-
payload_data = JSON.parse(request.body)['data']['attributes']['subscriptions']
|
36
|
-
|
37
|
-
objects_data = ObjectCache.instance.add_multiple(payload_data)
|
38
|
-
|
39
|
-
SharkSpec.fake_response(201, data: objects_data)
|
40
|
-
end
|
41
|
-
|
42
|
-
WebMock.stub_request(
|
43
|
-
:post,
|
44
|
-
%r{^#{host}/subscriptions/bulk_deletion}
|
45
|
-
).to_return do |request|
|
46
|
-
log_info "Faking POST request with body: #{request.body}"
|
47
|
-
|
48
|
-
payload_data = JSON.parse(request.body)['data']['attributes']['subscriptions']
|
49
|
-
ObjectCache.instance.remove_multiple(payload_data)
|
50
|
-
|
51
|
-
SharkSpec.fake_response(204, nil)
|
52
|
-
end
|
53
|
-
|
54
|
-
WebMock.stub_request(:delete, %r{^#{host}/subscriptions/.+}).to_return do |request|
|
55
|
-
log_info "Faking DELETE request with body: #{request.body}"
|
56
|
-
|
57
|
-
id = request.uri.path.split('/')[2]
|
58
|
-
|
59
|
-
ObjectCache.instance.remove(id)
|
60
|
-
|
61
|
-
SharkSpec.fake_response(204, nil)
|
62
|
-
end
|
63
|
-
|
64
|
-
WebMock.stub_request(:get, %r{^#{host}/subscriptions}).to_return do |request|
|
65
|
-
log_info 'Faking GET request'
|
66
|
-
|
67
|
-
query_parameters = request.uri.query_values
|
68
|
-
|
69
|
-
objects_data = if query_parameters
|
70
|
-
params = {}
|
71
|
-
query_parameters.each do |key, value|
|
72
|
-
parsed_key = key.match(/filter\[(.*)\]/)[1].camelize(:lower)
|
73
|
-
params[parsed_key] = value if ALLOWED_FILTERS.include?(parsed_key)
|
74
|
-
end
|
75
|
-
|
76
|
-
ObjectCache.instance.objects.select do |subscription|
|
77
|
-
conditions = params.map do |param, value|
|
78
|
-
subscription[:attributes][param] == value
|
79
|
-
end
|
80
|
-
conditions.all?
|
81
|
-
end
|
82
|
-
else
|
83
|
-
ObjectCache.instance.objects
|
84
|
-
end
|
85
|
-
|
86
|
-
SharkSpec.fake_response(200, data: objects_data)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
def host
|
91
|
-
Shark.configuration.subscription_service.site
|
92
|
-
end
|
93
|
-
|
94
|
-
def log_info(message)
|
95
|
-
Shark.logger.info "[Shark::SubscriptionService] #{message}"
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'fake_subscription_service/object_cache'
|
4
|
-
require_relative 'fake_subscription_service/request'
|
5
|
-
|
6
|
-
module Shark
|
7
|
-
module RSpec
|
8
|
-
module FakeSubscriptionService
|
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
|
data/lib/shark/subscription.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Shark
|
4
|
-
class Subscription < Base
|
5
|
-
extend SubscriptionService::Resource
|
6
|
-
|
7
|
-
custom_endpoint :bulk_creation, on: :collection, request_method: :post
|
8
|
-
custom_endpoint :bulk_deletion, on: :collection, request_method: :post
|
9
|
-
|
10
|
-
def self.create_multiple(attributes)
|
11
|
-
bulk_creation(subscriptions_attributes(attributes))
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.destroy_multiple(attributes)
|
15
|
-
bulk_deletion(subscriptions_attributes(attributes))
|
16
|
-
end
|
17
|
-
|
18
|
-
def save
|
19
|
-
if self['id'].present?
|
20
|
-
raise Shark::ActionNotSupportedError,
|
21
|
-
'Shark::Subscription#save is not supported for persisted subscriptions'
|
22
|
-
else
|
23
|
-
super
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def update_attributes(_attributes = {})
|
28
|
-
raise Shark::ActionNotSupportedError,
|
29
|
-
'Shark::Subscription#update_attributes is not supported'
|
30
|
-
end
|
31
|
-
|
32
|
-
def self.subscriptions_attributes(attributes)
|
33
|
-
{
|
34
|
-
data: {
|
35
|
-
type: 'bulk-subscriptions',
|
36
|
-
attributes: {
|
37
|
-
subscriptions: attributes
|
38
|
-
}
|
39
|
-
}
|
40
|
-
}
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|