Class: MailEngine::Sendgrid::SmtpApi
- Inherits:
-
Object
- Object
- MailEngine::Sendgrid::SmtpApi
- Defined in:
- lib/mail_engine/sendgrid/smtp_api.rb
Overview
smtp api class
Instance Method Summary (collapse)
- - (Object) add_sub_val(var, val)
- - (Object) add_to(to)
- - (Object) category(cat)
- - (Object) filters(&block)
-
- (SmtpApi) initialize
constructor
A new instance of SmtpApi.
-
- (Object) set_send_to(to)
for now only allow to send to one receiver once.
- - (Object) set_unique_args(val)
- - (Object) to_hash
- - (Object) to_json
- - (Object) to_s
Constructor Details
- (SmtpApi) initialize
A new instance of SmtpApi
43 44 45 |
# File 'lib/mail_engine/sendgrid/smtp_api.rb', line 43 def initialize() @data = {} end |
Instance Method Details
- (Object) add_sub_val(var, val)
71 72 73 74 |
# 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 |
- (Object) add_to(to)
65 66 67 68 69 |
# 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 |
- (Object) category(cat)
47 48 49 |
# File 'lib/mail_engine/sendgrid/smtp_api.rb', line 47 def category(cat) @data['category'] = cat end |
- (Object) filters(&block)
51 52 53 54 55 |
# 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 |
- (Object) set_send_to(to)
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
59 60 61 62 63 |
# 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 |
- (Object) set_unique_args(val)
76 77 78 |
# 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 |
- (Object) to_hash
84 85 86 |
# File 'lib/mail_engine/sendgrid/smtp_api.rb', line 84 def to_hash {'X-SMTPAPI' => self.to_json} end |
- (Object) to_json
80 81 82 |
# File 'lib/mail_engine/sendgrid/smtp_api.rb', line 80 def to_json @data.to_json.gsub(/(["\]}])([,:])(["\[{])/, '\\1\\2 \\3') end |
- (Object) to_s
88 89 90 |
# File 'lib/mail_engine/sendgrid/smtp_api.rb', line 88 def to_s 'X-SMTPAPI: %s' % self.to_json end |