Class: RBET::TriggeredSend

Inherits:
Client
  • Object
show all
Defined in:
lib/rbet/triggered_send.rb

Overview

usage:

# First load the Trigger client
trigger = ET::TriggeredSend.new('username', 'password')

# send message
summary = trigger.deliver("[email protected]", "message-key", {:first_name => 'John', :last_name => 'Wayne'})
=> 0 # success

Instance Attribute Summary

Attributes inherited from Client

#headers, #password, #username

Instance Method Summary collapse

Methods inherited from Client

#live?, #send, #status

Methods included from Renderable

#render_template, #set_template_path, #template_path

Constructor Details

#initialize(username, password, options = {}) ⇒ TriggeredSend

Returns a new instance of TriggeredSend.



41
42
43
# File 'lib/rbet/triggered_send.rb', line 41

def initialize(username, password, options={})
  super
end

Instance Method Details

#deliver(email, external_key, attributes = {}) ⇒ Object

deliver triggered email



46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/rbet/triggered_send.rb', line 46

def deliver(email, external_key, attributes={} )
  @email = email
  @external_key = external_key
  @attributes = attributes
  raise "external_key can't be nil" unless @external_key
  response = send do|io|
    io << render_template('triggered_send')
  end
  Error.check_response_error(response)
  doc = Hpricot.XML(response.read_body)
  doc.at("triggered_send_description").inner_html.to_i
end