Class: Remit::Response

Inherits:
BaseResponse show all
Defined in:
lib/remit2/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.



16
17
18
19
20
21
22
23
24
25
# File 'lib/remit2/response.rb', line 16

def initialize(xml)
  super
  @errors = []
  
  if is?(:Response) && has?(:Errors)
    @errors = elements('Errors/Error').collect do |error|
      Error.new(error)
    end
  end
end

Instance Attribute Details

#errorsObject

Returns the value of attribute errors.



14
15
16
# File 'lib/remit2/response.rb', line 14

def errors
  @errors
end

Class Method Details

.inner_parameters(*fields) ⇒ Object

Easily exposes parameters that are buried in the InnerResponse



48
49
50
51
52
# File 'lib/remit2/response.rb', line 48

def self.inner_parameters(*fields)
  fields.each do |inner_field_name|
    define_method(inner_field_name) { inner.send(inner_field_name) }
  end
end

Instance Method Details

#node_name(name, namespace = nil) ⇒ Object



41
42
43
44
45
# File 'lib/remit2/response.rb', line 41

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

#request_idObject



31
32
33
34
35
36
37
38
39
# File 'lib/remit2/response.rb', line 31

def request_id
  # If successful it's in the ResponseMetadata, if failure, it's in the base
  # response. Very irritating.
  if successful?
    .request_id
  else
    elements('RequestId')[0].to_s
  end
end

#successful?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/remit2/response.rb', line 27

def successful?
  @errors.empty?
end