Class: RealEx::Response

Inherits:
Object
  • Object
show all
Includes:
Initializer
Defined in:
lib/real_ex/response.rb

Defined Under Namespace

Classes: CardIssuer

Class Method Summary collapse

Methods included from Initializer

included, #initialize

Class Method Details

.new_from_xml(xml) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/real_ex/response.rb', line 15

def self.new_from_xml(xml)
  parsed_xml = xml.kind_of?(String) ? Nokogiri.XML(xml) : xml
  r = new
  r.timestamp = (parsed_xml).at('response')['timestamp'] if (parsed_xml).at('response')
  r.result = (parsed_xml).at('result').inner_html if (parsed_xml).at('result')
  r.message = (parsed_xml).at('message').inner_html if (parsed_xml).at('message')
  r.orderid = (parsed_xml).at('orderid').inner_html if (parsed_xml).at('orderid')
  r.merchantid = (parsed_xml).at('merchantid').inner_html if (parsed_xml).at('merchantid')
  r. = (parsed_xml).at('account').inner_html if (parsed_xml).at('account')
  r.cvnresult = (parsed_xml).at('cvnresult').inner_html if (parsed_xml).at('cvnresult')
  r.avspostcoderesponse = (parsed_xml).at('avspostcoderesponse').inner_html if (parsed_xml).at('avspostcoderesponse')
  r.avsaddressresponse = (parsed_xml).at('avsaddressresponse').inner_html if (parsed_xml).at('avsaddressresponse')
  r.batchid = (parsed_xml).at('batchid').inner_html if (parsed_xml).at('batchid')
  r.pasref = (parsed_xml).at('pasref').inner_html if (parsed_xml).at('pasref')
  r.timetaken = (parsed_xml).at('timetaken').inner_html if (parsed_xml).at('timetaken')
  r.authcode = (parsed_xml).at('authcode').inner_html if (parsed_xml).at('authcode')
  r.authtimetaken = (parsed_xml).at('authtimetaken').inner_html if (parsed_xml).at('authtimetaken')
  if cardissuer = (parsed_xml).at('cardissuer')
    r.cardissuer = CardIssuer.new()
    r.cardissuer.bank = cardissuer.at('bank').inner_html
    r.cardissuer.country = cardissuer.at('country').inner_html
    r.cardissuer.countrycode = cardissuer.at('countrycode').inner_html
    r.cardissuer.region = cardissuer.at('region').inner_html
  end
  r
end