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.



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/remit/common.rb', line 52

def initialize(xml)
  super

  # TODO: How to differentiate between Error and Service Error properly? - pboling
  # TODO: Is this ServiceError still relevant? - pboling
  if is?(:Response) and has?(:Errors)
    @errors = elements('errors/error').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.



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

def errors
  @errors
end

#statusObject

Returns the value of attribute status.



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

def status
  @status
end

Instance Method Details

#node_name(name, namespace = nil) ⇒ Object



73
74
75
76
77
# File 'lib/remit/common.rb', line 73

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

#request_idObject



48
49
50
# File 'lib/remit/common.rb', line 48

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

#successful?Boolean

Returns:

  • (Boolean)


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

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