lib/eroi/client.rb in eroi-0.1.0 vs lib/eroi/client.rb in eroi-0.1.1
- old
+ new
@@ -4,10 +4,15 @@
end
class Client
attr_reader :user_token, :api_password
+ def self.api_available?
+ Request::Post.api_available? &&
+ Request::Get.api_available?
+ end
+
def initialize(user_token, api_password)
@user_token = user_token
@api_password = api_password
end
@@ -32,16 +37,27 @@
Request::Post.send(self, build_contact_record(
:email => email,
:clear_record => 1 ))
end
+ def send_list_edition_to_contact(list, edition, email)
+ emails = ((email.is_a?(String)) ? [ email ] : email).join(',')
+
+ xml = Builder::XmlMarkup.new
+ xml.tag!('Send', emails, 'List' => list, 'Edition' => edition)
+
+ Request::Post.send(self, xml)
+ end
+
+ alias :send_list_edition_to_contacts :send_list_edition_to_contact
+
private
def build_contact_record(fields)
xml = Builder::XmlMarkup.new
- xml.tag!('Record') do |r|
+ xml.tag!('Record') do |x|
fields.each do |k,v|
- r.tag!(k.to_s.camelize, v)
+ x.tag!(k.to_s.camelize, v)
end
end
xml
end
end