Skip to content

Commit

Permalink
Merge pull request #16 from TheProductWorks/master
Browse files Browse the repository at this point in the history
Add support for `send_at` X-SMTPAPI parameter
  • Loading branch information
paveltyk committed Nov 12, 2015
2 parents 19a232a + 835c3dc commit de22182
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
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
include InstanceMethods
delegate :substitute, :uniq_args, :category, :add_filter_setting, :to => :sendgrid_header
delegate :substitute, :uniq_args, :category, :add_filter_setting, :deliver_at, :to => :sendgrid_header
alias_method_chain :mail, :sendgrid
alias_method :sendgrid_header, :send_grid_header
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 @@ -26,6 +26,10 @@ def add_filter_setting(fltr, setting, val)
@data[:filters][fltr][:settings][setting] = val
end

def deliver_at(timestamp)
@data[:send_at] = timestamp
end

def to_json
JSON.generate(@data, :array_nl => ' ')
end
Expand Down
6 changes: 6 additions & 0 deletions spec/api_header_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@
header.to_json.should eql '{"category":"category_name"}'
end

it "contains send_at" do
ts = 5.minutes.from_now.to_i
header.deliver_at ts
header.to_json.should eql "{\"send_at\":#{ts}}"
end

it "contains filter settings" do
header.add_filter_setting :filter1, :setting1, 'val1'
header.to_json.should eql '{"filters":{"filter1":{"settings":{"setting1":"val1"}}}}'
Expand Down

0 comments on commit de22182

Please sign in to comment.