Class: Sepa::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/sepa/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Client

Check that parameters are valid, initialize savon client with them and construct soap message



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/sepa/client.rb', line 5

def initialize(params)
  check_params_hash(params)
  check_bank(params.fetch(:bank))
  bank = params.fetch(:bank)

  wsdl = find_proper_wsdl(bank, params.fetch(:command))

  @client = Savon.client(wsdl: wsdl) #log_level: :info
  @command = params.fetch(:command)
  # SoapBuilder creates a complete SOAP message structure
  @soap = SoapBuilder.new(params).to_xml
end

Instance Method Details

#sendObject

Call savon to make the soap request with the correct command and the the constructed soap. The returned object will be a savon response.



20
21
22
# File 'lib/sepa/client.rb', line 20

def send
  @client.call(@command, xml: @soap)
end