bima-shark-sdk 2.4.2 → 2.4.4

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
- SHA1:
3
- metadata.gz: a940bf61424a49baa7f04791ca42ba61bb145a97
4
- data.tar.gz: 734da4e58e55397a983e31ac9e53aa372e664a7b
2
+ SHA256:
3
+ metadata.gz: e003bacef5ad3777bebedc0d3cc6998774649c19f9d01feceaf3353491368c5e
4
+ data.tar.gz: 744acc3e2be82f620f064a8d01b9f858939ff0fc28ec35f2b5fd9ea6b86f8d06
5
5
  SHA512:
6
- metadata.gz: 7c1ade4eaefb81ae08c8e799d29bd6caf4b4ff1f355df7f4382c9bd0cddb3dcc0b3b0022fb4c68ffeb6d3278a95cca50a04b3076002ff1d1e5a5e9688881b36a
7
- data.tar.gz: 12186155c320e2254eed1d4e4dcfe47ac31b2f540e5d5470d15472c3b333d9915fc75347795762be86438c7d556e004d85d2f02235bd89d5913e32f62709d763
6
+ metadata.gz: 7bd2cbb0c39408763febc462074a670cf29a5afdcdaa9e8cf6c7407e7a6d3343829ce291a13361434764b29e9a7b30d7f94f9c09bd2101f73e38b802d77490b8
7
+ data.tar.gz: bce739bb923bc2aba6dba2095ba000781fe3e2fcc4b44324e328aba34662dbd147373d369cb29bf8929b5babdd1dc2f987a14029318726bde30e602a6ad68f9d
data/.rubocop.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.3
2
+ TargetRubyVersion: 2.7
3
3
  Exclude:
4
4
  - 'config/routes.rb'
5
5
  - 'db/schema.rb'
data/.travis.yml CHANGED
@@ -1,8 +1,8 @@
1
1
  language: ruby
2
2
  cache: bundler
3
3
  rvm:
4
- - 2.3.8
5
- - 2.5.7
4
+ - 2.7.6
5
+ - 3.0.2
6
6
  before_install:
7
7
  - gem install bundler -v '~> 1.17'
8
8
  script:
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  ## Changelog
2
2
 
3
+ #### 2.4.4
4
+ * lowest supported Ruby version is 2.7
5
+ * add `recipient` to `Shark::DoubleOptIn::Execution`
6
+
7
+ #### 2.4.3
8
+ - allow `Shark::MailingService::Mailer#mail` to use separate layouts
9
+ - rename `Shark::MailingService::Mailers::BaseMailer` to `Shark::MailingService::Mailer`
10
+
3
11
  #### 2.4.2
4
12
  - [fix] don't swallow connection errors
5
13
 
@@ -7,8 +7,8 @@ require 'shark/version'
7
7
  Gem::Specification.new do |spec|
8
8
  spec.name = 'bima-shark-sdk'
9
9
  spec.version = Shark::VERSION
10
- spec.authors = ['Huy Dinh', 'Johannes Schmeißer', 'Joergen Dahlke']
11
- spec.email = ['bima-team@infopark.de']
10
+ spec.authors = ['bima-team@justrelate.com']
11
+ spec.email = ['bima-team@justrelate.com']
12
12
 
13
13
  spec.summary = ''
14
14
  spec.description = ''
@@ -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
@@ -0,0 +1,98 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Shark
4
+ module MailingService
5
+ class Mailer
6
+ class << self
7
+ attr_writer :layout, :template_root
8
+
9
+ def layout
10
+ @layout || MailingService.config.default_layout
11
+ end
12
+
13
+ def method_missing(method, *args, &block)
14
+ return super unless respond_to?(method)
15
+
16
+ instance = new(
17
+ layout: layout,
18
+ template_name: method.to_s,
19
+ template_path: File.join(template_root.to_s, name.underscore)
20
+ )
21
+ instance.send(method, *args)
22
+ instance
23
+ end
24
+
25
+ def template_root
26
+ @template_root || MailingService.config.default_template_root
27
+ end
28
+
29
+ protected
30
+
31
+ def respond_to_missing?(method, include_private = false)
32
+ known_methods = if include_private
33
+ instance_methods(false)
34
+ else
35
+ public_instance_methods(false)
36
+ end
37
+ known_methods.include?(method)
38
+ end
39
+ end
40
+
41
+ attr_reader :layout, :template_name, :template_path
42
+
43
+ def initialize(layout:, template_path:, template_name:)
44
+ @layout = layout
45
+ @template_name = template_name
46
+ @template_path = template_path
47
+ end
48
+
49
+ def deliver
50
+ @mail.save
51
+ end
52
+ alias deliver_now deliver
53
+
54
+ protected
55
+
56
+ def body(format, locals = {})
57
+ renderer.render(template_name, format, locals)
58
+ end
59
+
60
+ def attribute_with_default(attributes, attribute)
61
+ return attributes[attribute] if attributes.key?(attribute)
62
+
63
+ I18n.t!("#{self.class.name.underscore}.#{template_name}.#{attribute}")
64
+ rescue StandardError
65
+ nil
66
+ end
67
+
68
+ def mail(attributes)
69
+ locals = attributes[:locals] || {}
70
+ mail_attributes = {
71
+ layout: attributes[:layout] || layout,
72
+ reply_to: attributes[:reply_to],
73
+ recipient: attributes[:to],
74
+ subject: attribute_with_default(attributes, :subject),
75
+ header: attribute_with_default(attributes, :header),
76
+ sub_header: attribute_with_default(attributes, :sub_header),
77
+ html_body: body(:html, locals),
78
+ text_body: body(:text, locals),
79
+ attachments: attributes[:attachments] || {}
80
+ }
81
+ %i[from header_image reply_to unsubscribe_url].each do |key|
82
+ value = attributes[key]
83
+ mail_attributes[key] = value if value.present?
84
+ end
85
+
86
+ @mail = Shark::MailingService::Mail.new(mail_attributes)
87
+ end
88
+
89
+ def renderer
90
+ @renderer ||= Renderers::ErbRenderer.new(template_path)
91
+ end
92
+ end
93
+
94
+ module Mailers
95
+ BaseMailer = MailingService::Mailer
96
+ end
97
+ end
98
+ end
@@ -10,7 +10,7 @@ module Shark
10
10
  require 'shark/mailing_service/configuration'
11
11
  require 'shark/mailing_service/renderers/context'
12
12
  require 'shark/mailing_service/renderers/erb_renderer'
13
- require 'shark/mailing_service/mailers/base_mailer'
13
+ require 'shark/mailing_service/mailer'
14
14
 
15
15
  yield(config)
16
16
  end
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.4.2'
4
+ VERSION = '2.4.4'
5
5
  end
metadata CHANGED
@@ -1,16 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bima-shark-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.2
4
+ version: 2.4.4
5
5
  platform: ruby
6
6
  authors:
7
- - Huy Dinh
8
- - Johannes Schmeißer
9
- - Joergen Dahlke
10
- autorequire:
7
+ - bima-team@justrelate.com
8
+ autorequire:
11
9
  bindir: exe
12
10
  cert_chain: []
13
- date: 2022-10-12 00:00:00.000000000 Z
11
+ date: 2024-04-10 00:00:00.000000000 Z
14
12
  dependencies:
15
13
  - !ruby/object:Gem::Dependency
16
14
  name: activesupport
@@ -168,7 +166,7 @@ dependencies:
168
166
  version: '2.3'
169
167
  description: ''
170
168
  email:
171
- - bima-team@infopark.de
169
+ - bima-team@justrelate.com
172
170
  executables: []
173
171
  extensions: []
174
172
  extra_rdoc_files: []
@@ -222,7 +220,7 @@ files:
222
220
  - lib/shark/mailing_service/base.rb
223
221
  - lib/shark/mailing_service/configuration.rb
224
222
  - lib/shark/mailing_service/mail.rb
225
- - lib/shark/mailing_service/mailers/base_mailer.rb
223
+ - lib/shark/mailing_service/mailer.rb
226
224
  - lib/shark/mailing_service/renderers/context.rb
227
225
  - lib/shark/mailing_service/renderers/erb_renderer.rb
228
226
  - lib/shark/membership.rb
@@ -266,7 +264,7 @@ files:
266
264
  homepage: https://github.com/infopark-customers/bima-shark-sdk
267
265
  licenses: []
268
266
  metadata: {}
269
- post_install_message:
267
+ post_install_message:
270
268
  rdoc_options: []
271
269
  require_paths:
272
270
  - lib
@@ -281,9 +279,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
281
279
  - !ruby/object:Gem::Version
282
280
  version: '0'
283
281
  requirements: []
284
- rubyforge_project:
285
- rubygems_version: 2.5.2.3
286
- signing_key:
282
+ rubygems_version: 3.2.22
283
+ signing_key:
287
284
  specification_version: 4
288
285
  summary: ''
289
286
  test_files: []
@@ -1,96 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Shark
4
- module MailingService
5
- module Mailers
6
- class BaseMailer
7
- class << self
8
- attr_writer :layout, :template_root
9
-
10
- def layout
11
- @layout || MailingService.config.default_layout
12
- end
13
-
14
- def method_missing(method, *args, &block)
15
- return super unless respond_to?(method)
16
-
17
- instance = new(
18
- layout: layout,
19
- template_name: method.to_s,
20
- template_path: File.join(template_root.to_s, name.underscore)
21
- )
22
- instance.send(method, *args)
23
- instance
24
- end
25
-
26
- def template_root
27
- @template_root || MailingService.config.default_template_root
28
- end
29
-
30
- protected
31
-
32
- def respond_to_missing?(method, include_private = false)
33
- known_methods = if include_private
34
- instance_methods(false)
35
- else
36
- public_instance_methods(false)
37
- end
38
- known_methods.include?(method)
39
- end
40
- end
41
-
42
- attr_reader :layout, :template_name, :template_path
43
-
44
- def initialize(layout:, template_path:, template_name:)
45
- @layout = layout
46
- @template_name = template_name
47
- @template_path = template_path
48
- end
49
-
50
- def deliver
51
- @mail.save
52
- end
53
- alias deliver_now deliver
54
-
55
- protected
56
-
57
- def body(format, locals = {})
58
- renderer.render(template_name, format, locals)
59
- end
60
-
61
- def attribute_with_default(attributes, attribute)
62
- return attributes[attribute] if attributes.key?(attribute)
63
-
64
- I18n.t!("#{self.class.name.underscore}.#{template_name}.#{attribute}")
65
- rescue StandardError
66
- nil
67
- end
68
-
69
- def mail(attributes)
70
- locals = attributes[:locals] || {}
71
- mail_attributes = {
72
- layout: layout,
73
- reply_to: attributes[:reply_to],
74
- recipient: attributes[:to],
75
- subject: attribute_with_default(attributes, :subject),
76
- header: attribute_with_default(attributes, :header),
77
- sub_header: attribute_with_default(attributes, :sub_header),
78
- html_body: body(:html, locals),
79
- text_body: body(:text, locals),
80
- attachments: attributes[:attachments] || {}
81
- }
82
- %i[from header_image reply_to unsubscribe_url].each do |key|
83
- value = attributes[key]
84
- mail_attributes[key] = value if value.present?
85
- end
86
-
87
- @mail = Shark::MailingService::Mail.new(mail_attributes)
88
- end
89
-
90
- def renderer
91
- @renderer ||= Renderers::ErbRenderer.new(template_path)
92
- end
93
- end
94
- end
95
- end
96
- end