Module: Reapal::Api::User::BalanceQuery

Defined in:
lib/reapal/api/user/balance_query.rb

Instance Method Summary collapse

Instance Method Details

#balance_query(contracts) ⇒ Hash

1.6 查询余额(API)



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/reapal/api/user/balance_query.rb', line 23

def balance_query(contracts)
  service = 'reapal.trust.balanceQuery'
  post_path = '/reagw/agreement/agreeApi.htm'

  params = {
    contracts: contracts,
    queryTime: Time.now.strftime('%Y-%m-%d %H:%M:%S'),
  }

  res = operate_post(:query, service, params, post_path, ['0113'], ['0000'])

  if 'S' == res[:result] || ('P' == res[:result] && res[:data][:resultCode].nil?)
    res[:result] = 'S'

    res[:data] = {
      totalAmount: res[:data][:totalAmount].to_d,
      usableAmount: res[:data][:usableAmount].to_d,
      tenderAmount: res[:data][:tenderAmount].to_d,
    }
  end

  res
end