Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for suppression groups #25

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
SendGrid gem provides ActionMailer::Base extensions to use SendGrid API features in you emails.
It extends ActionMailer with next methods:

substitute(patters_string, array_of_substitunion_strings)
substitute(patterns_string, array_of_substitution_strings)
uniq_args(hash_of_unique_args)
category(category_string)
open_tracking(enabled = true)
add_filter_setting(filter_name, setting_name, value)
suppression_group(group_id)

== Rails 3 configuration

Expand All @@ -18,7 +19,7 @@ In your Gemfile:
In config/initializers/mail.rb:

ActionMailer::Base.register_interceptor(SendGrid::MailInterceptor)

ActionMailer::Base.smtp_settings = {
:address => 'smtp.sendgrid.net',
:port => '25',
Expand All @@ -31,7 +32,7 @@ In config/initializers/mail.rb:
If you use Heroku, here what the mailer initializer may look like:

ActionMailer::Base.register_interceptor(SendGrid::MailInterceptor)

if ENV['SENDGRID_USERNAME'] && ENV['SENDGRID_PASSWORD']
ActionMailer::Base.smtp_settings = {
:address => 'smtp.sendgrid.net',
Expand Down Expand Up @@ -125,7 +126,7 @@ Add an invisible image at the end of the email to track e-mail opens. If the ema

*v3.0.0*

* Depricated method `:alias_method_chain` has been replaced with `Module#prepend` Ruby 2.0 feature
* Deprecated method `:alias_method_chain` has been replaced with `Module#prepend` Ruby 2.0 feature
* Requires Ruby 2.0+

*v2.0.5*
Expand Down
2 changes: 1 addition & 1 deletion lib/send_grid.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module SendGrid
def self.included(base)
base.class_eval do
prepend InstanceMethods
delegate :substitute, :uniq_args, :category, :add_filter_setting, :deliver_at, :template_id, :to => :sendgrid_header
delegate :substitute, :uniq_args, :category, :add_filter_setting, :deliver_at, :template_id, :suppression_group, :to => :sendgrid_header
alias_method :sendgrid_header, :send_grid_header
end
end
Expand Down
4 changes: 4 additions & 0 deletions lib/send_grid/api_header.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ def template_id(temp_id)
add_filter_setting('templates', 'template_id', temp_id)
end

def suppression_group(group_id)
@data[:asm_group_id] = group_id.to_s
end

def to_json
JSON.generate(@data, :array_nl => ' ')
end
Expand Down
8 changes: 6 additions & 2 deletions spec/api_header_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
header.to_json.should eql '{"to":[ "[email protected]" ]}'
end

it "contaions an array of recipients" do
it "contains an array of recipients" do
header.add_recipients %w([email protected] [email protected])
header.to_json.should eql '{"to":[ "[email protected]", "[email protected]" ]}'
end
Expand Down Expand Up @@ -47,6 +47,10 @@
header.add_filter_setting :filter1, :setting1, 'val1'
header.to_json.should eql '{"filters":{"filter1":{"settings":{"setting1":"val1"}}}}'
end

it "contains suppression_group" do
header.suppression_group 1234
header.to_json.should eql '{"asm_group_id":"1234"}'
end
end
end