Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Pull in changes from Paul Nock and bump version

  • Loading branch information...
commit cf766ed3db46b93f2214e49697635b66d3fb8d04 2 parents 87b9a4b + ea45463
David McCullars authored
View
12 CHANGELOG
@@ -1,3 +1,15 @@
+v0.0.6. Pull in enhancements from Paul Nock and add as contributor:
+
+I added some triggered send support, and also switched 'send_to_exact_target' to
+http POST instead of GET. In our case, we were starting to generate some long xml
+parameters and we didn't want to run into size limits for GET. I'm not completely
+sure how generic the triggered send xml is, but it works well in our case. I'm not
+sure if the different Exact Target Account types affect this.
+
+Additionally, we were seeing some issues trying to register Facebook proxy email
+addresses with Exact Target, for example app+asdfadsfasdfasdf@proxymail.facebook.com.
+It was easier to simply POST this data than trying to properly escape the + in the data.
+
v0.0.5. Fix corrupted gem
v0.0.4. Fix gem to include CHANGELOG
v0.0.3. Allow for passing ExactTarget::Subscriber into subscriber_add and subscriber_edit
View
10 README.rdoc
@@ -164,6 +164,16 @@ tracking functionality is yet implemented.
:send_time => '17:35',
:test_send => true)
+=== Triggered Sends
+
+ # Kick off a triggered send
+ ExactTarget.triggered_send_add(external_key,
+ channel_member_id,
+ email_addresses =[],
+ options = {})
+ email_addresses is an array of addresses of subscribers
+ options is a hash of name value attributes to pass to the triggered send to add custom data to the email message
+
---
Author:: David McCullars <mailto:dmccullars@ePublishing.com>
Copyright:: (C) 2011 ePublishing
View
20 exact-target.gemspec
@@ -1,17 +1,19 @@
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
- s.name = "exact-target"
- s.version = "0.0.5"
+ s.name = %q{exact-target}
+ s.version = "0.1.7"
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
- s.authors = ["David McCullars"]
- s.date = "2011-10-25"
- s.description = "This is a pure-ruby implementation of the ExactTarget api.\nFor more information consule http://www.exacttarget.com/.\n"
- s.email = "dmccullars@ePublishing.com"
- s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README.rdoc", "lib/exact-target.rb"]
- s.files = ["CHANGELOG", "Gemfile", "Gemfile.lock", "LICENSE", "Manifest", "README.rdoc", "Rakefile", "lib/exact-target.rb", "lib/exact_target.rb", "lib/exact_target/builder_ext.rb", "lib/exact_target/configuration.rb", "lib/exact_target/error.rb", "lib/exact_target/net_https_hack.rb", "lib/exact_target/request_builder.rb", "lib/exact_target/response_class.erb", "lib/exact_target/response_classes.rb", "lib/exact_target/response_handler.rb", "lib/exact_target/string_ext.rb", "lib/exacttarget.rb", "spec/exact_target/net_https_hack_spec.rb", "spec/exact_target/response_handler_spec.rb", "spec/exact_target/string_ext_spec.rb", "spec/exact_target_data.yml", "spec/exact_target_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "exact-target.gemspec"]
- s.homepage = "http://github.com/ePublishing/exact_target"
+ s.authors = ["David McCullars", "Paul Nock"]
+ s.date = %q{2011-02-09}
+ s.description = %q{This is a pure-ruby implementation of the ExactTarget api.
+For more information consule http://www.exacttarget.com/.
+}
+ s.email = %q{dmccullars@ePublishing.com, nocksf@gmail.com}
+ s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README.rdoc"]
+ s.files = ["CHANGELOG", "LICENSE", "README.rdoc", "Rakefile", "lib/exact_target.rb", "lib/exact_target/builder_ext.rb", "lib/exact_target/configuration.rb", "lib/exact_target/error.rb", "lib/exact_target/net_https_hack.rb", "lib/exact_target/request_builder.rb", "lib/exact_target/response_class.erb", "lib/exact_target/response_classes.rb", "lib/exact_target/response_handler.rb", "lib/exact_target/string_ext.rb", "spec/exact_target/net_https_hack_spec.rb", "spec/exact_target/response_handler_spec.rb", "spec/exact_target/string_ext_spec.rb", "spec/exact_target_data.yml", "spec/exact_target_spec.rb", "spec/spec.opts", "Manifest", "exact-target.gemspec"]
+ s.homepage = %q{http://github.com/ePublishing/exact_target}
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Exact-target", "--main", "README.rdoc"]
s.require_paths = ["lib"]
s.rubyforge_project = "exact-target"
View
9 lib/exact_target.rb
@@ -71,12 +71,12 @@ def call(method, *args, &block)
def send_to_exact_target(request)
verify_configure
- uri = URI.parse "#{configuration.base_url}?qf=xml&xml=#{URI.escape request}"
+ uri = URI.parse configuration.base_url
http = net_http_or_proxy.new(uri.host, uri.port)
http.use_ssl = configuration.secure?
http.open_timeout = configuration.http_open_timeout
http.read_timeout = configuration.http_read_timeout
- resp = http.get(uri.request_uri)
+ resp = http.post(uri.request_uri, { 'qf' => 'xml', 'xml'=> request }.to_query)
if resp.is_a?(Net::HTTPSuccess)
resp.body
else
@@ -84,10 +84,11 @@ def send_to_exact_target(request)
end
end
+
# Define ExactTarget methods
(RequestBuilder.instance_methods(false) & ResponseHandler.instance_methods(false)).each do |m|
- define_method(m) do |*args, &block|
- call(m, *args, &block)
+ define_method(m) do |*args|
+ call(m, *args)
end
end
View
35 lib/exact_target/request_builder.rb
@@ -90,6 +90,24 @@ def batch_inquire(batch_id)
###################################################################
+ def triggered_send_add(external_key, channel_member_id, email_addresses, options={})
+ build(:triggeredsend, :add, :search_type => :omit, :search_value => :omit) do |operation|
+ operation.TriggeredSend('xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
+ 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema',
+ 'xmlns' => 'http://exacttarget.com/wsdl/partnerAPI') do |ts|
+ ts.TriggeredSendDefinition do |tsd|
+ tsd.CustomerKey external_key
+ tsd.Priority 'High'
+ end
+ email_addresses.each do |addr|
+ build_ts_subscriber(ts, channel_member_id, addr, options)
+ end
+ end
+ end
+ end
+
+ ###################################################################
+
def subscriber_add(list_id, subscriber, options={})
subscriber_edit(list_id, nil, subscriber, options)
end
@@ -279,5 +297,22 @@ def build_system_option(s, name, value)
end
end
+ def build_ts_subscriber(triggered_send, channel_member_id, email_address, options ={})
+ triggered_send.Subscribers('xmlns' => 'http://exacttarget.com/wsdl/partnerAPI') do |sub|
+ sub.Owner do |owner|
+ owner.Client do |client|
+ client.ID channel_member_id
+ end
+ end
+ sub.SubscriberKey email_address
+ sub.EmailAddress email_address
+ options.each do |key, value|
+ sub.Attributes do |atts|
+ atts.Name key.to_s
+ atts.Value value
+ end
+ end if options.present?
+ end
+ end
end
end
View
8 lib/exact_target/response_handler.rb
@@ -15,9 +15,9 @@ def handle_import_id_result(resp)
handle_id_result resp, :import_info, :importid, /is being imported/i
end
- %w(email job list subscriber).each do |t|
+ %w(email job list subscriber triggered_send).each do |t|
define_method "handle_#{t}_id_result", lambda { |resp|
- handle_id_result resp, "#{t}_info", "#{t}_description", /success/i
+ handle_id_result resp, "#{t}_info", "#{t}_description", /success|sucess/i
}
end
@@ -29,6 +29,8 @@ def accountinfo_retrieve_attrbs(resp)
end
end
+ alias :triggered_send_add :handle_triggered_send_id_result
+
alias :list_add :handle_list_id_result
alias :list_edit :handle_list_id_result
@@ -85,7 +87,7 @@ def subscriber_retrieve(resp)
return [] if s.text =~ /no subscribers found/i
sri = create_result(SubscriberInformation, s)
sri.subscriber = create_result(ExactTarget::Subscriber, s)
- sri
+ return sri
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.