class MailEngine::Sendgrid::SmtpApi

smtp api class

Public Class Methods

new() click to toggle source
# File lib/mail_engine/sendgrid/smtp_api.rb, line 43
def initialize()
  @data = {}
end

Public Instance Methods

add_sub_val(var, val) click to toggle source
# File lib/mail_engine/sendgrid/smtp_api.rb, line 71
def add_sub_val(var, val)
  @data['sub'] ||= {}
  @data['sub'][var] = Array.wrap(val)
end
add_to(to) click to toggle source
# File lib/mail_engine/sendgrid/smtp_api.rb, line 65
def add_to(to)
  @data['to'] ||= []
  @data['to'] += Array.wrap(to)
  @data['to'].uniq!
end
category(cat) click to toggle source
# File lib/mail_engine/sendgrid/smtp_api.rb, line 47
def category(cat)
  @data['category'] = cat
end
filters(&block) click to toggle source
# File lib/mail_engine/sendgrid/smtp_api.rb, line 51
def filters(&block)
  filter_setting = FilterSetting.new
  filter_setting.instance_eval(&block)
  @data["filters"] = filter_setting.data
end
set_send_to(to) click to toggle source

for now only allow to send to one receiver once. maybe we don't like people received a mail which allow people to view all receivers

# File lib/mail_engine/sendgrid/smtp_api.rb, line 59
def set_send_to(to)
  @data['to'] ||= []
  @data['to'] = Array.wrap(to)
  @data['to'].uniq!
end
set_unique_args(val) click to toggle source
# File lib/mail_engine/sendgrid/smtp_api.rb, line 76
def set_unique_args(val)
  @data['unique_args'] = val if val.instance_of?(Hash)
end
to_hash() click to toggle source
# File lib/mail_engine/sendgrid/smtp_api.rb, line 84
def to_hash
  {'X-SMTPAPI' => self.to_json}
end
to_json() click to toggle source
# File lib/mail_engine/sendgrid/smtp_api.rb, line 80
def to_json
  @data.to_json.gsub(/(["\]}])([,:])(["\[{])/, '\\1\\2 \\3')
end
to_s() click to toggle source
# File lib/mail_engine/sendgrid/smtp_api.rb, line 88
def to_s
  'X-SMTPAPI: %s' % self.to_json
end