lib/veritrans/cli.rb in veritrans-2.1.3 vs lib/veritrans/cli.rb in veritrans-2.2.0

- old
+ new

@@ -1,14 +1,14 @@ require 'json' require 'securerandom' require 'logger' class Veritrans - module CLI + module CLI #:nodoc: # can't find order - class OrderNotFound < Exception; end - class AuthenticationError < Exception; end + class OrderNotFound < Exception; end # :nodoc: + class AuthenticationError < Exception; end # :nodoc: extend self def test_webhook(args) url = args.shift @@ -117,12 +117,12 @@ } if CONFIG[:order] load_local_config! order_info = get_order_info(CONFIG[:order]) - order_data = order_info.data.except(:status_message, :signature_key) - data = data.except(:fraud_status, :masked_card).merge(order_data) + order_data = hash_except(order_info.data, :status_message, :signature_key) + data = hash_except(data, :fraud_status, :masked_card).merge(order_data) end JSON.pretty_generate(data) end @@ -148,8 +148,14 @@ def pink(str) colorize(str, 35) end def cyan(str); colorize(str, 36) end + + def hash_except(hash, *except_keys) + copy = hash.dup + except_keys.each { |key| copy.delete(key) } + copy + end end end \ No newline at end of file