lanmao 0.8.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lanmao/api/api_helper.rb +27 -0
- data/lib/lanmao/api/trade/download_checkfile.rb +1 -1
- data/lib/lanmao/form/form_helper.rb +1 -1
- data/lib/lanmao/form/money/withdraw_form.rb +1 -1
- data/lib/lanmao/http/request.rb +11 -3
- data/lib/lanmao/sign/rsa.rb +13 -1
- data/lib/lanmao/version.rb +1 -1
- data/lib/lanmao.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8380f0c51719efea1617de41d1e12fe9e61240b7
|
4
|
+
data.tar.gz: 42f342ffcb5d985cc1d7e9728428a6f7bc160d88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23d955c27c0438bd1e140f4818e75113f71b3c008127644a9a1f32e248eb843fc042a7143ba06dbebf1129a7126a5bf3bf0271dca806f351a431f567561f4e3c
|
7
|
+
data.tar.gz: ae843e35a747a680f24eba63dfb354a53b2c2e6e6dae5f66e5c800fb4bc382f80b3599c417664b6959753569a4e986abff4f4a1a3d63a03961bb06db4617a96f
|
@@ -49,6 +49,33 @@ module Lanmao
|
|
49
49
|
res
|
50
50
|
end
|
51
51
|
|
52
|
+
def download_post(service, params, type)
|
53
|
+
request = Http::Request.new(params, @config, service, type)
|
54
|
+
response = request.post
|
55
|
+
res = {
|
56
|
+
result: 'P', # 默认
|
57
|
+
request_params: params,
|
58
|
+
response: response,
|
59
|
+
flow_id: nil,
|
60
|
+
code: nil,
|
61
|
+
error_code: nil,
|
62
|
+
error_msg: nil,
|
63
|
+
data: nil,
|
64
|
+
}
|
65
|
+
result = JSON.parse(response).with_indifferent_access rescue {}
|
66
|
+
if "1" == result[:code]
|
67
|
+
res[:result] = "F"
|
68
|
+
res[:code] = result[:code]
|
69
|
+
res[:error_code] = result[:errorCode]
|
70
|
+
res[:error_msg] = result[:errorMessage]
|
71
|
+
else
|
72
|
+
res[:result] = "S"
|
73
|
+
res[:data] = response
|
74
|
+
end
|
75
|
+
|
76
|
+
res
|
77
|
+
end
|
78
|
+
|
52
79
|
end # CommunicateResultHelper
|
53
80
|
end
|
54
81
|
end
|
@@ -17,7 +17,7 @@ module Lanmao
|
|
17
17
|
# * :amount [Number] 金额
|
18
18
|
# * :balance [Number] 操作后账户余额
|
19
19
|
#
|
20
|
-
def withdraw_form(flow_id, platform_user_no, expired, redirect_url, amount, withdraw_type='NORMAL', withdraw_form='IMMEDIATE', commission=
|
20
|
+
def withdraw_form(flow_id, platform_user_no, expired, redirect_url, amount, withdraw_type='NORMAL', withdraw_form='IMMEDIATE', commission=nil)
|
21
21
|
|
22
22
|
service = "WITHDRAW"
|
23
23
|
|
data/lib/lanmao/http/request.rb
CHANGED
@@ -6,17 +6,19 @@ module Lanmao
|
|
6
6
|
require 'active_support/all'
|
7
7
|
|
8
8
|
def initialize(params, config, service, type)
|
9
|
-
Time.zone = "Beijing"
|
10
9
|
@params = params
|
11
10
|
@params[:timestamp] = Time.now.in_time_zone("Beijing").strftime('%Y%m%d%H%M%S') # 时间戳
|
12
11
|
|
13
12
|
@config = config
|
14
13
|
@service = service
|
14
|
+
@type = type
|
15
15
|
|
16
16
|
@url = if :gateway == type # 网关模式
|
17
17
|
@config[:path] + "/gateway"
|
18
18
|
elsif :service == type # 直连模式
|
19
19
|
@config[:path] + "/service"
|
20
|
+
elsif :download == type # 对账文件下载模式
|
21
|
+
@config[:path] + "/download"
|
20
22
|
else
|
21
23
|
@config[:path]
|
22
24
|
end
|
@@ -60,16 +62,22 @@ module Lanmao
|
|
60
62
|
# 5. send http request
|
61
63
|
Lanmao.logger.info "#{identifier} 发送的报文为:\n#{post_body}\n"
|
62
64
|
http_response = RestClient.post(@url, post_body)
|
65
|
+
|
63
66
|
Lanmao.logger.info "#{identifier} 返回的报文为:\n#{http_response.body.force_encoding('utf-8')}\n"
|
64
67
|
|
68
|
+
# 直接返回,数据以字节流形式在 response body 中输出,无签名
|
69
|
+
return http_response.body if @type == :download
|
70
|
+
|
65
71
|
# 6. create response
|
66
72
|
@response = Lanmao::Http::Response.new(service: @service,
|
67
73
|
flow_id: flow_id,
|
68
74
|
http_response: http_response,
|
69
75
|
raw_body: http_response.body,
|
70
76
|
data: Utils.symbolize_keys(JSON.parse(http_response.body)),
|
71
|
-
data_valid: true
|
72
|
-
|
77
|
+
# data_valid: true
|
78
|
+
data_valid: Sign::RSA.verify(http_response.body, http_response.headers[:sign], @config)
|
79
|
+
)
|
80
|
+
|
73
81
|
end
|
74
82
|
|
75
83
|
def flow_id
|
data/lib/lanmao/sign/rsa.rb
CHANGED
@@ -3,12 +3,24 @@ module Lanmao
|
|
3
3
|
module Sign
|
4
4
|
module RSA
|
5
5
|
|
6
|
+
#签名
|
6
7
|
def self.sign(content, private_key)
|
7
|
-
sign = private_key.sign(
|
8
|
+
sign = private_key.sign("sha1", content.force_encoding("utf-8"))
|
8
9
|
signature = Base64.encode64(sign)
|
9
10
|
signature = signature.delete("\n").delete("\r")
|
10
11
|
end
|
11
12
|
|
13
|
+
## 验签
|
14
|
+
def self.verify(data, sign, config) ##如何从data里分离出原始数据和签名数据
|
15
|
+
if sign
|
16
|
+
sign = Base64.decode64(sign)
|
17
|
+
digester = OpenSSL::Digest::SHA1.new
|
18
|
+
config[:public_key].verify(digester, sign, data)
|
19
|
+
else
|
20
|
+
true
|
21
|
+
end
|
22
|
+
end # verify
|
23
|
+
|
12
24
|
end
|
13
25
|
end
|
14
26
|
end
|
data/lib/lanmao/version.rb
CHANGED
data/lib/lanmao.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lanmao
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tony
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-06-
|
11
|
+
date: 2018-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|