Class: MPIClient::Verification::Response

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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_codeObject (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_messageObject (readonly)

Returns the value of attribute error_message.



4
5
6
# File 'lib/mpi_client/verification/response.rb', line 4

def error_message
  @error_message
end

#statusObject (readonly)

Returns the value of attribute status.



4
5
6
# File 'lib/mpi_client/verification/response.rb', line 4

def status
  @status
end

#urlObject (readonly)

Returns the value of attribute url.



4
5
6
# File 'lib/mpi_client/verification/response.rb', line 4

def url
  @url
end

#xmlObject (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

#parseObject



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

Returns:

  • (Boolean)


10
11
12
# File 'lib/mpi_client/verification/response.rb', line 10

def successful?
  !(error_message || error_code)
end