emailbutler 0.8.12 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3e041b4eb9f94cb8591b0bdd439eb35ea40f9f2806e065feb13e65d3ea217191
4
- data.tar.gz: 33f46385632a0c85e219aa3d55731d53ee548e4cb6fdc932a05c5e4fa77759ad
3
+ metadata.gz: a462f9ebcf6a686f4692573eecc1f319bb274f10aecb3247cf6e1d3191f80397
4
+ data.tar.gz: 41eab094dd56a6e374fb0a20a32c00aee1538b50a9eb5ea735ce3b9d13c681bd
5
5
  SHA512:
6
- metadata.gz: cff7daacc6e23cc0d01b17762ccd23eac8305f58f4756687f3efed466e45e2f19cdf6e93ddaadca99c15912b52eb8d071255fccf68f34f64f5a59ff0c1330fe6
7
- data.tar.gz: d32be30b001977e334190dc8b07dad3c900177642b8fc6eef21a0ed3f733f10c211c3a48be138663753ac2c1e725e9a5b896fb60abe3fc1a4c3b38d8374bd8d7
6
+ metadata.gz: ac70ce8e0fef8bf4a37a96f63d8b918afccbb7539f651f5aa1fdd116f62afffdfffb2797954373b3707806ace2c84aae43df6e638527583c2131cb0be9e61220
7
+ data.tar.gz: 9810ff0ab0ddf8024cf2a8bbe5269f5cfd6b7c93e788c009b5273c049ed5fe73ac97c9bb0d1aa545f9dcdbdd2485d1b5741dd7c537bc34b46d8e7f3a1dc201df
@@ -20,11 +20,12 @@ module Emailbutler
20
20
  PROCESSED = 'processed'
21
21
  FAILED = 'failed'
22
22
  DELIVERED = 'delivered'
23
+ OPENED = 'opened'
23
24
 
24
25
  if Gem.loaded_specs['activerecord'].version < Gem::Version.create('7.0')
25
- enum status: { CREATED => 0, REJECTED => 1, PROCESSED => 2, FAILED => 3, DELIVERED => 4 }
26
+ enum status: { CREATED => 0, REJECTED => 1, PROCESSED => 2, FAILED => 3, DELIVERED => 4, OPENED => 5 }
26
27
  else
27
- enum :status, { CREATED => 0, REJECTED => 1, PROCESSED => 2, FAILED => 3, DELIVERED => 4 }
28
+ enum :status, { CREATED => 0, REJECTED => 1, PROCESSED => 2, FAILED => 3, DELIVERED => 4, OPENED => 5 }
28
29
  end
29
30
 
30
31
  after_initialize :generate_uuid
@@ -4,16 +4,15 @@ module Emailbutler
4
4
  class Configuration
5
5
  InitializeError = Class.new(StandardError)
6
6
 
7
- AVAILABLE_ADAPTERS = %w[
8
- Emailbutler::Adapters::ActiveRecord
9
- ].freeze
7
+ AVAILABLE_ADAPTERS = %w[Emailbutler::Adapters::ActiveRecord].freeze
10
8
  AVAILABLE_PROVIDERS = %w[sendgrid smtp2go resend mailjet mailtrap mandrill].freeze
11
9
 
12
- attr_reader :adapter, :providers, :ui_username, :ui_password, :ui_secured_environments
10
+ attr_reader :adapter, :providers, :mapping, :ui_username, :ui_password, :ui_secured_environments
13
11
 
14
12
  def initialize
15
13
  @adapter = nil
16
14
  @providers = []
15
+ @mapping = true
17
16
 
18
17
  # It's required to specify these 3 variables to enable basic auth to UI
19
18
  @ui_username = ''
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Emailbutler
4
- VERSION = '0.8.12'
4
+ VERSION = '0.9.1'
5
5
  end
@@ -6,25 +6,33 @@ module Emailbutler
6
6
  class Mailjet
7
7
  DELIVERABILITY_MAPPER = {
8
8
  'sent' => 'processed',
9
- 'open' => 'delivered',
10
- 'click' => 'delivered'
9
+ 'open' => 'opened',
10
+ 'click' => 'opened'
11
11
  }.freeze
12
12
 
13
13
  def call(payload:)
14
14
  payload.stringify_keys!
15
15
  # message-id contains data like <uuid>
16
16
  message_uuid = payload['Message_GUID']
17
- status = DELIVERABILITY_MAPPER[payload['event']] || Emailbutler::Message::FAILED
17
+ message_uuid = message_uuid[1..-2] if message_uuid.starts_with?('<') && message_uuid.ends_with?('>')
18
18
  return [] if message_uuid.nil?
19
19
 
20
20
  [
21
21
  {
22
22
  message_uuid: message_uuid,
23
- status: status,
23
+ status: transform_status(payload['event']),
24
24
  timestamp: payload['time'] ? Time.at(payload['time'].to_i).utc.to_datetime : nil
25
25
  }
26
26
  ]
27
27
  end
28
+
29
+ private
30
+
31
+ def transform_status(value)
32
+ return DELIVERABILITY_MAPPER[value] || Emailbutler::Message::FAILED if Emailbutler.configuration.mapping
33
+
34
+ value
35
+ end
28
36
  end
29
37
  end
30
38
  end
@@ -6,24 +6,32 @@ module Emailbutler
6
6
  class Mailtrap
7
7
  DELIVERABILITY_MAPPER = {
8
8
  'delivery' => 'delivered',
9
- 'open' => 'delivered',
10
- 'click' => 'delivered'
9
+ 'open' => 'opened',
10
+ 'click' => 'opened'
11
11
  }.freeze
12
12
 
13
13
  def call(payload:)
14
14
  payload['events'].filter_map { |message|
15
15
  message.stringify_keys!
16
16
  message_uuid = message['message_id']
17
- status = DELIVERABILITY_MAPPER[message['event']] || Emailbutler::Message::FAILED
17
+ message_uuid = message_uuid[1..-2] if message_uuid.starts_with?('<') && message_uuid.ends_with?('>')
18
18
  next if message_uuid.nil?
19
19
 
20
20
  {
21
21
  message_uuid: message_uuid,
22
- status: status,
22
+ status: transform_status(message['event']),
23
23
  timestamp: message['timestamp'] ? Time.at(message['timestamp']).utc.to_datetime : nil
24
24
  }
25
25
  }
26
26
  end
27
+
28
+ private
29
+
30
+ def transform_status(value)
31
+ return DELIVERABILITY_MAPPER[value] || Emailbutler::Message::FAILED if Emailbutler.configuration.mapping
32
+
33
+ value
34
+ end
27
35
  end
28
36
  end
29
37
  end
@@ -6,24 +6,32 @@ module Emailbutler
6
6
  class Mandrill
7
7
  DELIVERABILITY_MAPPER = {
8
8
  'send' => 'processed',
9
- 'open' => 'delivered',
10
- 'click' => 'delivered'
9
+ 'open' => 'opened',
10
+ 'click' => 'opened'
11
11
  }.freeze
12
12
 
13
13
  def call(payload:)
14
14
  payload['mandrill_events'].filter_map { |message|
15
15
  message.stringify_keys!
16
16
  message_uuid = message['_id']
17
- status = DELIVERABILITY_MAPPER[message['event']] || Emailbutler::Message::FAILED
17
+ message_uuid = message_uuid[1..-2] if message_uuid.starts_with?('<') && message_uuid.ends_with?('>')
18
18
  next if message_uuid.nil?
19
19
 
20
20
  {
21
21
  message_uuid: message_uuid,
22
- status: status,
22
+ status: transform_status(message['event']),
23
23
  timestamp: message['ts'] ? Time.at(message['ts']).utc.to_datetime : nil
24
24
  }
25
25
  }
26
26
  end
27
+
28
+ private
29
+
30
+ def transform_status(value)
31
+ return DELIVERABILITY_MAPPER[value] || Emailbutler::Message::FAILED if Emailbutler.configuration.mapping
32
+
33
+ value
34
+ end
27
35
  end
28
36
  end
29
37
  end
@@ -7,24 +7,32 @@ module Emailbutler
7
7
  DELIVERABILITY_MAPPER = {
8
8
  'email.sent' => 'processed',
9
9
  'email.delivered' => 'delivered',
10
- 'email.opened' => 'delivered',
11
- 'email.clicked' => 'delivered'
10
+ 'email.opened' => 'opened',
11
+ 'email.clicked' => 'opened'
12
12
  }.freeze
13
13
 
14
14
  def call(payload:)
15
15
  payload.stringify_keys!
16
16
  message_uuid = payload.dig('data', 'email_id')
17
- status = DELIVERABILITY_MAPPER[payload['type']] || Emailbutler::Message::FAILED
17
+ message_uuid = message_uuid[1..-2] if message_uuid.starts_with?('<') && message_uuid.ends_with?('>')
18
18
  return [] if message_uuid.nil?
19
19
 
20
20
  [
21
21
  {
22
22
  message_uuid: message_uuid,
23
- status: status,
23
+ status: transform_status(payload['type']),
24
24
  timestamp: payload['created_at'] ? DateTime.parse(payload['created_at']).utc : nil
25
25
  }
26
26
  ]
27
27
  end
28
+
29
+ private
30
+
31
+ def transform_status(value)
32
+ return DELIVERABILITY_MAPPER[value] || Emailbutler::Message::FAILED if Emailbutler.configuration.mapping
33
+
34
+ value
35
+ end
28
36
  end
29
37
  end
30
38
  end
@@ -7,24 +7,32 @@ module Emailbutler
7
7
  DELIVERABILITY_MAPPER = {
8
8
  'processed' => 'processed',
9
9
  'delivered' => 'delivered',
10
- 'open' => 'delivered',
11
- 'click' => 'delivered'
10
+ 'open' => 'opened',
11
+ 'click' => 'opened'
12
12
  }.freeze
13
13
 
14
- def call(payload:)
14
+ def call(payload:) # rubocop: disable Metrics/AbcSize, Metrics/CyclomaticComplexity
15
15
  payload['_json'].filter_map { |message|
16
16
  message.stringify_keys!
17
17
  message_uuid = message['smtp-id'] || message['sg_message_id']
18
- status = DELIVERABILITY_MAPPER[message['event']] || Emailbutler::Message::FAILED
18
+ message_uuid = message_uuid[1..-2] if message_uuid.starts_with?('<') && message_uuid.ends_with?('>')
19
19
  next if message_uuid.nil? || status.nil?
20
20
 
21
21
  {
22
22
  message_uuid: message_uuid,
23
- status: status,
23
+ status: transform_status(message['event']),
24
24
  timestamp: message['timestamp'] ? Time.at(message['timestamp'].to_i).utc.to_datetime : nil
25
25
  }
26
26
  }
27
27
  end
28
+
29
+ private
30
+
31
+ def transform_status(value)
32
+ return DELIVERABILITY_MAPPER[value] || Emailbutler::Message::FAILED if Emailbutler.configuration.mapping
33
+
34
+ value
35
+ end
28
36
  end
29
37
  end
30
38
  end
@@ -7,25 +7,33 @@ module Emailbutler
7
7
  DELIVERABILITY_MAPPER = {
8
8
  'processed' => 'processed',
9
9
  'delivered' => 'delivered',
10
- 'open' => 'delivered',
11
- 'click' => 'delivered'
10
+ 'open' => 'opened',
11
+ 'click' => 'opened'
12
12
  }.freeze
13
13
 
14
14
  def call(payload:)
15
15
  payload.stringify_keys!
16
16
  # message-id contains data like <uuid>
17
- message_uuid = payload['message-id'][1..-2]
18
- status = DELIVERABILITY_MAPPER[payload['event']] || Emailbutler::Message::FAILED
17
+ message_uuid = payload['message-id']
18
+ message_uuid = message_uuid[1..-2] if message_uuid.starts_with?('<') && message_uuid.ends_with?('>')
19
19
  return [] if message_uuid.nil?
20
20
 
21
21
  [
22
22
  {
23
23
  message_uuid: message_uuid,
24
- status: status,
24
+ status: transform_status(payload['event']),
25
25
  timestamp: payload['sendtime'] ? Time.at(payload['sendtime'].to_i).utc.to_datetime : nil
26
26
  }
27
27
  ]
28
28
  end
29
+
30
+ private
31
+
32
+ def transform_status(value)
33
+ return DELIVERABILITY_MAPPER[value] || Emailbutler::Message::FAILED if Emailbutler.configuration.mapping
34
+
35
+ value
36
+ end
29
37
  end
30
38
  end
31
39
  end
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.12
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bogdanov Anton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-03-03 00:00:00.000000000 Z
11
+ date: 2026-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-container