Class: Silverpop::Mailer
- Inherits:
-
Object
- Object
- Silverpop::Mailer
- Defined in:
- lib/silverpop/mailer.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#request ⇒ Object
Returns the value of attribute request.
-
#response ⇒ Object
Returns the value of attribute response.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Mailer
constructor
A new instance of Mailer.
- #mail(campaign_id, email, options = {}) ⇒ Object
-
#send(request) ⇒ Object
Submits the request.
Constructor Details
#initialize(options = {}) ⇒ Mailer
Returns a new instance of Mailer.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/silverpop/mailer.rb', line 7 def initialize( = {}) # config self.config = # logger Silverpop.logger.level = self.config[:log_level] || Logger::ERROR # logging Silverpop.logger.debug "Mailer init: #{self.config[:server]}" end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
5 6 7 |
# File 'lib/silverpop/mailer.rb', line 5 def config @config end |
#request ⇒ Object
Returns the value of attribute request.
5 6 7 |
# File 'lib/silverpop/mailer.rb', line 5 def request @request end |
#response ⇒ Object
Returns the value of attribute response.
5 6 7 |
# File 'lib/silverpop/mailer.rb', line 5 def response @response end |
Instance Method Details
#mail(campaign_id, email, options = {}) ⇒ Object
18 19 20 21 |
# File 'lib/silverpop/mailer.rb', line 18 def mail(campaign_id, email, = {}) self.request = Silverpop::Request.new(campaign_id, email, ) self.response = Silverpop::Response.new(self.send(self.request.generate)) end |
#send(request) ⇒ Object
Submits the request.
25 26 27 28 29 |
# File 'lib/silverpop/mailer.rb', line 25 def send(request) # TODO: implement into Silverpop::Transact res = Net::HTTP.post_form(URI.parse(self.config[:server]), :xml => request) res.body end |