Class: MailEngine::Sendgrid::SmtpApi

Inherits:
Object
  • Object
show all
Defined in:
lib/mail_engine/sendgrid/smtp_api.rb

Overview

smtp api class

Instance Method Summary (collapse)

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)



63
64
65
66
# File 'lib/mail_engine/sendgrid/smtp_api.rb', line 63

def add_sub_val(var, val)
  @data['sub'] ||= {}
  @data['sub'][var] = val.instance_of?(Array) ? var : [var]
end

- (Object) add_to(to)



57
58
59
60
61
# File 'lib/mail_engine/sendgrid/smtp_api.rb', line 57

def add_to(to)
  @data['to'] ||= []
  @data['to'] += to.kind_of?(Array) ? to : [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_unique_args(val)



68
69
70
# File 'lib/mail_engine/sendgrid/smtp_api.rb', line 68

def set_unique_args(val)
  @data['unique_args'] = val if val.instance_of?(Hash)
end

- (Object) to_hash



76
77
78
# File 'lib/mail_engine/sendgrid/smtp_api.rb', line 76

def to_hash
  {'X-SMTPAPI' => self.to_json}
end

- (Object) to_json



72
73
74
# File 'lib/mail_engine/sendgrid/smtp_api.rb', line 72

def to_json
  @data.to_json.gsub(/(["\]}])([,:])(["\[{])/, '\\1\\2 \\3')
end

- (Object) to_s



80
81
82
# File 'lib/mail_engine/sendgrid/smtp_api.rb', line 80

def to_s
  'X-SMTPAPI: %s' % self.to_json
end