lib/sailthru.rb in sailthru-client-1.04 vs lib/sailthru.rb in sailthru-client-1.05

- old
+ new

@@ -5,11 +5,11 @@ require 'json' require 'digest/md5' module Sailthru - Version = VERSION = '1.04' + Version = VERSION = '1.05' class SailthruClientException < Exception end module Helpers @@ -199,11 +199,46 @@ post[:content_html] = content_html post[:content_text] = content_text api_post(:blast, post) end + # Schedule a mass mail blast from template + def schedule_blast_from_template(template, list, schedule_time, options={}) + post = options ? options : {} + post[:copy_template] = template + post[:list] = list + post[:schedule_time] = schedule_time + api_post(:blast, post) + end + # Schedule a mass mail blast from previous blast + def schedule_blast_from_blast(blast_id, schedule_time, options={}) + post = options ? options : {} + post[:copy_blast] = blast_id + #post[:name] = name + post[:schedule_time] = schedule_time + api_post(:blast, post) + end + + def schedule_blast_from_copy(copy_blast = nil, copy_template = nil, options = {}) + if copy_blast.nil? and copy_template.nil? + raise SailthruClientException.new('copy_blast and copy_template are both null') + end + + post = options ? options : {} + if copy_blast != nil + post[:copy_blast] = copy_blast + end + + if copy_template != nil + post[:copy_template] = copy_template + end + + api_post(:blast, post) + end + + # params # blast_id, Fixnum | String # name, String # list, String # schedule_time, String @@ -576,12 +611,10 @@ def delete_alert(email, alert_id) data = {:email => email, :alert_id => alert_id} api_delete(:alert, data) end - protected - # Make Stats API Request def stats(data) api_get(:stats, data) end @@ -597,9 +630,11 @@ #Perform API DELETE request def api_delete(action, data) api_request(action, data, 'DELETE') end + + protected # params: # action, String # data, Hash # request, String "GET" or "POST"