rock_fintech 0.10.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cc40be3b2af85f4843dfaf5fc932a78cd000395c
4
- data.tar.gz: '0597041ea4bbdaee1893c8868e1fa143a2f89ceb'
3
+ metadata.gz: 76a01e42411b132675f0dfe9cafbfa0de0934d01
4
+ data.tar.gz: 5138e927b6e555197441d4ec284157df8b2d6ef9
5
5
  SHA512:
6
- metadata.gz: 37c9d752479e3bfda840038121aa1a7e59393d9e06f25400ff52d55c74fbd75fa38438203546352859335224eef3e6427fb22b71f3923f31d5cf81c71b31b71e
7
- data.tar.gz: c44cabb59fe3ca70adc5242e34bbbd1688ca2a0a7e47bf4529126e048d6818e234a64af3fa1f56e0d96df9a929090b5f8bea886ce4d9f928cf17e1521990f5bb
6
+ metadata.gz: 1fc6699d7a735512b2ac7432feaea8f69c03fbfc72f501a9ae78c2204f484f9b85fc4a07dc7f23a04be40bf3b80da1d622a6fbdc893108495a4e4b7724c9b9d5
7
+ data.tar.gz: 55d3dd6bec461ec8d207db83df08e65e9da571c0acedcfdf15aab399b6402ba37fbe50cace366aebc73db4cdfafeb69e73dd3b5c3d33b022ebe4fbc38fb036e6
@@ -0,0 +1,40 @@
1
+ # coding: utf-8
2
+ module RockFintech
3
+ module Api
4
+ module Query
5
+ module CnapsQuery
6
+
7
+ # 联行号查询
8
+ #
9
+ # @param keywords [Array]
10
+ #
11
+ # @return [ Hash ] 结果集
12
+ # * :result [String] "S"/"F"/"P"
13
+ # * :request_params [Hash] 请求参数
14
+ # * :response [Object] 请求返回对象
15
+ # * :code [String] 结果代码
16
+ # * :msg [String] 结果信息
17
+ # * :data: 具体业务返回信息
18
+ # * :banks [Array] 查询结果银行列表
19
+ # * :union_bank_code [String] 人行分配联行号
20
+ # * :bank_name [String] 银行分支行全称
21
+ #
22
+ def cnaps_query(keywords, devise='000002', remark='')
23
+
24
+ service = 'cnaps_query'
25
+
26
+ params = {
27
+ keywords: keywords,
28
+ client: devise,
29
+ custom: remark,
30
+ }
31
+
32
+ res = operate_post(:query, service, params, Http::ErrorCode.cnaps_query, ['RD000000'])
33
+
34
+ res
35
+ end
36
+
37
+ end
38
+ end
39
+ end
40
+ end
@@ -2,25 +2,32 @@
2
2
  module RockFintech
3
3
  module Encrypt
4
4
  module RSA
5
+ MAX_ENCRYPT_LENGTH = 245
6
+ MAX_DECRYPT_LENGTH = 256
5
7
 
6
8
  def self.encrypt(content, public_key)
7
- content_str = ''
8
- content.scan(/.{1,100}/).each{ |str|
9
- content_str += public_key.public_encrypt(str)
10
- }
11
- Base64.strict_encode64(content_str)
9
+ content_str, encryt_str, offset, i = "", "", 0, 0
10
+
11
+ bytes_array = content.unpack("C*")
12
+ input_length = bytes_array.length
13
+ while input_length - offset > 0
14
+ encryt_bytes = bytes_array[offset, MAX_ENCRYPT_LENGTH]
15
+ encryt_str << public_key.public_encrypt(encryt_bytes.pack("C*"))
16
+ offset = (i += 1) * MAX_ENCRYPT_LENGTH
17
+ end
18
+ Base64.strict_encode64(encryt_str)
12
19
  end
13
20
 
14
21
  def self.decrypt(content, private_key)
15
- content_str = Base64.strict_decode64(content)
16
-
17
- result_str = ''
18
- count = content_str.length / 256
19
- count.times.each{ |i|
20
- str = content_str[256*i, 256]
21
- result_str += private_key.private_decrypt(str)
22
- }
22
+ result_str, decryt_bytes, offset, i = "", "", 0, 0
23
23
 
24
+ content_str = Base64.strict_decode64(content)
25
+ input_length = content_str.length
26
+ while input_length - offset > 0
27
+ decryt_bytes = content_str[offset, MAX_DECRYPT_LENGTH]
28
+ result_str << private_key.private_decrypt(decryt_bytes)
29
+ offset = (i += 1) * MAX_DECRYPT_LENGTH
30
+ end
24
31
  result_str
25
32
  end
26
33
 
@@ -31,6 +31,10 @@ module RockFintech
31
31
  def self.money_query
32
32
  @_money_query ||= %w[]
33
33
  end
34
+
35
+ def self.cnaps_query
36
+ @_cnaps_query ||= %w[]
37
+ end
34
38
  end # module ErrorCode
35
39
  end
36
40
  end
@@ -1,3 +1,3 @@
1
1
  module RockFintech
2
- VERSION = "0.10.0"
2
+ VERSION = "0.11.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rock_fintech
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - chenpengyu
@@ -189,6 +189,7 @@ files:
189
189
  - lib/rock_fintech/api/query/batch_query_payment_b.rb
190
190
  - lib/rock_fintech/api/query/batch_query_repayment_b.rb
191
191
  - lib/rock_fintech/api/query/buy_credit_query.rb
192
+ - lib/rock_fintech/api/query/cnaps_query.rb
192
193
  - lib/rock_fintech/api/query/money_query.rb
193
194
  - lib/rock_fintech/api/trade/.gitkeep
194
195
  - lib/rock_fintech/api/trade/auto_bid_apply.rb