Close and Go BackBack to Viget

Introducing: EmailLabsClient

David Eisinger
David Eisinger, Senior Developer, July 31, 2008

On my latest project, the client is using EmailLabs to manage their mailing lists. To simplify interaction with their system, we’ve created EmailLabsClient, a small Ruby client for the EmailLabs API. The core of the program is the send_request method:

def self.send_request(request_type, activity)
  xml = Builder::XmlMarkup.new :target => (input = '')
  xml.instruct!
  xml.DATASET do
    xml.SITE_ID SITE_ID
    yield xml
  end
  Net::HTTP.post_form(URI.parse(ENDPOINT),
    :type => request_type, :activity => activity,
    :input => input)
end

Then you can make API requests like this:

def self.subscribe_user(mailing_list, email_address)
  send_request('record', 'add') do |body|
    body.MLID mailing_list
    body.DATA email_address, :type => 'email'
  end
end

If you find yourself needing to work with an EmailLabs mailing list, check it out. At the very least, you should get a decent idea of how to interact with their API. It’s up on GitHub, so if you add any functionality, send those patches our way.

blog comments powered by Disqus

We're the Developers

at Viget Labs. We write about web development trends, tips, best practices, industry events, and our projects — all with an emphasis on Ruby on Rails.

Contact Us

Have any questions, comments, ideas, or secrets to share? Let us know.


How many days in a non-leap year?

Sorry, you need to have Javascript enabled to use this form. (Don't blame us, blame the spammers!) If you'd like to contact us, please visit our Contact page.