emailbutler 0.8.2 → 0.8.3

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
2
  SHA256:
3
- metadata.gz: 8e223a593bef4c9075afed0fa29d31057519250a0949a589c8535232d632bc83
4
- data.tar.gz: 7355cdbd47a964b9da80cbf0a80203c40865ebc5cec0af272595d105a4cbcb16
3
+ metadata.gz: d753748defc72a9be03be5ce3b5292ac438ccb040babd44955968a73515805f5
4
+ data.tar.gz: 6a962a4ae519be7280a0bf90ec2fa4e1283a7431967d070899164446d74a4b66
5
5
  SHA512:
6
- metadata.gz: 0d92a36b9c851110c9c038f7ef077119cde85fed6f1731531db011649cbbe83fa8d2d1ab1db310a5e8df513014277fb074a9445088ff195d5f649ac7d385a97a
7
- data.tar.gz: 5313f1e26f096577cbc2ad07be23842862ebf9a24b1ccc358a51469130bce50e416b9ffe5e6895b3e14962e43a1f389b271daeca0a0cdedd0516564d270ef632
6
+ metadata.gz: e84a65be9929fee1171136cf07190c42c9d6004171ee080fb87e46ea31587252ad231d7e4530aa1ca05deac266ac0903ca5055f0e20b84d720f26549c96ab64a
7
+ data.tar.gz: cc7bcf25f40122b0efe390b01e8c42cf76eef2fea4894376dec8a2e872cda5ca3ba9aaee858e8666f3417a6a859842480fde431c2394ab4bf11ef61119db5089
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Emailbutler
2
2
  Simple email tracker for Ruby on Rails applications.
3
- Emailbutler allows you to track delivery status of emails sent by your app through Sendgrid, SMTP2GO, Resend.
3
+ Emailbutler allows you to track delivery status of emails sent by your app through Sendgrid, SMTP2GO, Resend, Mailjet.
4
4
 
5
5
  There are situations when you need to check whether a certain letter or certain type of letters was successfully sent from the application, and through the UI of some providers you can try to find such a letter by the recipient or the subject of the letter, but sometimes it's not enough.
6
6
 
@@ -34,7 +34,7 @@ require 'emailbutler/adapters/active_record'
34
34
 
35
35
  Emailbutler.configure do |config|
36
36
  config.adapter = Emailbutler::Adapters::ActiveRecord.new # required
37
- config.providers = %w[sendgrid smtp2go resend] # optional
37
+ config.providers = %w[sendgrid smtp2go resend mailjet] # optional
38
38
  config.ui_username = 'username' # optional
39
39
  config.ui_password = 'password' # optional
40
40
  config.ui_secured_environments = ['production'] # optional
@@ -25,6 +25,7 @@ module Emailbutler
25
25
  when 'sendgrid' then Emailbutler::Container.resolve(:sendgrid_mapper)
26
26
  when 'smtp2go' then Emailbutler::Container.resolve(:smtp2go_mapper)
27
27
  when 'resend' then Emailbutler::Container.resolve(:resend_mapper)
28
+ when 'mailjet' then Emailbutler::Container.resolve(:mailjet_mapper)
28
29
  end
29
30
  end
30
31
 
@@ -33,6 +34,7 @@ module Emailbutler
33
34
  when 'sendgrid' then sendgrid_params
34
35
  when 'smtp2go' then smtp2go_params
35
36
  when 'resend' then resend_params
37
+ when 'mailjet' then mailjet_params
36
38
  end
37
39
  end
38
40
 
@@ -47,5 +49,9 @@ module Emailbutler
47
49
  def resend_params
48
50
  params.permit('type', 'created_at', 'data' => %w[email_id])
49
51
  end
52
+
53
+ def mailjet_params
54
+ params.permit('event', 'time', 'Message_GUID')
55
+ end
50
56
  end
51
57
  end
@@ -7,7 +7,7 @@ module Emailbutler
7
7
  AVAILABLE_ADAPTERS = %w[
8
8
  Emailbutler::Adapters::ActiveRecord
9
9
  ].freeze
10
- AVAILABLE_PROVIDERS = %w[sendgrid smtp2go resend].freeze
10
+ AVAILABLE_PROVIDERS = %w[sendgrid smtp2go resend mailjet].freeze
11
11
 
12
12
  attr_accessor :adapter, :providers, :ui_username, :ui_password, :ui_secured_environments
13
13
 
@@ -4,6 +4,7 @@ require 'dry/container'
4
4
  require 'emailbutler/webhooks/mappers/sendgrid'
5
5
  require 'emailbutler/webhooks/mappers/smtp2go'
6
6
  require 'emailbutler/webhooks/mappers/resend'
7
+ require 'emailbutler/webhooks/mappers/mailjet'
7
8
  require 'emailbutler/webhooks/receiver'
8
9
 
9
10
  module Emailbutler
@@ -22,6 +23,7 @@ module Emailbutler
22
23
  register(:sendgrid_mapper) { Emailbutler::Webhooks::Mappers::Sendgrid.new }
23
24
  register(:smtp2go_mapper) { Emailbutler::Webhooks::Mappers::Smtp2Go.new }
24
25
  register(:resend_mapper) { Emailbutler::Webhooks::Mappers::Resend.new }
26
+ register(:mailjet_mapper) { Emailbutler::Webhooks::Mappers::Mailjet.new }
25
27
 
26
28
  # webhook receiver
27
29
  register(:webhooks_receiver) { Emailbutler::Webhooks::Receiver.new }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Emailbutler
4
- VERSION = '0.8.2'
4
+ VERSION = '0.8.3'
5
5
  end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Emailbutler
4
+ module Webhooks
5
+ module Mappers
6
+ class Mailjet
7
+ DELIVERABILITY_MAPPER = {
8
+ 'sent' => 'processed',
9
+ 'open' => 'delivered',
10
+ 'click' => 'delivered',
11
+ 'unsub' => 'failed',
12
+ 'blocked' => 'failed',
13
+ 'bounce' => 'failed',
14
+ 'spam' => 'failed'
15
+ }.freeze
16
+
17
+ def call(payload:)
18
+ payload.stringify_keys!
19
+ # message-id contains data like <uuid>
20
+ message_uuid = payload['Message_GUID']
21
+ status = DELIVERABILITY_MAPPER[payload['event']]
22
+ return [] if message_uuid.nil? || status.nil?
23
+
24
+ [
25
+ {
26
+ message_uuid: message_uuid,
27
+ status: status,
28
+ timestamp: payload['time'] ? Time.at(payload['time'].to_i).utc.to_datetime : nil
29
+ }
30
+ ]
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -16,7 +16,6 @@ module Emailbutler
16
16
 
17
17
  def call(payload:)
18
18
  payload.stringify_keys!
19
- # message-id contains data like <uuid>
20
19
  message_uuid = payload.dig('data', 'email_id')
21
20
  status = DELIVERABILITY_MAPPER[payload['type']]
22
21
  return [] if message_uuid.nil? || status.nil?
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: emailbutler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.2
4
+ version: 0.8.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bogdanov Anton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-06-16 00:00:00.000000000 Z
11
+ date: 2024-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-container
@@ -136,6 +136,20 @@ dependencies:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
138
  version: '1.39'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rubocop-factory_bot
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '2.0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '2.0'
139
153
  - !ruby/object:Gem::Dependency
140
154
  name: rubocop-performance
141
155
  requirement: !ruby/object:Gem::Requirement
@@ -166,6 +180,20 @@ dependencies:
166
180
  version: '0.6'
167
181
  - !ruby/object:Gem::Dependency
168
182
  name: rubocop-rspec
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: '3.0'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "~>"
193
+ - !ruby/object:Gem::Version
194
+ version: '3.0'
195
+ - !ruby/object:Gem::Dependency
196
+ name: rubocop-rspec_rails
169
197
  requirement: !ruby/object:Gem::Requirement
170
198
  requirements:
171
199
  - - "~>"
@@ -216,6 +244,7 @@ files:
216
244
  - lib/emailbutler/helpers.rb
217
245
  - lib/emailbutler/mailers/helpers.rb
218
246
  - lib/emailbutler/version.rb
247
+ - lib/emailbutler/webhooks/mappers/mailjet.rb
219
248
  - lib/emailbutler/webhooks/mappers/resend.rb
220
249
  - lib/emailbutler/webhooks/mappers/sendgrid.rb
221
250
  - lib/emailbutler/webhooks/mappers/smtp2go.rb