Class: Remit::Response

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml) ⇒ Response

Returns a new instance of Response.



32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/remit/common.rb', line 32

def initialize(xml)
  super

  if is?(:Response) && 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 unless successful?
  end
end

Instance Attribute Details

#errorsObject

Returns the value of attribute errors.



30
31
32
# File 'lib/remit/common.rb', line 30

def errors
  @errors
end

#statusObject

Returns the value of attribute status.



29
30
31
# File 'lib/remit/common.rb', line 29

def status
  @status
end

Instance Method Details

#node_name(name, namespace = nil) ⇒ Object



51
52
53
54
55
# File 'lib/remit/common.rb', line 51

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

#successful?Boolean

Returns:

  • (Boolean)


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

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