Sha256: 19cd4892c6bbae3a522f2f7bdc800405088509d85def1e6c652b6ac576c3ce98

Contents?: true

Size: 908 Bytes

Versions: 3

Compression:

Stored size: 908 Bytes

Contents

module Einvoice
  module Neweb
    class Result < Einvoice::Result
      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

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

      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
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
einvoice-1.1.1 lib/einvoice/neweb/result.rb
einvoice-1.1.0 lib/einvoice/neweb/result.rb
einvoice-1.0.0 lib/einvoice/neweb/result.rb