mailjet 1.5.2 → 1.5.3
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 +4 -4
- data/lib/mailjet/configuration.rb +11 -12
- data/lib/mailjet/connection.rb +1 -1
- data/lib/mailjet/mailer.rb +21 -10
- data/lib/mailjet/resources/newsletter_schedule.rb +1 -1
- data/lib/mailjet/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce7a69f28969e1a632cc70e07a8a04b973576f5f
|
4
|
+
data.tar.gz: 3a7bf17b3fd83efeb88427b6bc09f184d41b9996
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3043cf5a15c67cb008677ea98b439ef656e5ce5f6bcad3f3fba3497ea1dae6f8f99e637d7a27cb07c11ee1f12d46e4e30b573ea01258e1901f32cdc6a4c7a5c2
|
7
|
+
data.tar.gz: 672355e584024830232f12dcbea25e1d6e5ac543ddf56476cd2a64b55e45b9a920eb4f667a7e08ae6f9ca5f0a7bf6f0d22812013705ecf49bac69ad70e344e5d
|
@@ -2,18 +2,17 @@ require 'active_support/core_ext/module/attribute_accessors'
|
|
2
2
|
|
3
3
|
module Mailjet
|
4
4
|
module Configuration
|
5
|
-
mattr_accessor :api_key
|
6
|
-
mattr_accessor :secret_key
|
7
|
-
mattr_accessor :default_from
|
8
|
-
mattr_accessor :api_version do
|
9
|
-
'v3'
|
10
|
-
end
|
11
|
-
mattr_accessor :end_point do
|
12
|
-
'https://api.mailjet.com'
|
13
|
-
end
|
14
|
-
mattr_accessor :perform_api_call do
|
15
|
-
true
|
16
|
-
end
|
5
|
+
mattr_accessor :api_key, :secret_key, :default_from
|
17
6
|
|
7
|
+
DEFAULT = {
|
8
|
+
api_version: 'v3',
|
9
|
+
end_point: 'https://api.mailjet.com',
|
10
|
+
perform_api_call: true,
|
11
|
+
}
|
12
|
+
|
13
|
+
DEFAULT.each do |param, default_value|
|
14
|
+
mattr_accessor param
|
15
|
+
self.send("#{param}=", default_value)
|
16
|
+
end
|
18
17
|
end
|
19
18
|
end
|
data/lib/mailjet/connection.rb
CHANGED
@@ -69,7 +69,7 @@ module Mailjet
|
|
69
69
|
@adapter.send(method, formatted_payload, additional_headers, &block)
|
70
70
|
end
|
71
71
|
else
|
72
|
-
return {'Count'
|
72
|
+
return {'Count' => 0, 'Data' => [mock_api_call: true], 'Total' => 0}.to_json
|
73
73
|
end
|
74
74
|
rescue RestClient::Exception => e
|
75
75
|
handle_exception(e, additional_headers, formatted_payload)
|
data/lib/mailjet/mailer.rb
CHANGED
@@ -49,8 +49,7 @@ class Mailjet::APIMailer
|
|
49
49
|
)
|
50
50
|
end
|
51
51
|
|
52
|
-
def deliver!(mail, options =
|
53
|
-
# p mail.header.fields
|
52
|
+
def deliver!(mail, options = {})
|
54
53
|
|
55
54
|
if (options && options.kind_of?(Object) && options['version'].present?)
|
56
55
|
@version = options['version']
|
@@ -66,20 +65,27 @@ class Mailjet::APIMailer
|
|
66
65
|
end
|
67
66
|
|
68
67
|
if (@version == 'v3.1')
|
69
|
-
Mailjet::Send.create({:Messages => [setContentV3_1(mail)]})
|
68
|
+
Mailjet::Send.create({:Messages => [setContentV3_1(mail)]}, options)
|
70
69
|
else
|
71
|
-
Mailjet::Send.create(setContentV3_0(mail))
|
70
|
+
Mailjet::Send.create(setContentV3_0(mail), options)
|
72
71
|
end
|
73
72
|
end
|
74
73
|
|
75
74
|
def setContentV3_1(mail)
|
76
75
|
content = {}
|
76
|
+
|
77
77
|
content[:TextPart] = mail.text_part.try(:decoded) if !mail.text_part.blank?
|
78
78
|
content[:HTMLPart] = mail.html_part.try(:decoded) if !mail.html_part.blank?
|
79
79
|
|
80
|
+
# try message `body` as fallback if no content found
|
81
|
+
unless content[:TextPart] || content[:HTMLPart] || mail.body.try(:raw_source).empty?
|
82
|
+
content[mail.content_type.try(:include?,'text/html') ? :HTMLPart : :TextPart] = mail.body.raw_source
|
83
|
+
end
|
84
|
+
|
85
|
+
|
80
86
|
if mail.attachments.any?
|
81
87
|
content[:Attachments] = []
|
82
|
-
content[:
|
88
|
+
content[:InlinedAttachments] = []
|
83
89
|
|
84
90
|
mail.attachments.each do |attachment|
|
85
91
|
mailjet_attachment = {
|
@@ -90,7 +96,7 @@ class Mailjet::APIMailer
|
|
90
96
|
|
91
97
|
if attachment.inline?
|
92
98
|
mailjet_attachment['ContentId'] = attachment.content_id
|
93
|
-
content[:
|
99
|
+
content[:InlinedAttachments].push(mailjet_attachment)
|
94
100
|
else
|
95
101
|
content[:Attachments].push(mailjet_attachment)
|
96
102
|
end
|
@@ -108,14 +114,14 @@ class Mailjet::APIMailer
|
|
108
114
|
end
|
109
115
|
end
|
110
116
|
|
111
|
-
#
|
117
|
+
# ReplyTo property was added in v3.1
|
112
118
|
# Passing it as an header if mail.reply_to
|
113
119
|
|
114
120
|
if mail.reply_to
|
115
|
-
if mail.reply_to.display_names.first
|
116
|
-
content[:
|
121
|
+
if mail.reply_to.respond_to?(:display_names) && mail.reply_to.display_names.first
|
122
|
+
content[:ReplyTo] = {:Email=> mail[:reply_to].addresses.first, :Name=> mail[:reply_to].display_names.first}
|
117
123
|
else
|
118
|
-
content[:
|
124
|
+
content[:ReplyTo] = {:Email=> mail[:reply_to].addresses.first}
|
119
125
|
end
|
120
126
|
end
|
121
127
|
|
@@ -199,6 +205,11 @@ class Mailjet::APIMailer
|
|
199
205
|
content[:text_part] = mail.text_part.try(:decoded) if !mail.text_part.blank?
|
200
206
|
content[:html_part] = mail.html_part.try(:decoded) if !mail.html_part.blank?
|
201
207
|
|
208
|
+
# try message `body` as fallback if no content found
|
209
|
+
unless content[:text_part] || content[:html_part] || mail.body.try(:raw_source).empty?
|
210
|
+
content[mail.content_type.try(:include?,'text/html') ? :html_part : :text_part] = mail.body.raw_source
|
211
|
+
end
|
212
|
+
|
202
213
|
# Formatting attachments (inline + regular)
|
203
214
|
unless mail.attachments.empty?
|
204
215
|
content[:attachments] = []
|
@@ -3,7 +3,7 @@ module Mailjet
|
|
3
3
|
include Mailjet::Resource
|
4
4
|
self.action = "schedule"
|
5
5
|
self.resource_path = "REST/newsletter/id/#{self.action}"
|
6
|
-
self.public_operations = [:post, :delete]
|
6
|
+
self.public_operations = [:get, :post, :delete]
|
7
7
|
self.filters = []
|
8
8
|
self.resourceprop = [:date]
|
9
9
|
|
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.5.
|
4
|
+
version: 1.5.3
|
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: 2017-06-
|
14
|
+
date: 2017-06-30 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: activesupport
|