Browse files

Added Jeff's batch processing stuff to the exact target gem.

  • Loading branch information...
1 parent 46d5d94 commit fa8f262c4b898b73938a369afdf514c8e00b0aae @charlie-white charlie-white committed Dec 7, 2011
View
2 .gitignore
@@ -2,3 +2,5 @@
/pkg
/doc
*.sw*
+.idea
+*.gem
View
2 exact-target.gemspec
@@ -2,7 +2,7 @@
Gem::Specification.new do |s|
s.name = %q{exact-target}
- s.version = "0.0.4"
+ s.version = "0.0.5.beta2"
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
s.authors = ["David McCullars"]
View
9 lib/exact_target/configuration.rb
@@ -40,12 +40,21 @@ class Configuration
attr_accessor :email_whitelist
attr_accessor :email_blacklist
+ # optional params for batch
+ attr_accessor :ftp_base_url
+ attr_accessor :ftp_username
+ attr_accessor :ftp_password
+ attr_accessor :export_folder
+ attr_accessor :import_folder
+
def initialize
@base_url = 'https://api.dc1.exacttarget.com/integrate.aspx'
@http_open_timeout = 2
@http_read_timeout = 5
@http_method = "get"
@readonly = []
+ @export_folder = 'Export'
+ @import_folder = 'Import'
end
def valid?
View
76 lib/exact_target/request_builder.rb
@@ -242,6 +242,82 @@ def job_send(email_id, list_ids, options={})
end
###################################################################
+
+ def list_bulkasync(list_id, list_status = nil)
+ build(
+ :list, :bulkasync,
+ :sub_action => 'Subs_ToFTP',
+ :search_type => :listid,
+ :search_value => list_id
+ ) do |xml|
+ xml.search_status list_status if list_status
+ end
+ end
+
+ def subscriber_bulkasync(list_id)
+ build(:subscriber, :BulkAsync,
+ :sub_action => "SubsStatus_ToFTP",
+ :search_type => "lid",
+ :search_value => list_id)
+ end
+
+ # "retrieves complete tracking data for an email send"
+ def tracking_bulkasync_all(job_id, start_date = nil, end_date = nil)
+ build(:tracking, :BulkAsync,
+ :sub_action => "all_ToFTP",
+ :search_type => "jobID",
+ :search_value => job_id) do |xml|
+ if start_date || end_date
+ start_date = start_date.strftime("%m/%d/%Y") if start_date.respond_to?(:strftime)
+ end_date = end_date.strftime("%m/%d/%Y") if end_date.respond_to?(:strftime)
+ xml.daterange do
+ xml.startdate start_date
+ xml.enddate end_date
+ end
+ end
+ end
+ end
+
+ def tracking_bulkasync_all_attributes(job_id, start_date = nil, end_date = nil)
+ build(:tracking, :BulkAsync,
+ :sub_action => "all_attributes_ToFTP",
+ :search_type => "jobID",
+ :search_value => job_id) do |xml|
+ if start_date || end_date
+ start_date = start_date.strftime("%m/%d/%Y") if start_date.respond_to?(:strftime)
+ end_date = end_date.strftime("%m/%d/%Y") if end_date.respond_to?(:strftime)
+ xml.daterange do
+ xml.startdate start_date
+ xml.enddate end_date
+ end
+ end
+ end
+ end
+
+ def tracking_sent_bulkasync_all(job_id)
+ build(:tracking, :Sent_BulkAsync,
+ :sub_action => "all_ToFTP",
+ :search_type => "jobID",
+ :search_value => job_id)
+ end
+
+ def tracking_sent_bulkasync_all_attributes(job_id, start_date = nil, end_date = nil)
+ build(:tracking, :Sent_BulkAsync,
+ :sub_action => "all_attributes_ToFTP",
+ :search_type => "jobID",
+ :search_value => job_id) do |xml|
+ if start_date || end_date
+ start_date = start_date.strftime("%m/%d/%Y") if start_date.respond_to?(:strftime)
+ end_date = end_date.strftime("%m/%d/%Y") if end_date.respond_to?(:strftime)
+ xml.daterange do
+ xml.startdate start_date
+ xml.enddate end_date
+ end
+ end
+ end
+ end
+
+ ###################################################################
private
###################################################################
View
3 lib/exact_target/response_classes.rb
@@ -28,6 +28,9 @@ def extended(base)
class_from_et_attributes base, :EmailInformation,
:emailname, :emailid, :emailsubject, :emailcreateddate, :categoryid
+ class_from_et_attributes base, :BatchStatus,
+ :status, :batchid, :filename
+
def base.subscriber_class
@subscriber_class ||= ResponseClasses.class_from_et_attributes(
self, :Subscriber, accountinfo_retrieve_attrbs.map(&:name), :Status
View
21 lib/exact_target/response_handler.rb
@@ -71,7 +71,7 @@ def list_refresh_group(resp)
end
def batch_inquire(resp)
- resp.xpath('//Batch/status[1]').first.text
+ create_result(BatchStatus, resp.xpath('//Batch').first)
end
###################################################################
@@ -127,6 +127,25 @@ def triggeredsend_add(resp)
alias :job_send :handle_job_id_result
###################################################################
+
+ def list_bulkasync(resp)
+ resp.xpath('//batchID').first.text.to_i
+ end
+
+ def subscriber_bulkasync(resp)
+ resp.xpath('//batchID').first.text.to_i
+ end
+
+ def tracking_sent_bulkasync_all(resp)
+ resp.xpath('//batchID').first.text.to_i
+ end
+
+ def tracking_sent_bulkasync_all_attributes(resp)
+ resp.xpath('//batchID').first.text.to_i
+ end
+
+
+ ###################################################################
private
###################################################################

0 comments on commit fa8f262

Please sign in to comment.