Class: Goldeneye::Drivers::Savon

Inherits:
Base
  • Object
show all
Defined in:
lib/goldeneye/drivers/savon.rb

Instance Attribute Summary (collapse)

Attributes inherited from Base

#password, #url, #user

Class Method Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Savon) initialize(service, options = {})

Returns a new instance of Savon



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/goldeneye/drivers/savon.rb', line 15

def initialize(service, options = {})
  super

  ::Savon.configure do |config|
    config.soap_version = 1  # use SOAP 1.2
  end

  @api = ::Savon::Client.new do |wsdl, http|
    wsdl.document = url
    http.auth.basic(user, password) if user && password
  end
end

Instance Attribute Details

- (Object) api (readonly)

Returns the value of attribute api



13
14
15
# File 'lib/goldeneye/drivers/savon.rb', line 13

def api
  @api
end

Class Method Details

+ (Object) log=(log)



7
8
9
10
# File 'lib/goldeneye/drivers/savon.rb', line 7

def log=(log)
  ::Savon.log = log
  ::HTTPI.log = log
end

Instance Method Details

- (Object) call(method, args = {})



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/goldeneye/drivers/savon.rb', line 28

def call(method, args = {})
  begin
    api.request(method) do |soap|
      # Manually uses Gyoku to generate the body xml becase by default Savon appends the
      # namespace to the parameters and that does not work with the R1 CDP api
      soap.body = Gyoku.xml(args)
    end.to_xml
  rescue ::Savon::Error => e
    raise Error.new(e)
  end
end