Module: Zanox::Connect

Defined in:
lib/zanox.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#driverObject

Returns the value of attribute driver.



111
112
113
# File 'lib/zanox.rb', line 111

def driver
  @driver
end

#wsdlObject

Returns the value of attribute wsdl.



110
111
112
# File 'lib/zanox.rb', line 110

def wsdl
  @wsdl
end

Class Method Details

.request(method, options) ⇒ Object



113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/zanox.rb', line 113

def self.request(method, options)
  begin
    options.merge!(:publicKey=>Zanox::API.public_key)
  
    unless Zanox::API.secret_key.nil?
      timestamp = Zanox::API.get_timestamp
      nonce = Zanox::API.generate_nonce
      signature = Zanox::API.create_signature(Zanox::API.secret_key, "connectservice"+method.downcase + timestamp + nonce)
      options.merge!(:timestamp=>timestamp, :nonce=>nonce, :signature=>signature)
    end
  
    @wsdl = 'https://auth.zanox-affiliate.de/wsdl/2010-02-01' unless !!@wsdl
    @driver = SOAP::WSDLDriverFactory.new(@wsdl).create_rpc_driver unless !!@driver
    @driver.wiredump_dev = STDOUT if $DEBUG
    @driver.options['protocol.http.ssl_config.verify_mode'] = OpenSSL::SSL::VERIFY_NONE if $DEBUG
    @driver.method(method.to_sym).call(options)
  rescue Exception => e
    puts
    puts "ERROR"
    puts e.message
  end
end