mad_mimi_mailer 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/mad_mimi_mailer.rb +27 -4
- metadata +13 -5
data/lib/mad_mimi_mailer.rb
CHANGED
@@ -8,6 +8,9 @@ class MadMimiMailer < ActionMailer::Base
|
|
8
8
|
|
9
9
|
@@api_settings = {}
|
10
10
|
cattr_accessor :api_settings
|
11
|
+
|
12
|
+
@@default_parameters = {}
|
13
|
+
cattr_accessor :default_parameters
|
11
14
|
|
12
15
|
# Custom Mailer attributes
|
13
16
|
|
@@ -34,6 +37,14 @@ class MadMimiMailer < ActionMailer::Base
|
|
34
37
|
@hidden = hidden
|
35
38
|
end
|
36
39
|
end
|
40
|
+
|
41
|
+
def unconfirmed(value = nil)
|
42
|
+
if value.nil?
|
43
|
+
@unconfirmed
|
44
|
+
else
|
45
|
+
@unconfirmed = value
|
46
|
+
end
|
47
|
+
end
|
37
48
|
|
38
49
|
# Class methods
|
39
50
|
|
@@ -60,7 +71,14 @@ class MadMimiMailer < ActionMailer::Base
|
|
60
71
|
if delivery_method == :test
|
61
72
|
deliveries << (mail.mail ? mail.mail : mail)
|
62
73
|
else
|
63
|
-
|
74
|
+
if (all_recipients = mail.recipients).is_a? Array
|
75
|
+
all_recipients.each do |recipient|
|
76
|
+
mail.recipients = recipient
|
77
|
+
call_api!(mail, method)
|
78
|
+
end
|
79
|
+
else
|
80
|
+
call_api!(mail, method)
|
81
|
+
end
|
64
82
|
end
|
65
83
|
end
|
66
84
|
|
@@ -71,11 +89,13 @@ class MadMimiMailer < ActionMailer::Base
|
|
71
89
|
'promotion_name' => mail.promotion || method.to_s.sub(/^mimi_/, ''),
|
72
90
|
'recipients' => serialize(mail.recipients),
|
73
91
|
'subject' => mail.subject,
|
74
|
-
'bcc' => serialize(mail.bcc),
|
75
|
-
'from' => mail.from,
|
92
|
+
'bcc' => serialize(mail.bcc || default_parameters[:bcc]),
|
93
|
+
'from' => (mail.from || default_parameters[:from]),
|
76
94
|
'hidden' => serialize(mail.hidden)
|
77
95
|
}
|
78
96
|
|
97
|
+
params['unconfirmed'] = '1' if mail.unconfirmed
|
98
|
+
|
79
99
|
if mail.use_erb
|
80
100
|
if mail.parts.any?
|
81
101
|
params['raw_plain_text'] = content_for(mail, "text/plain")
|
@@ -85,7 +105,10 @@ class MadMimiMailer < ActionMailer::Base
|
|
85
105
|
params['raw_html'] = mail.body
|
86
106
|
end
|
87
107
|
else
|
88
|
-
|
108
|
+
stringified_default_body = (default_parameters[:body] || {}).stringify_keys!
|
109
|
+
stringified_mail_body = (mail.body || {}).stringify_keys!
|
110
|
+
body_hash = stringified_default_body.merge(stringified_mail_body)
|
111
|
+
params['body'] = body_hash.to_yaml
|
89
112
|
end
|
90
113
|
|
91
114
|
response = post_request do |request|
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mad_mimi_mailer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 9
|
9
|
+
version: 0.0.9
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Dave Hoover
|
@@ -9,7 +14,7 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date: 2010-
|
17
|
+
date: 2010-04-09 00:00:00 -05:00
|
13
18
|
default_executable:
|
14
19
|
dependencies: []
|
15
20
|
|
@@ -36,18 +41,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
36
41
|
requirements:
|
37
42
|
- - ">="
|
38
43
|
- !ruby/object:Gem::Version
|
44
|
+
segments:
|
45
|
+
- 0
|
39
46
|
version: "0"
|
40
|
-
version:
|
41
47
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
42
48
|
requirements:
|
43
49
|
- - ">="
|
44
50
|
- !ruby/object:Gem::Version
|
51
|
+
segments:
|
52
|
+
- 1
|
53
|
+
- 2
|
45
54
|
version: "1.2"
|
46
|
-
version:
|
47
55
|
requirements: []
|
48
56
|
|
49
57
|
rubyforge_project: mad_mimi_mailer
|
50
|
-
rubygems_version: 1.3.
|
58
|
+
rubygems_version: 1.3.6
|
51
59
|
signing_key:
|
52
60
|
specification_version: 3
|
53
61
|
summary: Extending ActionMailer::Base for Mad Mimi integration.
|