Sha256: 89149d1d2c125afd6c5e57e878812a66ff97f8512f9794d028e8d89df97013e2
Contents?: true
Size: 901 Bytes
Versions: 1
Compression:
Stored size: 901 Bytes
Contents
module Einvoice class Response attr_reader :response def initialize(response = nil) @response = response end def errors raise NotImplementedError, 'You must initialize one of Einvoice::Response subclasses then use it.' end def success? raise NotImplementedError, 'You must initialize one of Einvoice::Response subclasses then use it.' end end class NewebResponse < Response def errors if response.is_a? ActiveModel::Errors response.full_messages.join('; ') else response && response.fetch("Result", {}) do |data| "#{data["statcode"]}: #{data["statdesc"]}" end end end def success? if response.is_a? ActiveModel::Errors false elsif response && response.fetch("Result", {})["statdesc"] == "0000" true else false end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
einvoice-0.2.0 | lib/einvoice/response.rb |