Method: ETAPI::Session#initialize
- Defined in:
- lib/etapi/exact_target.rb
#initialize(*args) ⇒ Session
initialize a new exact target instance
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/etapi/exact_target.rb', line 23 def initialize(*args) # merge options with configuration = args. @username = [:username] ||= ETAPI.username @password = [:password] ||= ETAPI.password @use_s4 = [:use_s4] ||= ETAPI.use_s4 ||= DEFAULTS[:use_s4] @headers = {"Content-Type" => "application/x-www-form-urlencoded", "Connection" => "close"} # check for required options raise ArgumentError, "* missing :username *" if @username.blank? raise ArgumentError, "* missing :password *" if @password.blank? raise ArgumentError, "* invalid :use_s4 | options => [true, false] *" unless ALLOWED_USE_S4_OPTIONS.include?(@use_s4) @api_uri = @use_s4 ? DEFAULTS[:api_uri_xml_s4] : DEFAULTS[:api_uri_xml] @api_wsdl = @api_uri if @use_s4 # parse uri @api_uri = URI.parse(@api_uri) @api_url = Net::HTTP.new(@api_uri.host, @api_uri.port) # check for SSL (disabled) @api_url.use_ssl = [:use_ssl] ||= DEFAULTS[:use_ssl] end |