Class: AN::Response

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

Constant Summary collapse

OK =
"Ok"

Instance Method Summary collapse

Constructor Details

#initialize(xml) ⇒ Response

Returns a new instance of Response.



69
70
71
# File 'lib/an.rb', line 69

def initialize(xml)
  @data = XmlSimple.xml_in(xml, forcearray: false)
end

Instance Method Details

#[](key) ⇒ Object



73
74
75
# File 'lib/an.rb', line 73

def [](key)
  @data[key]
end

#authorizationObject



93
94
95
96
97
# File 'lib/an.rb', line 93

def authorization
  response = @data["validationDirectResponse"] || @data["directResponse"]

  AuthorizationResponse.new(response) if response
end

#payment_profile_idObject



89
90
91
# File 'lib/an.rb', line 89

def payment_profile_id
  @data["customerPaymentProfileId"]
end

#profile_idObject



85
86
87
# File 'lib/an.rb', line 85

def profile_id
  @data["customerProfileId"]
end

#success?Boolean

Returns:

  • (Boolean)


77
78
79
# File 'lib/an.rb', line 77

def success?
  @data["messages"]["resultCode"] == OK
end

#to_hashObject



81
82
83
# File 'lib/an.rb', line 81

def to_hash
  @data
end