Class: WirecardMapper::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/wirecardmapper/response.rb

Instance Method Summary collapse

Constructor Details

#initialize(xml) ⇒ Response

Returns a new instance of Response.



4
5
6
7
8
9
# File 'lib/wirecardmapper/response.rb', line 4

def initialize(xml)
  @doc = Nokogiri::XML(xml)
  if @doc.at_css('issuer-response').nil?
    raise WirecardMapper::Exception, "No valid wirecard issuer-response"
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



37
38
39
40
41
42
43
44
45
# File 'lib/wirecardmapper/response.rb', line 37

def method_missing(method, *args)
  node_name = method.to_s.gsub(/_/, '-')
  node = @doc.at_css(node_name)
  unless node.nil?
    parse(@doc.at_css(node_name).content)
  else
    super
  end
end

Instance Method Details

#account_numberObject



31
32
33
# File 'lib/wirecardmapper/response.rb', line 31

def 
  @doc.at_css('account-number').content
end

#bank_codeObject



27
28
29
# File 'lib/wirecardmapper/response.rb', line 27

def bank_code
  @doc.at_css('bank-code').content
end

#card_numberObject



23
24
25
# File 'lib/wirecardmapper/response.rb', line 23

def card_number
  @doc.at_css('card-number').content
end

#card_security_codeObject



19
20
21
# File 'lib/wirecardmapper/response.rb', line 19

def card_security_code
  @doc.at_css('card-security-code').content
end

#ok?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/wirecardmapper/response.rb', line 15

def ok?
  return_code.to_i.eql?(0) || return_code.to_i.eql?(21)
end

#to_sObject



11
12
13
# File 'lib/wirecardmapper/response.rb', line 11

def to_s
  @doc.to_s
end