Class: Einvoice::Neweb::Result

Inherits:
Result
  • Object
show all
Defined in:
lib/einvoice/neweb/result.rb

Instance Attribute Summary

Attributes inherited from Result

#response

Instance Method Summary collapse

Methods inherited from Result

#initialize

Constructor Details

This class inherits a constructor from Einvoice::Result

Instance Method Details

#dataObject



22
23
24
25
26
27
28
29
# File 'lib/einvoice/neweb/result.rb', line 22

def data
  if response.is_a? ActiveModel::Errors
    nil
  else
    data = response && (response["Result"]["Invoice"] || response["Result"])
    data["InvoiceMapRoot"] if data["statcode"] == "0000"
  end
end

#errorsObject



4
5
6
7
8
9
10
11
# File 'lib/einvoice/neweb/result.rb', line 4

def errors
  if response.is_a? ActiveModel::Errors
    response.full_messages.join('; ')
  else
    data = response && (response["Result"]["Invoice"] || response["Result"])
    data["statcode"] == "0000" ? nil : "#{data["statcode"]}: #{data["statdesc"]}" if data
  end
end

#success?Boolean

Returns:

  • (Boolean)


13
14
15
16
17
18
19
20
# File 'lib/einvoice/neweb/result.rb', line 13

def success?
  if response.is_a? ActiveModel::Errors
    false
  else
    data = response && (response["Result"]["Invoice"] || response["Result"])
    data["statcode"] == "0000" if data
  end
end