Class: ESortCode::Response::Base

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

Instance Method Summary collapse

Constructor Details

#initialize(xml_data) ⇒ Base

Returns a new instance of Base.



6
7
8
# File 'lib/esortcode/response/base.rb', line 6

def initialize(xml_data)
  @xml = REXML::Document.new(xml_data)
end

Instance Method Details

#errorObject



24
25
26
27
28
# File 'lib/esortcode/response/base.rb', line 24

def error
  if has_error?
    @error ||= (message_from(@xml.get_text('*/ErrorMessage')))
  end
end

#error!Object



30
31
32
# File 'lib/esortcode/response/base.rb', line 30

def error!
  raise ESortCode::Exception::GeneralError, error if has_error?
end

#has_error?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/esortcode/response/base.rb', line 20

def has_error?
  @has_error ||= (@xml.get_text('*/IsError') == 'true')
end

#invalid_messageObject



14
15
16
17
18
# File 'lib/esortcode/response/base.rb', line 14

def invalid_message
  unless valid?
    @invalid_message ||= (message_from(@xml.get_text('*/ValidationMessage')))
  end
end

#valid?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/esortcode/response/base.rb', line 10

def valid?
  @valid ||= (@xml.get_text('*/ValidationMessage') == 'VALID')
end