Skip to content

Commit

Permalink
Added Jeff's batch processing stuff to the exact target gem.
Browse files Browse the repository at this point in the history
  • Loading branch information
charlie-white committed Dec 7, 2011
1 parent 46d5d94 commit fa8f262
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
/pkg /pkg
/doc /doc
*.sw* *.sw*
.idea
*.gem
2 changes: 1 addition & 1 deletion exact-target.gemspec
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


Gem::Specification.new do |s| Gem::Specification.new do |s|
s.name = %q{exact-target} 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.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
s.authors = ["David McCullars"] s.authors = ["David McCullars"]
Expand Down
9 changes: 9 additions & 0 deletions lib/exact_target/configuration.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -40,12 +40,21 @@ class Configuration
attr_accessor :email_whitelist attr_accessor :email_whitelist
attr_accessor :email_blacklist 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 def initialize
@base_url = 'https://api.dc1.exacttarget.com/integrate.aspx' @base_url = 'https://api.dc1.exacttarget.com/integrate.aspx'
@http_open_timeout = 2 @http_open_timeout = 2
@http_read_timeout = 5 @http_read_timeout = 5
@http_method = "get" @http_method = "get"
@readonly = [] @readonly = []
@export_folder = 'Export'
@import_folder = 'Import'
end end


def valid? def valid?
Expand Down
76 changes: 76 additions & 0 deletions lib/exact_target/request_builder.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -241,6 +241,82 @@ def job_send(email_id, list_ids, options={})
end end
end 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 private
################################################################### ###################################################################
Expand Down
3 changes: 3 additions & 0 deletions lib/exact_target/response_classes.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ def extended(base)
class_from_et_attributes base, :EmailInformation, class_from_et_attributes base, :EmailInformation,
:emailname, :emailid, :emailsubject, :emailcreateddate, :categoryid :emailname, :emailid, :emailsubject, :emailcreateddate, :categoryid


class_from_et_attributes base, :BatchStatus,
:status, :batchid, :filename

def base.subscriber_class def base.subscriber_class
@subscriber_class ||= ResponseClasses.class_from_et_attributes( @subscriber_class ||= ResponseClasses.class_from_et_attributes(
self, :Subscriber, accountinfo_retrieve_attrbs.map(&:name), :Status self, :Subscriber, accountinfo_retrieve_attrbs.map(&:name), :Status
Expand Down
21 changes: 20 additions & 1 deletion lib/exact_target/response_handler.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def list_refresh_group(resp)
end end


def batch_inquire(resp) def batch_inquire(resp)
resp.xpath('//Batch/status[1]').first.text create_result(BatchStatus, resp.xpath('//Batch').first)
end end


################################################################### ###################################################################
Expand Down Expand Up @@ -126,6 +126,25 @@ def triggeredsend_add(resp)


alias :job_send :handle_job_id_result 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 private
################################################################### ###################################################################
Expand Down

0 comments on commit fa8f262

Please sign in to comment.