Class: RBET::Client
Direct Known Subclasses
Instance Attribute Summary collapse
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
-
#initialize(username, password, options = {}) ⇒ Client
constructor
Initializes a new ET::Client object.
-
#live? ⇒ Boolean
Boolean value of whether the service is running or not currently.
-
#send {|@system| ... } ⇒ Object
usage: send do|io| io << ‘more xml’ end.
-
#status ⇒ Object
Returns the string value from the ExactTarget API ping method.
Methods included from Renderable
#render_template, #set_template_path, #template_path
Constructor Details
#initialize(username, password, options = {}) ⇒ Client
Initializes a new ET::Client object
Usaage:
client = ET::Client.new('tester','tester11', {:service_url => 'http://127.0.0.1:99999/test/', :use_ssl => false})
client.status
=> "Running"
client.live?
=> true
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/rbet/client.rb', line 44 def initialize(username,password,={}) @username = username @password = password service_url = [:service_url] ? [:service_url] : 'https://www.exacttarget.com/api/integrate.asp?qf=xml' @uri = URI.parse(service_url) @url = Net::HTTP.new(@uri.host, @uri.port) @url.use_ssl = .key?(:use_ssl) ? [:use_ssl] : true @url.set_debug_output .key?(:debug_output) ? [:debug_output] : nil @headers = { 'Content-Type' => 'application/x-www-form-urlencoded' } end |
Instance Attribute Details
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
31 32 33 |
# File 'lib/rbet/client.rb', line 31 def headers @headers end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
31 32 33 |
# File 'lib/rbet/client.rb', line 31 def password @password end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
31 32 33 |
# File 'lib/rbet/client.rb', line 31 def username @username end |
Instance Method Details
#live? ⇒ Boolean
Boolean value of whether the service is running or not currently
58 59 60 61 |
# File 'lib/rbet/client.rb', line 58 def live? @current_status ||= status @current_status == 'Running' end |
#send {|@system| ... } ⇒ Object
usage:
send do|io|
io << 'more xml'
end
77 78 79 80 81 82 83 84 |
# File 'lib/rbet/client.rb', line 77 def send @system = "" yield @system result = 'qf=xml&xml=' + render_template( 'auth' ) @url.post( @uri.path, result, @headers.merge('Content-length' => result.length.to_s) ) end |
#status ⇒ Object
Returns the string value from the ExactTarget API ping method. (“Running” when the system is operational)
64 65 66 67 68 69 70 71 |
# File 'lib/rbet/client.rb', line 64 def status response = send do|io| io << render_template('ping') end Error.check_response_error(response) doc = Hpricot.XML( response.read_body ) @current_status = doc.at("Ping").inner_html end |