Class: TencentTrustsql::Client
- Inherits:
-
Object
- Object
- TencentTrustsql::Client
- Includes:
- Api::AssetIssue, Api::Tpki
- Defined in:
- lib/tencent_trustsql/client.rb
Constant Summary
Constants included from Api::Tpki
Constants included from Api::AssetIssue
Instance Attribute Summary collapse
-
#mch_id ⇒ Object
Returns the value of attribute mch_id.
-
#mch_private_key ⇒ Object
Returns the value of attribute mch_private_key.
-
#mch_public_key_out ⇒ Object
Returns the value of attribute mch_public_key_out.
Instance Method Summary collapse
- #http_post(url, params) ⇒ Object
-
#initialize(mch_private_key = nil) ⇒ Client
constructor
A new instance of Client.
- #sign_list_sign(user_private_key, sign_list) ⇒ Object
Methods included from Api::Tpki
#account_apply, #account_get_list, #tpki_base_params, #user_apply, #user_get
Methods included from Api::AssetIssue
#asset_apply, #asset_apply_base, #asset_base_params, #asset_commit_base, #asset_transfer_apply, #asset_transfer_submit, #commit, #trans_batch_query
Constructor Details
#initialize(mch_private_key = nil) ⇒ Client
Returns a new instance of Client.
9 10 11 12 13 |
# File 'lib/tencent_trustsql/client.rb', line 9 def initialize mch_private_key = nil @mch_private_key = mch_private_key || TencentTrustsql.mch_private_key_local @mch_id = TencentTrustsql.mch_id @mch_public_key_out = TencentTrustsql.encoded_public_key @mch_private_key end |
Instance Attribute Details
#mch_id ⇒ Object
Returns the value of attribute mch_id.
7 8 9 |
# File 'lib/tencent_trustsql/client.rb', line 7 def mch_id @mch_id end |
#mch_private_key ⇒ Object
Returns the value of attribute mch_private_key.
7 8 9 |
# File 'lib/tencent_trustsql/client.rb', line 7 def mch_private_key @mch_private_key end |
#mch_public_key_out ⇒ Object
Returns the value of attribute mch_public_key_out.
7 8 9 |
# File 'lib/tencent_trustsql/client.rb', line 7 def mch_public_key_out @mch_public_key_out end |
Instance Method Details
#http_post(url, params) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/tencent_trustsql/client.rb', line 37 def http_post url, params # sign query = TencentTrustsql.params_to_string(params) mch_sign = TencentTrustsql.output_formatter.out_sign(TencentTrustsql.sign(mch_private_key, query)) p 'http_post mch_sign used query' + query params.merge!(mch_sign: mch_sign) p params p url response =HTTP.post(url, json: params) puts response.body JSON.parse(response.body) rescue nil end |
#sign_list_sign(user_private_key, sign_list) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/tencent_trustsql/client.rb', line 16 def sign_list_sign user_private_key, sign_list signed_list = [] p "count ------ #{sign_list.count}" sign_list.each do |obj| signed_obj = {} p "obj --------- #{obj}" p obj.keys [:account, :sign_str, :id].each do |key| signed_obj["#{key.to_s}"] = obj[key] || obj[key.to_s] end p signed_obj['sign_str'] sign = TencentTrustsql.trans_sign user_private_key, signed_obj['sign_str'] p a = TencentTrustsql.output_formatter.out_sign(sign) signed_obj['sign'] = a#TencentTrustsql.output_formatter.out_sign sign signed_list.push signed_obj end p 'sign_list signed' p signed_list signed_list end |