Skip to content

Commit

Permalink
Implement #bulk_async_retrieve_subscriber_statuses Action
Browse files Browse the repository at this point in the history
  • Loading branch information
rjkaes committed Sep 29, 2014
1 parent fa3ee02 commit 7ebfc4d
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
25 changes: 25 additions & 0 deletions lib/exact_target/request_builder.rb
Expand Up @@ -99,6 +99,31 @@ def batch_inquire(batch_id)
)
end

# Public: Builds an BulkAsync Subscriber request. A BulkAsync is used to
# retrieve information from ExactTarget that is too big to return in
# a normal SOAP call. Instead, the results are deposited on an SFTP server
# for later retrieval.
#
# list_id - An optional Integer list id. When not supplied, returns the
# subscriber statuses for *all* lists.
#
# Examples
#
# batch_id = ExactTarget.bulk_async_retrieve_subscriber_statuses
# => 12345
# ExactTarget.batch_inquire(batch_id)
#
# Returns an XML String.
def bulk_async_retrieve_subscriber_statuses(list_id = :no_list_id_supplied)
ensure_executable!("subscriber_bulk_async")
args = { :sub_action => 'SubsStatus_ToFTP' }

args.merge!(:search_type => :lid, :search_value => Integer(list_id)) \
unless list_id == :no_list_id_supplied

build(:subscriber, 'BulkAsync', args)
end

###################################################################

def triggered_send_add(external_key, channel_member_id, email_addresses, options={})
Expand Down
4 changes: 4 additions & 0 deletions lib/exact_target/response_handler.rb
Expand Up @@ -76,6 +76,10 @@ def batch_inquire(resp)
create_result(BatchStatus, resp.xpath('//Batch').first)
end

def bulk_async_retrieve_subscriber_statuses(resp)
resp.xpath('//batchID').text.to_i
end

###################################################################

alias :subscriber_add :handle_subscriber_id_result
Expand Down
19 changes: 19 additions & 0 deletions spec/exact_target/request_builder_spec.rb
@@ -0,0 +1,19 @@
require 'spec_helper'

describe ExactTarget::RequestBuilder do
subject { ExactTarget::RequestBuilder.new(ExactTarget::Configuration.new) }

describe '#bulk_async_retrieve_subscriber_statuses' do
it 'returns the correct XML' do
xml = %q(
<system>
<system_name>subscriber</system_name>
<action>BulkAsync</action>
<sub_action>SubsStatus_ToFTP</sub_action>
<search_type>lid</search_type>
<search_value>1</search_value>
</system>).gsub(%r(\n), '')
expect(subject.bulk_async_retrieve_subscriber_statuses(1)).to match(xml)
end
end
end

0 comments on commit 7ebfc4d

Please sign in to comment.