Sha256: d2f45dcd83cad4292ec8b0b78b4286324024c0e1b385cf71d90cec25bcbd8cdb
Contents?: true
Size: 777 Bytes
Versions: 1
Compression:
Stored size: 777 Bytes
Contents
# frozen_string_literal: true class Valvat class Lookup class Response def initialize(raw) @raw = raw end def [](key) to_hash[key] end def to_hash @to_hash ||= self.class.cleanup(@raw.to_hash) end def self.cleanup(hash) ( hash[:check_vat_approx_response] || hash[:check_vat_response] || {} ).each_with_object({}) do |(key, value), result| result[cleanup_key(key)] = cleanup_value(value) unless key == :@xmlns end end TRADER_PREFIX = /\Atrader_/.freeze def self.cleanup_key(key) key.to_s.sub(TRADER_PREFIX, '').to_sym end def self.cleanup_value(value) value == '---' ? nil : value end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
valvat-1.1.5 | lib/valvat/lookup/response.rb |