mailjet 1.7.0 → 1.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mailjet/connection.rb +15 -2
- data/lib/mailjet/resource.rb +7 -2
- data/lib/mailjet/resources/contact.rb +15 -1
- data/lib/mailjet/resources/statistics_linkclick.rb +12 -0
- data/lib/mailjet/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f379dc1214f713aaaa97f3b4f6530655f86905f8a80ad4bccc877793efcaaf8
|
4
|
+
data.tar.gz: a8edcae65cef3ab95b3508fd309383e0eb82f83d20c0eacd8eb79bb838aab60a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d090d495b8dc5bfed6011ea7365aec9c357b28a9f03b5d5d199002078d476375cedc6ac289277db1a3d7be57f887b3fdf358d6d8dc294d568e273f37480eec25
|
7
|
+
data.tar.gz: 85f44a31d32daea2b4cb3f98f28a2f3fe62f4698c9143561f3f77d85bad7c9c50f87bbb588a0601eb39cbe988999cdd0ee18487e73ab3013772095b5ad0a0508
|
data/lib/mailjet/connection.rb
CHANGED
@@ -96,13 +96,26 @@ module Mailjet
|
|
96
96
|
formatted_payload = (additional_headers[:content_type] == :json) ? JSON.parse(payload) : payload
|
97
97
|
params = params.merge(formatted_payload)
|
98
98
|
|
99
|
-
http_body = if e.http_headers[:content_type]
|
99
|
+
http_body = if e.http_headers[:content_type].include?("application/json")
|
100
100
|
e.http_body
|
101
101
|
else
|
102
102
|
"{}"
|
103
103
|
end
|
104
104
|
|
105
|
-
|
105
|
+
if sent_invalid_email?(e.http_body, @adapter.url)
|
106
|
+
return e.http_body
|
107
|
+
else
|
108
|
+
raise Mailjet::ApiError.new(e.http_code, http_body, @adapter, @adapter.url, params)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def sent_invalid_email?(error_http_body, url)
|
113
|
+
return false unless url.include?('v3.1/send')
|
114
|
+
return unless error_http_body
|
115
|
+
|
116
|
+
parsed_body = JSON.parse(error_http_body)
|
117
|
+
error_message = parsed_body['Messages']&.first&.dig('Errors')&.first&.dig('ErrorMessage')
|
118
|
+
error_message.include?('is an invalid email address.')
|
106
119
|
end
|
107
120
|
|
108
121
|
end
|
data/lib/mailjet/resource.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
require 'mailjet/connection'
|
2
2
|
require 'active_support/core_ext/string'
|
3
3
|
require 'active_support/core_ext/module/delegation'
|
4
|
-
require 'active_support/hash_with_indifferent_access'
|
5
4
|
#require 'mail'
|
5
|
+
require 'active_support/hash_with_indifferent_access'
|
6
|
+
require 'active_support/core_ext/hash'
|
7
|
+
require 'active_support/json/decoding'
|
6
8
|
require 'json'
|
7
9
|
|
8
10
|
|
@@ -23,9 +25,11 @@ module Mailjet
|
|
23
25
|
def self.included(base)
|
24
26
|
base.extend ClassMethods
|
25
27
|
base.class_eval do
|
26
|
-
cattr_accessor :resource_path, :public_operations, :read_only, :filters, :resourceprop, :action, :non_json_urls, :version
|
28
|
+
cattr_accessor :resource_path, :public_operations, :read_only, :filters, :resourceprop, :read_only_attributes, :action, :non_json_urls, :version
|
27
29
|
cattr_writer :connection
|
28
30
|
|
31
|
+
self.read_only_attributes = []
|
32
|
+
|
29
33
|
def self.connection(options = {})
|
30
34
|
class_variable_get(:@@connection) || default_connection(options)
|
31
35
|
end
|
@@ -316,6 +320,7 @@ module Mailjet
|
|
316
320
|
payload = attributes.reject { |k,v| v.blank? }
|
317
321
|
if persisted?
|
318
322
|
payload = payload.slice(*resourceprop.map(&:to_s))
|
323
|
+
.except(*read_only_attributes.map(&:to_s))
|
319
324
|
end
|
320
325
|
payload = camelcase_keys(payload)
|
321
326
|
payload.tap { |hs| hs.delete("Persisted") }
|
@@ -4,7 +4,21 @@ module Mailjet
|
|
4
4
|
self.resource_path = 'REST/contact'
|
5
5
|
self.public_operations = [:get, :put, :post]
|
6
6
|
self.filters = [:campaign, :contacts_list, :is_unsubscribed, :last_activity_at, :recipient, :status]
|
7
|
-
self.resourceprop = [
|
7
|
+
self.resourceprop = [
|
8
|
+
:created_at,
|
9
|
+
:delivered_count,
|
10
|
+
:email,
|
11
|
+
:id,
|
12
|
+
:is_opt_in_pending,
|
13
|
+
:is_spam_complaining,
|
14
|
+
:last_activity_at,
|
15
|
+
:last_update_at,
|
16
|
+
:name,
|
17
|
+
:unsubscribed_at,
|
18
|
+
:unsubscribed_by,
|
19
|
+
:is_excluded_from_campaigns
|
20
|
+
]
|
21
|
+
self.read_only_attributes = [:created_at, :last_activity_at, :last_update_at, :unsubscribed_at]
|
8
22
|
|
9
23
|
end
|
10
24
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Mailjet
|
2
|
+
class Statistics_linkclick
|
3
|
+
include Mailjet::Resource
|
4
|
+
self.resource_path = 'REST/statistics/link-click'
|
5
|
+
self.public_operations = [:get]
|
6
|
+
self.filters = [:campaign_id]
|
7
|
+
self.resourceprop = [:url, :position_index, :clicked_messages_count, :clicked_events_count]
|
8
|
+
|
9
|
+
self.read_only = true
|
10
|
+
|
11
|
+
end
|
12
|
+
end
|
data/lib/mailjet/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mailjet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tyler Nappy
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2022-
|
14
|
+
date: 2022-12-18 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: activesupport
|
@@ -253,6 +253,7 @@ files:
|
|
253
253
|
- lib/mailjet/resources/sender_validate.rb
|
254
254
|
- lib/mailjet/resources/senderstatistics.rb
|
255
255
|
- lib/mailjet/resources/statcounters.rb
|
256
|
+
- lib/mailjet/resources/statistics_linkclick.rb
|
256
257
|
- lib/mailjet/resources/template.rb
|
257
258
|
- lib/mailjet/resources/template_detailcontent.rb
|
258
259
|
- lib/mailjet/resources/toplinkclicked.rb
|