class Hbci::Dialog

Attributes

connector[R]
hbci_version[R]
id[R]
response[R]
system_id[R]
tan_mechanism[R]

Public Class Methods

new(connector, system_id: 0) click to toggle source
# File lib/hbci/dialog.rb, line 19
def initialize(connector, system_id: 0)
  @connector = connector
  @initiated = false
  @hbci_version = '3.0'
  @system_id = system_id
  @tan_mechanism = nil
  @id = 0
  @response = nil
end
open(connector, system_id: 0) { |dialog| ... } click to toggle source
# File lib/hbci/dialog.rb, line 12
def self.open(connector, system_id: 0)
  dialog = Dialog.new(connector, system_id: system_id)
  dialog.initiate
  yield dialog
  dialog.finish
end

Public Instance Methods

credentials() click to toggle source
# File lib/hbci/dialog.rb, line 29
def credentials
  @connector.credentials
end
finish() click to toggle source
# File lib/hbci/dialog.rb, line 53
def finish
  request_message = MessageFactory.build(@connector, self) do |hnvsd|
    hnvsd.add_segment(Segments::HKENDv1.new)
  end
  request_message.compile

  Response.new(@connector.post(request_message))

  @connector.reset_message_number
end
initiate() click to toggle source
# File lib/hbci/dialog.rb, line 37
def initiate
  request_message = MessageFactory.build(@connector, self) do |hnvsd|
    hnvsd.add_segment(Segments::HKIDNv2.new)
    hnvsd.add_segment(Segments::HKVVBv3.new)
  end
  request_message.compile

  @response = Response.new(@connector.post(request_message))

  raise DialogError.new('Initialization failed', @response.to_s) unless initialization_successful?

  @id            = @response.find('HNHBK').dialog_id
  @tan_mechanism = @response.find('HNVSD').find('HIRMS').allowed_tan_mechanism
  @initiated     = true
end
initiated?() click to toggle source
# File lib/hbci/dialog.rb, line 33
def initiated?
  @initiated
end

Private Instance Methods

initialization_successful?() click to toggle source
# File lib/hbci/dialog.rb, line 66
def initialization_successful?
  hirmg = response.find('HIRMG')
  return false if hirmg && hirmg.ret_val_1.code[0].to_i == 9

  hnvsd = response.find('HNVSD')
  hirmg = hnvsd.find('HIRMG')
  return false if hirmg && hirmg.ret_val_1.code[0].to_i == 9

  true
end