Class: Remit::Response

Inherits:
BaseResponse show all
Defined in:
lib/remit/common.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Relax::Response

alias_for_parameter, parameter

Constructor Details

#initialize(xml) ⇒ Response

Returns a new instance of Response.



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/remit/common.rb', line 49

def initialize(xml)
  super

  #TODO: How to differentiate between Error and Service Error
  if is?(:Response) and has?(:Errors)
    @errors = elements(:Errors).collect do |error|
      Error.new(error)
    end
  else
    @status = text_value(element(:Status))
    @errors = elements('errors/errors').collect do |error|
      ServiceError.new(error)
    end if not successful?
  end
end

Instance Attribute Details

#errorsObject

Returns the value of attribute errors.



43
44
45
# File 'lib/remit/common.rb', line 43

def errors
  @errors
end

#statusObject

Returns the value of attribute status.



42
43
44
# File 'lib/remit/common.rb', line 42

def status
  @status
end

Instance Method Details

#node_name(name, namespace = nil) ⇒ Object



69
70
71
72
73
# File 'lib/remit/common.rb', line 69

def node_name(name, namespace=nil)
  super(name.to_s.split('/').collect{ |tag|
    tag.gsub(/(^|_)(.)/) { $2.upcase }
  }.join('/'), namespace)
end

#request_idObject



45
46
47
# File 'lib/remit/common.rb', line 45

def request_id
  self..respond_to?(:request_id) ? self..request_id : nil
end

#successful?Boolean

Returns:

  • (Boolean)


65
66
67
# File 'lib/remit/common.rb', line 65

def successful?
  @status == ResponseStatus::SUCCESS
end