Created
February 27, 2014 18:34
-
-
Save loe/9256190 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'httparty' | |
class LitmusTest | |
include HTTParty | |
base_uri('https://api.litmus.com/v2') | |
basic_auth('<YOUR API KEY>', 'x') | |
headers({'Content-Type' => 'application/json'}) | |
def self.create(subject, body) | |
post('/emails', :body => {:email => {:name => "#{subject} @ #{Time.now.to_s(:short)}", :subject => subject, :body => body, :client_ids => self.client_ids}}.to_json) | |
end | |
# Cache the client_id list per test suite. | |
def self.client_ids | |
@@client_ids ||= get('/emails/clients')['clients'].map { |client| client['id'] } | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def write_output_to_file(subject, body) | |
if ENV['LITMUS'] | |
puts "Posting email to Litmus:" | |
test = LitmusTest.create(subject, body) | |
puts "Created Litmus Test: #{test.body}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment