Sha256: c0b53618e004200e1d6032fa1a5021d70a1e4e51e417dbba87c3493c003d40af
Contents?: true
Size: 1.1 KB
Versions: 2
Compression:
Stored size: 1.1 KB
Contents
module RubyPaypalNvp module Fetcher class Balance < Base RESPONSE_PARAMS = %w[L_AMT L_CURRENCYCODE].freeze private def process_loaded_data(result) result = filter_current_currency(result) return if result[:values].blank? ::RubyPaypalNvp::Model::Balance.new(result) end def filter_current_currency(result) currency_code = result[:meta]['currency_code'] balance = result[:values].select do |_key, value| { key: value } if value.values.include?(currency_code) end result[:values] = balance.values.first result end def load_response response = load_api_response(request_options) raise response['L_LONGMESSAGE0'] if response['ACK'] == 'Failure' parse(response, increment: 0) result = result_with_meta(timestamp: Time.zone.parse(response['TIMESTAMP']).to_s) @resulting_hash = default_hash result end def request_options super.merge! returnallcurrencies: 1 end def api_method 'GetBalance' end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ruby_paypal_nvp-0.1.1 | lib/ruby_paypal_nvp/fetcher/balance.rb |
ruby_paypal_nvp-0.1.0 | lib/ruby_paypal_nvp/fetcher/balance.rb |