Class: MPIClient::Verification::Response
- Inherits:
-
Object
- Object
- MPIClient::Verification::Response
- Defined in:
- lib/mpi_client/verification/response.rb
Instance Attribute Summary collapse
-
#error_code ⇒ Object
readonly
Returns the value of attribute error_code.
-
#error_message ⇒ Object
readonly
Returns the value of attribute error_message.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
-
#xml ⇒ Object
readonly
Returns the value of attribute xml.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(xml) ⇒ Response
constructor
A new instance of Response.
- #parse ⇒ Object
- #successful? ⇒ Boolean
Constructor Details
#initialize(xml) ⇒ Response
Returns a new instance of Response.
6 7 8 |
# File 'lib/mpi_client/verification/response.rb', line 6 def initialize(xml) @xml = xml end |
Instance Attribute Details
#error_code ⇒ Object (readonly)
Returns the value of attribute error_code.
4 5 6 |
# File 'lib/mpi_client/verification/response.rb', line 4 def error_code @error_code end |
#error_message ⇒ Object (readonly)
Returns the value of attribute error_message.
4 5 6 |
# File 'lib/mpi_client/verification/response.rb', line 4 def @error_message end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
4 5 6 |
# File 'lib/mpi_client/verification/response.rb', line 4 def status @status end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
4 5 6 |
# File 'lib/mpi_client/verification/response.rb', line 4 def url @url end |
#xml ⇒ Object (readonly)
Returns the value of attribute xml.
4 5 6 |
# File 'lib/mpi_client/verification/response.rb', line 4 def xml @xml end |
Class Method Details
.parse(xml) ⇒ Object
26 27 28 29 30 |
# File 'lib/mpi_client/verification/response.rb', line 26 def self.parse(xml) response = self.new(xml) response.parse response end |
Instance Method Details
#parse ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/mpi_client/verification/response.rb', line 14 def parse doc = Nokogiri::XML(xml) unless (doc.xpath("//Transaction")).empty? @status = doc.xpath("//Transaction").attr('status').value @url = doc.xpath("//Transaction/URL").text else get_error(doc) end end |
#successful? ⇒ Boolean
10 11 12 |
# File 'lib/mpi_client/verification/response.rb', line 10 def successful? !( || error_code) end |