Class: ExactTarget::Client
- Inherits:
-
Object
- Object
- ExactTarget::Client
- Defined in:
- lib/exacttarget/email.rb,
lib/exacttarget/client.rb
Instance Attribute Summary collapse
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
- #email_create(name, subject, html, text = false) ⇒ Object
- #email_find(options = {}) ⇒ Object
- #email_find_all(body = false) ⇒ Object
- #email_find_by_id(id, options = {}) ⇒ Object
- #email_find_by_name(name, options = {}) ⇒ Object
- #email_find_by_subject(subject, options = {}) ⇒ Object
-
#initialize(username, password) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(username, password) ⇒ Client
Returns a new instance of Client.
8 9 10 11 12 13 14 |
# File 'lib/exacttarget/client.rb', line 8 def initialize(username, password) @username = username @password = password @uri = URI.parse('https://api.dc1.exacttarget.com/integrate.asp') @url = Net::HTTP.new(@uri.host, @uri.port) @url.use_ssl = true end |
Instance Attribute Details
#password ⇒ Object (readonly)
Returns the value of attribute password.
4 5 6 |
# File 'lib/exacttarget/client.rb', line 4 def password @password end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
4 5 6 |
# File 'lib/exacttarget/client.rb', line 4 def username @username end |
Instance Method Details
#email_create(name, subject, html, text = false) ⇒ Object
85 86 87 88 89 |
# File 'lib/exacttarget/email.rb', line 85 def email_create(name, subject, html, text = false) id = email_add_html(name, subject, html) email_add_text(id, text) if text id end |
#email_find(options = {}) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/exacttarget/email.rb', line 29 def email_find( = {}) @action = 'retrieve' @sub_action = 'all' @type = '' @value = '' id = [:id] || false name = [:name] || false subject = [:subject] || false start_date = [:start] || false end_date = [:end] || false get_body = [:body] || false list = [] format = Proc.new { |date| begin date if date.instance_of? Date Date.strptime(date, '%m/%d/%Y') rescue raise '[ExactTarget] Error: Invalid date.' end } Nokogiri::Slop(send(render(:email))) .exacttarget .system .email .emaillist.each do |email| (next if email.emailid.content != id.to_s) if id (next if !email.emailname.content.include? name.to_s) if name (next if !email.emailsubject.content.include? subject.to_s) if subject date = format.call(email.emailcreateddate.content) (next if date < format.call(start_date)) if start_date (next if date > format.call(end_date)) if end_date body = email_get_body(email.emailid.content) if get_body email.instance_eval do new = { :id => emailid.content, :name => emailname.content, :subject => emailsubject.content, :date => email.emailcreateddate.content, :category_id => categoryid.content } new[:body] = body if get_body list << new end end list end |
#email_find_all(body = false) ⇒ Object
6 7 8 |
# File 'lib/exacttarget/email.rb', line 6 def email_find_all(body = false) email_find({ :body => body }) end |
#email_find_by_id(id, options = {}) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/exacttarget/email.rb', line 10 def email_find_by_id(id, = {}) email_find({ :id => id, :body => true }.merge()) end |
#email_find_by_name(name, options = {}) ⇒ Object
17 18 19 20 21 |
# File 'lib/exacttarget/email.rb', line 17 def email_find_by_name(name, = {}) email_find({ :name => name, }.merge()) end |
#email_find_by_subject(subject, options = {}) ⇒ Object
23 24 25 26 27 |
# File 'lib/exacttarget/email.rb', line 23 def email_find_by_subject(subject, = {}) email_find({ :subject => subject, }.merge()) end |