emailbutler 0.9.0 → 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: 0d6612dd1009249a9314d73130f50e552ca2617ac9e9396321d838097847b2b4
4
- data.tar.gz: e844f163ca10039a3214b441fce3ce1036e1d621c75719af5b45f0c6301d4a98
3
+ metadata.gz: a462f9ebcf6a686f4692573eecc1f319bb274f10aecb3247cf6e1d3191f80397
4
+ data.tar.gz: 41eab094dd56a6e374fb0a20a32c00aee1538b50a9eb5ea735ce3b9d13c681bd
5
5
  SHA512:
6
- metadata.gz: bded1db47fe2574726f9b695154b96a18c51cf639c1a0f54d4fe561ed7932b681bbe069c463c905c00f7ef8b1b9f2f58b8a710fd638d40a9b24b1046280c3ef6
7
- data.tar.gz: 8e889730f6f8d5e14e70c327b9e627c57daba2200113b924ef4adbd71ff84960a3ff12913e8a5cc00111b62526278e8d6007dbefbe1fab429c63a854cc140c7a
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.9.0'
4
+ VERSION = '0.9.1'
5
5
  end
@@ -6,8 +6,8 @@ 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:)
@@ -15,17 +15,24 @@ module Emailbutler
15
15
  # message-id contains data like <uuid>
16
16
  message_uuid = payload['Message_GUID']
17
17
  message_uuid = message_uuid[1..-2] if message_uuid.starts_with?('<') && message_uuid.ends_with?('>')
18
- status = DELIVERABILITY_MAPPER[payload['event']] || Emailbutler::Message::FAILED
19
18
  return [] if message_uuid.nil?
20
19
 
21
20
  [
22
21
  {
23
22
  message_uuid: message_uuid,
24
- status: status,
23
+ status: transform_status(payload['event']),
25
24
  timestamp: payload['time'] ? Time.at(payload['time'].to_i).utc.to_datetime : nil
26
25
  }
27
26
  ]
28
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
29
36
  end
30
37
  end
31
38
  end
@@ -6,8 +6,8 @@ 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:)
@@ -15,16 +15,23 @@ module Emailbutler
15
15
  message.stringify_keys!
16
16
  message_uuid = message['message_id']
17
17
  message_uuid = message_uuid[1..-2] if message_uuid.starts_with?('<') && message_uuid.ends_with?('>')
18
- status = DELIVERABILITY_MAPPER[message['event']] || Emailbutler::Message::FAILED
19
18
  next if message_uuid.nil?
20
19
 
21
20
  {
22
21
  message_uuid: message_uuid,
23
- status: status,
22
+ status: transform_status(message['event']),
24
23
  timestamp: message['timestamp'] ? Time.at(message['timestamp']).utc.to_datetime : nil
25
24
  }
26
25
  }
27
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
28
35
  end
29
36
  end
30
37
  end
@@ -6,8 +6,8 @@ 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:)
@@ -15,16 +15,23 @@ module Emailbutler
15
15
  message.stringify_keys!
16
16
  message_uuid = message['_id']
17
17
  message_uuid = message_uuid[1..-2] if message_uuid.starts_with?('<') && message_uuid.ends_with?('>')
18
- status = DELIVERABILITY_MAPPER[message['event']] || Emailbutler::Message::FAILED
19
18
  next if message_uuid.nil?
20
19
 
21
20
  {
22
21
  message_uuid: message_uuid,
23
- status: status,
22
+ status: transform_status(message['event']),
24
23
  timestamp: message['ts'] ? Time.at(message['ts']).utc.to_datetime : nil
25
24
  }
26
25
  }
27
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
28
35
  end
29
36
  end
30
37
  end
@@ -7,25 +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
17
  message_uuid = message_uuid[1..-2] if message_uuid.starts_with?('<') && message_uuid.ends_with?('>')
18
- status = DELIVERABILITY_MAPPER[payload['type']] || Emailbutler::Message::FAILED
19
18
  return [] if message_uuid.nil?
20
19
 
21
20
  [
22
21
  {
23
22
  message_uuid: message_uuid,
24
- status: status,
23
+ status: transform_status(payload['type']),
25
24
  timestamp: payload['created_at'] ? DateTime.parse(payload['created_at']).utc : nil
26
25
  }
27
26
  ]
28
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
29
36
  end
30
37
  end
31
38
  end
@@ -7,25 +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:) # rubocop: disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
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
18
  message_uuid = message_uuid[1..-2] if message_uuid.starts_with?('<') && message_uuid.ends_with?('>')
19
- status = DELIVERABILITY_MAPPER[message['event']] || Emailbutler::Message::FAILED
20
19
  next if message_uuid.nil? || status.nil?
21
20
 
22
21
  {
23
22
  message_uuid: message_uuid,
24
- status: status,
23
+ status: transform_status(message['event']),
25
24
  timestamp: message['timestamp'] ? Time.at(message['timestamp'].to_i).utc.to_datetime : nil
26
25
  }
27
26
  }
28
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
29
36
  end
30
37
  end
31
38
  end
@@ -7,8 +7,8 @@ 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:)
@@ -16,17 +16,24 @@ module Emailbutler
16
16
  # message-id contains data like <uuid>
17
17
  message_uuid = payload['message-id']
18
18
  message_uuid = message_uuid[1..-2] if message_uuid.starts_with?('<') && message_uuid.ends_with?('>')
19
- status = DELIVERABILITY_MAPPER[payload['event']] || Emailbutler::Message::FAILED
20
19
  return [] if message_uuid.nil?
21
20
 
22
21
  [
23
22
  {
24
23
  message_uuid: message_uuid,
25
- status: status,
24
+ status: transform_status(payload['event']),
26
25
  timestamp: payload['sendtime'] ? Time.at(payload['sendtime'].to_i).utc.to_datetime : nil
27
26
  }
28
27
  ]
29
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
30
37
  end
31
38
  end
32
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.9.0
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: 2026-04-01 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