sendgrid 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/sendgrid.rb +21 -11
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.4
|
data/lib/sendgrid.rb
CHANGED
@@ -107,7 +107,7 @@ module SendGrid
|
|
107
107
|
# Sets the custom X-SMTPAPI header before sending the email
|
108
108
|
def perform_delivery_smtp(mail)
|
109
109
|
puts "SendGrid X-SMTPAPI: #{sendgrid_json_headers(mail)}" if Object.const_defined?("SENDGRID_DEBUG_OUTPUT") && SENDGRID_DEBUG_OUTPUT
|
110
|
-
|
110
|
+
mail['X-SMTPAPI'] = sendgrid_json_headers(mail)
|
111
111
|
super
|
112
112
|
end
|
113
113
|
|
@@ -126,24 +126,27 @@ module SendGrid
|
|
126
126
|
header_opts[:category] = self.class.default_sg_category
|
127
127
|
end
|
128
128
|
|
129
|
-
# Set enables
|
129
|
+
# Set enables/disables
|
130
130
|
header_opts[:filters] = {} unless header_opts.has_key?(:filters)
|
131
|
-
|
131
|
+
enabled_opts = []
|
132
|
+
if @sg_options && !@sg_options.empty?
|
132
133
|
# merge the options so that the instance-level "overrides"
|
133
|
-
merged = self.class.default_sg_options
|
134
|
-
merged += @sg_options
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
134
|
+
merged = self.class.default_sg_options || []
|
135
|
+
merged += @sg_options
|
136
|
+
enabled_opts = merged
|
137
|
+
elsif self.class.default_sg_options
|
138
|
+
enabled_opts = self.class.default_sg_options
|
139
|
+
end
|
140
|
+
if !enabled_opts.empty? || (@sg_disabled_options && !@sg_disabled_options.empty?)
|
141
|
+
header_opts[:filters] = filters_hash_from_options(enabled_opts, @sg_disabled_options)
|
139
142
|
end
|
140
143
|
|
141
144
|
header_opts.to_json
|
142
145
|
end
|
143
146
|
|
144
|
-
def filters_hash_from_options(
|
147
|
+
def filters_hash_from_options(enabled_opts, disabled_opts)
|
145
148
|
filters = {}
|
146
|
-
|
149
|
+
enabled_opts.each do |opt|
|
147
150
|
filters[opt] = {'settings' => {'enable' => 1}}
|
148
151
|
case opt.to_sym
|
149
152
|
when :subscriptiontrack
|
@@ -170,6 +173,13 @@ module SendGrid
|
|
170
173
|
end
|
171
174
|
end
|
172
175
|
end
|
176
|
+
|
177
|
+
if disabled_opts
|
178
|
+
disabled_opts.each do |opt|
|
179
|
+
filters[opt] = {'settings' => {'enable' => 0}}
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
173
183
|
return filters
|
174
184
|
end
|
175
185
|
|