Class: SynergyWholesale::API

Inherits:
Object
  • Object
show all
Defined in:
lib/synergy_wholesale/api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#adapterObject



10
11
12
# File 'lib/synergy_wholesale/api.rb', line 10

def adapter
  @adapter ||= Adapter.new
end

#response_generatorObject



14
15
16
# File 'lib/synergy_wholesale/api.rb', line 14

def response_generator
  @response_generator ||= ResponseGenerator.new
end

Instance Method Details

#call(command) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/synergy_wholesale/api.rb', line 18

def call(command)
  adapter.add_params(command.to_param)
  command_name = command.class.name
  soap_command = command.operation

  savon_response = adapter.call(soap_command)
  response       = savon_response.body["#{soap_command}_response".to_sym][:return]
  response_generator.build_response(command_name, response, soap_command)
end