Permalink
Browse files

Merge branch 'master' into limit_requests

  • Loading branch information...
2 parents c74c41c + dca9107 commit c4f94f2a70258e9669f53e81a7e481ced67ebd46 Jeff Ching committed Aug 24, 2011
Showing with 15 additions and 3 deletions.
  1. +10 −2 lib/exact_target.rb
  2. +5 −1 lib/exact_target/configuration.rb
View
@@ -71,12 +71,20 @@ 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}"
+
+ data = "qf=xml&xml=#{URI.escape(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)
+
+ if configuration.http_method == "post"
+ resp = http.post(uri.request_uri, data)
+ else
+ resp = http.get(uri.request_uri + "?" + data)
+ end
+
if resp.is_a?(Net::HTTPSuccess)
resp.body
else
@@ -3,7 +3,7 @@ module ExactTarget
class Configuration
OPTIONS = [:base_url, :username, :password,
- :http_open_timeout, :http_read_timeout, :http_proxy].freeze
+ :http_method, :http_open_timeout, :http_read_timeout, :http_proxy].freeze
# The (optional) base URL for accessing ExactTarget (can be http or https).
# Defaults to 'https://api.dc1.exacttarget.com/integrate.aspx'
@@ -27,10 +27,14 @@ class Configuration
# The (optional) HTTP proxy url
attr_accessor :http_proxy
+ # The HTTP method to make the request with
+ attr_accessor :http_method
+
def initialize
@base_url = 'https://api.dc1.exacttarget.com/integrate.aspx'
@http_open_timeout = 2
@http_read_timeout = 5
+ @http_method = "get"
end
def valid?

0 comments on commit c4f94f2

Please sign in to comment.