diff --git a/README.rdoc b/README.rdoc index 82d9604..40a8e25 100644 --- a/README.rdoc +++ b/README.rdoc @@ -71,6 +71,20 @@ Mailer class definition: end end +=== Setting ip pool + + Mailer class definition: + + class Mailer < ActionMailer::Base + default :from => 'no-reply@example.com', + :subject => 'An email sent via SendGridSmtpApi with substitutions' + + def email_with_ip_pool + ip_pool 'IPPoolName' + mail :to => 'email1@email.com' + end + end + == Apps (formerly called Filters) Apps can be applied to any of your email messages and can be configured through SendGridSmtpApi gem. diff --git a/lib/send_grid.rb b/lib/send_grid.rb index 604b797..74a4bc6 100644 --- a/lib/send_grid.rb +++ b/lib/send_grid.rb @@ -6,7 +6,7 @@ module SendGridSmtpApi def self.included(base) base.class_eval do prepend InstanceMethods - delegate :substitute, :uniq_args, :category, :add_filter_setting, :standard_smtp, :to => :sendgrid_header + delegate :substitute, :uniq_args, :category, :add_filter_setting, :ip_pool, :standard_smtp, :to => :sendgrid_header alias_method :sendgrid_header, :send_grid_header end end diff --git a/lib/send_grid/api_header.rb b/lib/send_grid/api_header.rb index 1d4893c..3ca5bf6 100644 --- a/lib/send_grid/api_header.rb +++ b/lib/send_grid/api_header.rb @@ -26,6 +26,10 @@ def add_filter_setting(fltr, setting, val) @data[:filters][fltr][:settings][setting] = val end + def ip_pool(pool_name) + @data[:ip_pool] = pool_name + end + def to_json JSON.generate(@data, {:indent => " ", :space => "", :space_before => "", :object_nl => "", :array_nl => ""}) end @@ -33,5 +37,4 @@ def to_json def standard_smtp(enabled = false) @standard_smtp = enabled end - end diff --git a/spec/api_header_spec.rb b/spec/api_header_spec.rb index 788760e..0796699 100644 --- a/spec/api_header_spec.rb +++ b/spec/api_header_spec.rb @@ -36,5 +36,10 @@ header.add_filter_setting :filter1, :setting1, 'val1' header.to_json.should eql '{ "filters":{ "filter1":{ "settings":{ "setting1":"val1" } } }}' end + + it "contains ip_pool" do + header.ip_pool 'pool_name' + header.to_json.should eql '{ "ip_pool":"pool_name"}' + end end end