emailbutler 0.8.4 → 0.8.5

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: 60f2148f4793cad24e9b23a458dc30a5501bb9bc18dd33690876bb5063a58f6b
4
- data.tar.gz: 9fa0ddc6da65ba27422abe993f1ab767f0cfb347925a89a4ebfe77b392d9bc65
3
+ metadata.gz: 296cc3406157af31f3ec46810d33662b75f630ce784d1417c2e2ec911c314718
4
+ data.tar.gz: f5829e5fa9b3d06f276fdc00615fa37495d507c65f9931ff9bbd682050debed1
5
5
  SHA512:
6
- metadata.gz: 9356fdca863bdd820bdca2526e3f2b90e09dee401bf0a499664ee9eecca8766ba6e8e415228965732cc0b8db192d0669a81b86b8165abfc8c09fb3733e52ccc5
7
- data.tar.gz: e3135c5e199dd2e55804825ffb194d9de3de118bd898eab10040e84cef889b93ff72cbdacc2c72d79550629d4b20b16416bed5d40ee26f08e239191245791fa2
6
+ metadata.gz: e074e7b90157b378365d76efd5295246219336e41330f349e68dc8a3ad4cd3fad309d0549a653754a30110055016ccf3337bfe4b939c560f79c96c844551ed8b
7
+ data.tar.gz: ce64d8fac91538107a2afb78ab84011de22c08eb08e726bc97dbb5da241e0178d2ed90ac92edfb007c72987bb0089c2c528e8b67fa529f3e740acde9dbc99e45
data/README.md CHANGED
@@ -36,7 +36,7 @@ require 'emailbutler/adapters/active_record'
36
36
 
37
37
  Emailbutler.configure do |config|
38
38
  config.adapter = Emailbutler::Adapters::ActiveRecord.new # required
39
- config.providers = %w[sendgrid smtp2go resend mailjet] # optional
39
+ config.providers = %w[sendgrid smtp2go resend mailjet mailtrap mandrill] # optional
40
40
  config.ui_username = 'username' # optional
41
41
  config.ui_password = 'password' # optional
42
42
  config.ui_secured_environments = ['production'] # optional
@@ -26,6 +26,8 @@ module Emailbutler
26
26
  when 'smtp2go' then Emailbutler::Container.resolve(:smtp2go_mapper)
27
27
  when 'resend' then Emailbutler::Container.resolve(:resend_mapper)
28
28
  when 'mailjet' then Emailbutler::Container.resolve(:mailjet_mapper)
29
+ when 'mailtrap' then Emailbutler::Container.resolve(:mailtrap_mapper)
30
+ when 'mandrill' then Emailbutler::Container.resolve(:mandrill_mapper)
29
31
  end
30
32
  end
31
33
 
@@ -35,6 +37,8 @@ module Emailbutler
35
37
  when 'smtp2go' then smtp2go_params
36
38
  when 'resend' then resend_params
37
39
  when 'mailjet' then mailjet_params
40
+ when 'mailtrap' then mailtrap_params
41
+ when 'mandrill' then mandrill_params
38
42
  end
39
43
  end
40
44
 
@@ -53,5 +57,13 @@ module Emailbutler
53
57
  def mailjet_params
54
58
  params.permit('event', 'time', 'Message_GUID')
55
59
  end
60
+
61
+ def mailtrap_params
62
+ params.permit('events' => %w[event timestamp message_id])
63
+ end
64
+
65
+ def mandrill_params
66
+ params.permit('mandrill_events' => %w[event ts _id])
67
+ end
56
68
  end
57
69
  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 mailjet].freeze
10
+ AVAILABLE_PROVIDERS = %w[sendgrid smtp2go resend mailjet mailtrap mandrill].freeze
11
11
 
12
12
  attr_accessor :adapter, :providers, :ui_username, :ui_password, :ui_secured_environments
13
13
 
@@ -5,6 +5,8 @@ require 'emailbutler/webhooks/mappers/sendgrid'
5
5
  require 'emailbutler/webhooks/mappers/smtp2go'
6
6
  require 'emailbutler/webhooks/mappers/resend'
7
7
  require 'emailbutler/webhooks/mappers/mailjet'
8
+ require 'emailbutler/webhooks/mappers/mailtrap'
9
+ require 'emailbutler/webhooks/mappers/mandrill'
8
10
  require 'emailbutler/webhooks/receiver'
9
11
 
10
12
  module Emailbutler
@@ -24,6 +26,8 @@ module Emailbutler
24
26
  register(:smtp2go_mapper) { Emailbutler::Webhooks::Mappers::Smtp2Go.new }
25
27
  register(:resend_mapper) { Emailbutler::Webhooks::Mappers::Resend.new }
26
28
  register(:mailjet_mapper) { Emailbutler::Webhooks::Mappers::Mailjet.new }
29
+ register(:mailtrap_mapper) { Emailbutler::Webhooks::Mappers::Mailtrap.new }
30
+ register(:mandrill_mapper) { Emailbutler::Webhooks::Mappers::Mandrill.new }
27
31
 
28
32
  # webhook receiver
29
33
  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.4'
4
+ VERSION = '0.8.5'
5
5
  end
@@ -7,19 +7,15 @@ module Emailbutler
7
7
  DELIVERABILITY_MAPPER = {
8
8
  'sent' => 'processed',
9
9
  'open' => 'delivered',
10
- 'click' => 'delivered',
11
- 'unsub' => 'failed',
12
- 'blocked' => 'failed',
13
- 'bounce' => 'failed',
14
- 'spam' => 'failed'
10
+ 'click' => 'delivered'
15
11
  }.freeze
16
12
 
17
13
  def call(payload:)
18
14
  payload.stringify_keys!
19
15
  # message-id contains data like <uuid>
20
16
  message_uuid = payload['Message_GUID']
21
- status = DELIVERABILITY_MAPPER[payload['event']]
22
- return [] if message_uuid.nil? || status.nil?
17
+ status = DELIVERABILITY_MAPPER[payload['event']] || Emailbutler::Message::FAILED
18
+ return [] if message_uuid.nil?
23
19
 
24
20
  [
25
21
  {
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Emailbutler
4
+ module Webhooks
5
+ module Mappers
6
+ class Mailtrap
7
+ DELIVERABILITY_MAPPER = {
8
+ 'delivery' => 'delivered',
9
+ 'open' => 'delivered',
10
+ 'click' => 'delivered'
11
+ }.freeze
12
+
13
+ def call(payload:)
14
+ payload['events'].filter_map { |message|
15
+ message.stringify_keys!
16
+ message_uuid = message['message_id']
17
+ status = DELIVERABILITY_MAPPER[message['event']] || Emailbutler::Message::FAILED
18
+ next if message_uuid.nil?
19
+
20
+ {
21
+ message_uuid: message_uuid,
22
+ status: status,
23
+ timestamp: message['timestamp'] ? Time.at(message['timestamp']).utc.to_datetime : nil
24
+ }
25
+ }
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Emailbutler
4
+ module Webhooks
5
+ module Mappers
6
+ class Mandrill
7
+ DELIVERABILITY_MAPPER = {
8
+ 'send' => 'processed',
9
+ 'open' => 'delivered',
10
+ 'click' => 'delivered'
11
+ }.freeze
12
+
13
+ def call(payload:)
14
+ payload['mandrill_events'].filter_map { |message|
15
+ message.stringify_keys!
16
+ message_uuid = message['_id']
17
+ status = DELIVERABILITY_MAPPER[message['event']] || Emailbutler::Message::FAILED
18
+ next if message_uuid.nil?
19
+
20
+ {
21
+ message_uuid: message_uuid,
22
+ status: status,
23
+ timestamp: message['ts'] ? Time.at(message['ts']).utc.to_datetime : nil
24
+ }
25
+ }
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -8,17 +8,14 @@ module Emailbutler
8
8
  'email.sent' => 'processed',
9
9
  'email.delivered' => 'delivered',
10
10
  'email.opened' => 'delivered',
11
- 'email.clicked' => 'delivered',
12
- 'email.delivered_delayed' => 'failed',
13
- 'email.bounced' => 'failed',
14
- 'email.complained' => 'failed'
11
+ 'email.clicked' => 'delivered'
15
12
  }.freeze
16
13
 
17
14
  def call(payload:)
18
15
  payload.stringify_keys!
19
16
  message_uuid = payload.dig('data', 'email_id')
20
- status = DELIVERABILITY_MAPPER[payload['type']]
21
- return [] if message_uuid.nil? || status.nil?
17
+ status = DELIVERABILITY_MAPPER[payload['type']] || Emailbutler::Message::FAILED
18
+ return [] if message_uuid.nil?
22
19
 
23
20
  [
24
21
  {
@@ -8,18 +8,14 @@ module Emailbutler
8
8
  'processed' => 'processed',
9
9
  'delivered' => 'delivered',
10
10
  'open' => 'delivered',
11
- 'click' => 'delivered',
12
- 'deferred' => 'failed',
13
- 'bounce' => 'failed',
14
- 'dropped' => 'failed',
15
- 'spamreport' => 'failed'
11
+ 'click' => 'delivered'
16
12
  }.freeze
17
13
 
18
14
  def call(payload:)
19
15
  payload['_json'].filter_map { |message|
20
16
  message.stringify_keys!
21
17
  message_uuid = message['smtp-id'] || message['sg_message_id']
22
- status = DELIVERABILITY_MAPPER[message['event']]
18
+ status = DELIVERABILITY_MAPPER[message['event']] || Emailbutler::Message::FAILED
23
19
  next if message_uuid.nil? || status.nil?
24
20
 
25
21
  {
@@ -8,18 +8,15 @@ module Emailbutler
8
8
  'processed' => 'processed',
9
9
  'delivered' => 'delivered',
10
10
  'open' => 'delivered',
11
- 'click' => 'delivered',
12
- 'bounce' => 'failed',
13
- 'reject' => 'failed',
14
- 'spam' => 'failed'
11
+ 'click' => 'delivered'
15
12
  }.freeze
16
13
 
17
14
  def call(payload:)
18
15
  payload.stringify_keys!
19
16
  # message-id contains data like <uuid>
20
17
  message_uuid = payload['message-id'][1..-2]
21
- status = DELIVERABILITY_MAPPER[payload['event']]
22
- return [] if message_uuid.nil? || status.nil?
18
+ status = DELIVERABILITY_MAPPER[payload['event']] || Emailbutler::Message::FAILED
19
+ return [] if message_uuid.nil?
23
20
 
24
21
  [
25
22
  {
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.4
4
+ version: 0.8.5
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-09-13 00:00:00.000000000 Z
11
+ date: 2024-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-container
@@ -245,6 +245,8 @@ files:
245
245
  - lib/emailbutler/mailers/helpers.rb
246
246
  - lib/emailbutler/version.rb
247
247
  - lib/emailbutler/webhooks/mappers/mailjet.rb
248
+ - lib/emailbutler/webhooks/mappers/mailtrap.rb
249
+ - lib/emailbutler/webhooks/mappers/mandrill.rb
248
250
  - lib/emailbutler/webhooks/mappers/resend.rb
249
251
  - lib/emailbutler/webhooks/mappers/sendgrid.rb
250
252
  - lib/emailbutler/webhooks/mappers/smtp2go.rb