reapal 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/lib/reapal.rb +2 -0
- data/lib/reapal/api/asset/tender_all_cancel.rb +64 -0
- data/lib/reapal/api/asset/tender_apply.rb +81 -0
- data/lib/reapal/api/asset/tender_auth_cancel.rb +66 -0
- data/lib/reapal/api/asset/tender_auth_query.rb +64 -0
- data/lib/reapal/api/asset/tender_finish.rb +78 -0
- data/lib/reapal/api/asset/tender_repayment_complete.rb +75 -0
- data/lib/reapal/api/asset/tender_repayment_project.rb +70 -0
- data/lib/reapal/api/error_codes.rb +46 -0
- data/lib/reapal/api/money/.keep +0 -0
- data/lib/reapal/api/order/.keep +0 -0
- data/lib/reapal/api/user/balance_query.rb +61 -0
- data/lib/reapal/api/user/bank_card_add_sms.rb +71 -0
- data/lib/reapal/api/user/bank_card_add_sms_again.rb +62 -0
- data/lib/reapal/api/user/bank_card_add_sms_confirm.rb +61 -0
- data/lib/reapal/api/user/bind_card_query.rb +67 -0
- data/lib/reapal/api/user/contract_query.rb +18 -0
- data/lib/reapal/api/user/mobile_query.rb +56 -0
- data/lib/reapal/api/{trust → user}/onekey_batch_contract.rb +8 -26
- data/lib/reapal/api/user/onekey_contract.rb +61 -0
- data/lib/reapal/api/user/undo_bind_bank_card.rb +60 -0
- data/lib/reapal/client.rb +6 -0
- data/lib/reapal/form/business_auth_form.rb +61 -0
- data/lib/reapal/form/find_trade_password_form.rb +48 -0
- data/lib/reapal/form/mobile_modify_form.rb +50 -0
- data/lib/reapal/form/signle_tender_transfer_form.rb +72 -0
- data/lib/reapal/form/tender_invest_form.rb +62 -0
- data/lib/reapal/form/tender_refund_form.rb +84 -0
- data/lib/reapal/form/withdraw_apply_form.rb +54 -0
- data/lib/reapal/http/communicate.rb +45 -20
- data/lib/reapal/http/response.rb +21 -0
- data/lib/reapal/utils.rb +16 -0
- data/lib/reapal/version.rb +1 -1
- metadata +29 -9
- data/lib/reapal/api/trust/balance_query.rb +0 -58
- data/lib/reapal/api/trust/contract_query.rb +0 -35
- data/lib/reapal/api/trust/find_trade_password.rb +0 -41
- data/lib/reapal/api/trust/mobile_modify.rb +0 -42
- data/lib/reapal/api/trust/onekey_contract.rb +0 -77
- data/lib/reapal/api/trust/withdraw_apply.rb +0 -44
@@ -0,0 +1,18 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module Reapal
|
4
|
+
module Api
|
5
|
+
module User
|
6
|
+
module ContractQuery
|
7
|
+
|
8
|
+
# 1.5 签约查询,支持个人和企业(API)
|
9
|
+
#
|
10
|
+
def contract_query(ori_flow_id)
|
11
|
+
# TODO(tony): 目前我们只用个人签约,个人签约都是同步返回,所以先不做实现
|
12
|
+
raise "Not Implement"
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module Reapal
|
4
|
+
module Api
|
5
|
+
module User
|
6
|
+
module MobileQuery
|
7
|
+
|
8
|
+
# 1.8 手机号查询
|
9
|
+
#
|
10
|
+
# @param contracts [ String ] 用户协议号
|
11
|
+
#
|
12
|
+
# @return [ Hash ] 结果集
|
13
|
+
# * :result [String] 业务结果:'S/F/P'
|
14
|
+
# * :request_params [Hash] 请求参数
|
15
|
+
# * :response [Object] 请求返回对象
|
16
|
+
# * :error_code [String] 错误代号
|
17
|
+
# * :error_msg [String] 错误信息
|
18
|
+
# * :data: 具体业务返回信息
|
19
|
+
# * :contracts [String] 用户协议号
|
20
|
+
# * :mobile [String] 用户手机号
|
21
|
+
#
|
22
|
+
|
23
|
+
|
24
|
+
def mobile_query(contracts)
|
25
|
+
service = 'reapal.trust.mobileQuery'
|
26
|
+
post_path = '/reagw/user/restApi.htm'
|
27
|
+
|
28
|
+
params = {
|
29
|
+
contracts: contracts,
|
30
|
+
queryTime: Time.now.strftime('%Y-%m-%d %H:%M:%S'),
|
31
|
+
}
|
32
|
+
|
33
|
+
response = Http.post(service, params, @config, post_path)
|
34
|
+
|
35
|
+
res = Reapal::Utils.api_result(params, response)
|
36
|
+
|
37
|
+
if Api::ErrorCode.mobile.include?(response.data[:errorcode])
|
38
|
+
res[:result] = 'F'
|
39
|
+
return res
|
40
|
+
end
|
41
|
+
|
42
|
+
# 查询类 api,http 没成功都返回 pending
|
43
|
+
return res unless response.http_success?
|
44
|
+
|
45
|
+
# 其余 api 错误不知道
|
46
|
+
return res unless response.data[:errorCode].nil?
|
47
|
+
|
48
|
+
res[:result] = "S"
|
49
|
+
|
50
|
+
res
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module Reapal
|
4
4
|
module Api
|
5
|
-
module
|
5
|
+
module User
|
6
6
|
module OnekeyBatchContract
|
7
7
|
|
8
8
|
# 1.1 个人一键签约(API)新版本,迁移老数据
|
@@ -44,37 +44,19 @@ module Reapal
|
|
44
44
|
|
45
45
|
response = Http.post(service, params, @config, post_path)
|
46
46
|
|
47
|
-
|
48
|
-
data: nil,
|
49
|
-
result: "F",
|
50
|
-
error_msg: "未知错误",
|
51
|
-
}
|
47
|
+
res = Reapal::Utils.api_result(params, response)
|
52
48
|
|
53
|
-
|
54
|
-
unless response.data_valid
|
55
|
-
error_result[:error_msg] = "返回数据不合法"
|
56
|
-
return error_result
|
57
|
-
end
|
58
|
-
|
59
|
-
# 如果网络出错,包括超时或者非200类数据
|
60
|
-
unless response.http_response.kind_of?(Net::HTTPSuccess)
|
61
|
-
error_result[:error_msg] = "网络出错"
|
62
|
-
return error_result
|
63
|
-
end
|
49
|
+
return res if response.http_pending?
|
64
50
|
|
65
51
|
# 个人签约只有返回码是 '0000', '0007' 才成功
|
66
52
|
if ['0000', '0007'].include?(response.data[:resultCode])
|
67
|
-
|
68
|
-
|
69
|
-
result: "S",
|
70
|
-
error_msg: nil,
|
71
|
-
}
|
53
|
+
res[:result] = 'S'
|
54
|
+
res[:data] = response.data
|
72
55
|
else
|
73
|
-
|
74
|
-
error_result[:error_code] = response.data[:errorCode]
|
75
|
-
error_result[:error_msg] = response.data[:errorMsg]
|
76
|
-
return error_result
|
56
|
+
res[:result] = 'F'
|
77
57
|
end
|
58
|
+
|
59
|
+
res
|
78
60
|
end
|
79
61
|
|
80
62
|
end # module Agree
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module Reapal
|
4
|
+
module Api
|
5
|
+
module User
|
6
|
+
module OnekeyContract
|
7
|
+
|
8
|
+
# 1.2 个人一键签约(API)
|
9
|
+
#
|
10
|
+
# @param flow_id [ String ] 订单号
|
11
|
+
# @param true_name [ String ] 真实姓名
|
12
|
+
# @param identity_id [ String ] 身份证号
|
13
|
+
# @param phone [ String ] 手机号
|
14
|
+
# @param bus_way [ String ] 00:PC端;01:手机端;02:Pad端;03:其它
|
15
|
+
#
|
16
|
+
# @return [ Hash ] 结果集
|
17
|
+
# * :result [String] 业务结果:'S/F/P'
|
18
|
+
# * :request_params [Hash] 请求参数
|
19
|
+
# * :response [Object] 请求返回对象
|
20
|
+
# * :error_code [String] 错误代号
|
21
|
+
# * :error_msg [String] 错误信息
|
22
|
+
# * :data: 具体业务返回信息
|
23
|
+
# * :contracts [String] 用户签约协议号
|
24
|
+
# * :userName [String] 姓名
|
25
|
+
# * :userIdentity [String] 身份证
|
26
|
+
# * :userMobile [String] 手机号
|
27
|
+
#
|
28
|
+
def onekey_contract(flow_id, true_name, identity_id, phone, bus_way='01')
|
29
|
+
service = 'reapal.trust.onekeyContract'
|
30
|
+
post_path = '/reagw/agreement/agree.htm'
|
31
|
+
|
32
|
+
params = {
|
33
|
+
orderNo: flow_id,
|
34
|
+
userName: true_name,
|
35
|
+
userIdentity: identity_id,
|
36
|
+
userMobile: phone,
|
37
|
+
busway: bus_way,
|
38
|
+
remark: '',
|
39
|
+
applyTime: Time.now.strftime('%Y-%m-%d %H:%M:%S'),
|
40
|
+
}
|
41
|
+
|
42
|
+
response = Http.post(service, params, @config, post_path)
|
43
|
+
|
44
|
+
res = Reapal::Utils.api_result(params, response)
|
45
|
+
|
46
|
+
return res if response.http_pending? # 比如超时等操作
|
47
|
+
|
48
|
+
# 个人签约只有返回码是 '0000', '0007' 才成功
|
49
|
+
if ['0000', '0007'].include?(response.data[:resultCode])
|
50
|
+
res[:result] = 'S'
|
51
|
+
else
|
52
|
+
res[:result] = 'F'
|
53
|
+
end
|
54
|
+
|
55
|
+
res
|
56
|
+
end
|
57
|
+
|
58
|
+
end # module
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module Reapal
|
4
|
+
module Api
|
5
|
+
module User
|
6
|
+
module UndoBindBankCard
|
7
|
+
|
8
|
+
# 1.13 撤销绑卡 (API)
|
9
|
+
#
|
10
|
+
# @param order_no [ String ] 订单号
|
11
|
+
# @param contract [ String ] 用户协议号
|
12
|
+
# @param bank_account_no [ String ] 银行卡信息(卡号后四位)
|
13
|
+
#
|
14
|
+
# @return [ Hash ] 结果集
|
15
|
+
# * :result [String] 业务结果:'S/F/P'
|
16
|
+
# * :request_params [Hash] 请求参数
|
17
|
+
# * :response [Object] 请求返回对象
|
18
|
+
# * :error_code [String] 错误代号
|
19
|
+
# * :error_msg [String] 错误信息
|
20
|
+
# * :data: 具体业务返回信息
|
21
|
+
# * :orderNo [String] 订单号
|
22
|
+
# * :resultCode [String] 结果代码 0000:撤销绑卡成功
|
23
|
+
#
|
24
|
+
def undo_bind_bank_card(order_no, contracts, bank_account_no)
|
25
|
+
service = 'reapal.trust.undoBindBankCard'
|
26
|
+
post_path = '/reagw/bankcard/undoBindBankApi.htm'
|
27
|
+
|
28
|
+
params = {
|
29
|
+
orderNo: order_no,
|
30
|
+
contracts: contracts,
|
31
|
+
bankAccountNo: bank_account_no,
|
32
|
+
applyTime: Time.now.strftime('%Y-%m-%d %H:%M:%S'),
|
33
|
+
}
|
34
|
+
|
35
|
+
response = Http.post(service, params, @config, post_path)
|
36
|
+
|
37
|
+
res = Reapal::Utils.api_result(params, response)
|
38
|
+
|
39
|
+
return res if response.http_pending? # 比如超时等操作
|
40
|
+
|
41
|
+
# 1,明确失败的
|
42
|
+
if Api::ErrorCode.bind_card.include?(response.data[:errorCode])
|
43
|
+
res[:result] = 'F'
|
44
|
+
return res
|
45
|
+
end
|
46
|
+
|
47
|
+
# 2. 明确正确的
|
48
|
+
if ['0000'].include?(response.data[:resultCode])
|
49
|
+
res[:result] = 'S'
|
50
|
+
return res
|
51
|
+
end
|
52
|
+
|
53
|
+
# 3. 其他错误 pending
|
54
|
+
res
|
55
|
+
end
|
56
|
+
|
57
|
+
end # module
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
data/lib/reapal/client.rb
CHANGED
@@ -19,6 +19,12 @@ module Reapal
|
|
19
19
|
|
20
20
|
# 自动 include api 下的模块
|
21
21
|
recursive_include_api('Reapal::Api')
|
22
|
+
# 自动 include form 下的模块
|
23
|
+
recursive_include_api('Reapal::Form')
|
24
|
+
end
|
25
|
+
|
26
|
+
def decode_data(encryptkey, data)
|
27
|
+
::Reapal::Http::decode_data(encryptkey, data, @config)
|
22
28
|
end
|
23
29
|
|
24
30
|
private
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module Reapal
|
4
|
+
module Form
|
5
|
+
module BusinessAuth
|
6
|
+
|
7
|
+
# 3.20 标的授权 (Form)
|
8
|
+
#
|
9
|
+
# @param flow_id [String] 业务订单号
|
10
|
+
# @param contracts [String] 用户协议号
|
11
|
+
# @param services [String] 授权服务 02一键投标 ,03 为一键还款 04 一键债转
|
12
|
+
# @param busway [String] 00:PC端;01:手机端;02:Pad端;03:其它
|
13
|
+
# @param auth_limit [String] 授权期限日期 YYYYMMDD
|
14
|
+
# @param tender_no [String] 标的号,授权为一键还款时必填
|
15
|
+
# @param return_url [String] 回调 url
|
16
|
+
# @param notify_url [String] 通知 url
|
17
|
+
#
|
18
|
+
|
19
|
+
# @return [ Hash ] 结果集
|
20
|
+
# * form_method
|
21
|
+
# * url
|
22
|
+
# * method
|
23
|
+
# * form_data
|
24
|
+
# * :merchant_id
|
25
|
+
# * :encryptkey
|
26
|
+
# * :data
|
27
|
+
#
|
28
|
+
def business_auth_form(flow_id, contracts, services, busway='01', auth_limit,
|
29
|
+
tender_no, return_url, notify_url)
|
30
|
+
|
31
|
+
service = 'reapal.trust.businessAuth'
|
32
|
+
post_path = '/reagw/tender/rest.htm'
|
33
|
+
|
34
|
+
params = {
|
35
|
+
orderNo: flow_id,
|
36
|
+
contracts: contracts,
|
37
|
+
services: services,
|
38
|
+
busway: busway,
|
39
|
+
authLimit: auth_limit,
|
40
|
+
tenderNo: tender_no,
|
41
|
+
returnUrl: return_url,
|
42
|
+
notifyUrl: notify_url,
|
43
|
+
remark: '',
|
44
|
+
applyTime: Time.now.strftime('%Y-%m-%d %H:%M:%S')
|
45
|
+
}
|
46
|
+
|
47
|
+
request = Http.get_body(service, params, @config)
|
48
|
+
|
49
|
+
{
|
50
|
+
form_method: {
|
51
|
+
:url => config[:server_url] + post_path,
|
52
|
+
:method => :post,
|
53
|
+
},
|
54
|
+
form_data: request
|
55
|
+
}
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
end #BusinessAuth
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module Reapal
|
4
|
+
module Form
|
5
|
+
module FindTradePassowrdForm
|
6
|
+
|
7
|
+
# 1.9 设置/修改交易密码
|
8
|
+
#
|
9
|
+
# @param contract [String] 用户协议
|
10
|
+
# @param return_url [String] 回调 url
|
11
|
+
# @param notify_url [String] 通知 url
|
12
|
+
# @param buyway [String] 设备通道,默认手机端。00:PC端;01:手机端;02:Pad端;03:其它
|
13
|
+
#
|
14
|
+
# @return [ Hash ] 结果集
|
15
|
+
# * :form_method
|
16
|
+
# * :method
|
17
|
+
# * :url
|
18
|
+
# * :form_data
|
19
|
+
# * :merchant_id
|
20
|
+
# * :encryptkey
|
21
|
+
# * :data
|
22
|
+
#
|
23
|
+
def find_trade_password_form(contract, return_url, notify_url, busway='01')
|
24
|
+
service = 'reapal.trust.findTradePassword'
|
25
|
+
post_path = '/reagw/findTradePassword/findTradePassword.htm'
|
26
|
+
|
27
|
+
params = {
|
28
|
+
contracts: contract,
|
29
|
+
busway: busway,
|
30
|
+
returnUrl: return_url,
|
31
|
+
notifyUrl: notify_url,
|
32
|
+
applyTime: Time.now.strftime('%Y-%m-%d %H:%M:%S'),
|
33
|
+
}
|
34
|
+
|
35
|
+
form_data = Http.get_body(service, params, @config)
|
36
|
+
|
37
|
+
{
|
38
|
+
form_method: {
|
39
|
+
method: :post,
|
40
|
+
url: config[:server_url] + post_path,
|
41
|
+
},
|
42
|
+
form_data: form_data
|
43
|
+
}
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module Reapal
|
4
|
+
module Form
|
5
|
+
module MobileModifyForm
|
6
|
+
|
7
|
+
# 1.7 签约手机号修改
|
8
|
+
#
|
9
|
+
# @param contract [String] 用户协议
|
10
|
+
# @param new_phone [String] 新手机号
|
11
|
+
# @param return_url [String] 回调 url
|
12
|
+
# @param notify_url [String] 通知 url
|
13
|
+
# @param buyway [String] 设备通道,默认手机端。00:PC端;01:手机端;02:Pad端;03:其它
|
14
|
+
#
|
15
|
+
# @return [ Hash ] 结果集
|
16
|
+
# * :form_method
|
17
|
+
# * :method
|
18
|
+
# * :url
|
19
|
+
# * :form_data
|
20
|
+
# * :merchant_id
|
21
|
+
# * :encryptkey
|
22
|
+
# * :data
|
23
|
+
#
|
24
|
+
def mobile_modify_form(contract, new_phone, return_url, notify_url, busway='01')
|
25
|
+
service = 'reapal.trust.mobileModify'
|
26
|
+
post_path = '/reagw/user/rest.htm'
|
27
|
+
|
28
|
+
params = {
|
29
|
+
contracts: contract,
|
30
|
+
mobile: new_phone,
|
31
|
+
busway: busway,
|
32
|
+
returnUrl: return_url,
|
33
|
+
notifyUrl: notify_url,
|
34
|
+
applyTime: Time.now.strftime('%Y-%m-%d %H:%M:%S'),
|
35
|
+
}
|
36
|
+
|
37
|
+
form_data = Http.get_body(service, params, @config)
|
38
|
+
|
39
|
+
{
|
40
|
+
form_method: {
|
41
|
+
method: :post,
|
42
|
+
url: config[:server_url] + post_path,
|
43
|
+
},
|
44
|
+
form_data: form_data
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module Reapal
|
4
|
+
module Form
|
5
|
+
module SignleTenderTransfer
|
6
|
+
|
7
|
+
# 3.16 债权转让(Form)
|
8
|
+
#
|
9
|
+
# @param flow_id [String] 业务订单号
|
10
|
+
# @param tender_no [String] 转让方原投资标的号
|
11
|
+
# @param trans_capital [BigDecimal] 转让人出让的本金
|
12
|
+
# @param money [BigDecimal] 债权转让承接人应支付金额
|
13
|
+
# @param trans_contracts [String] 债权转让方在存管系统签约的协议号
|
14
|
+
# @param into_contracts [String] 债权承接方在存管系统签约的协议号
|
15
|
+
# @param transfer_type [String] 债转类型
|
16
|
+
# @param invest_order [String] 若transferType为1时,即首次债转时必传
|
17
|
+
# @param org_transfer_order [String] 若transferType 为2时,即N次债转时必传
|
18
|
+
# @param busway [String] 00:PC端;01:手机端;02:Pad端;03:其它
|
19
|
+
# @param return_url [String] 回调 url
|
20
|
+
# @param notify_url [String] 通知 url
|
21
|
+
|
22
|
+
|
23
|
+
# @return [ Hash ] 结果集
|
24
|
+
# * form_method
|
25
|
+
# * url
|
26
|
+
# * method
|
27
|
+
# * form_data
|
28
|
+
# * :merchant_id
|
29
|
+
# * :encryptkey
|
30
|
+
# * :data
|
31
|
+
#
|
32
|
+
def signle_tender_transfer_form(flow_id, tender_no, trans_capital, money, into_contracts,
|
33
|
+
transfer_type, invest_order, org_transfer_order, busway='01',
|
34
|
+
return_url, notify_url)
|
35
|
+
|
36
|
+
service = 'reapal.trust.signleTenderTransfer'
|
37
|
+
post_path = '/reagw/tender/rest.htm'
|
38
|
+
|
39
|
+
params = {
|
40
|
+
orderNo: flow_id,
|
41
|
+
tenderNo: tender_no,
|
42
|
+
transCapital: trans_capital,
|
43
|
+
amount: money,
|
44
|
+
transContracts: trans_contracts,
|
45
|
+
intoContracts: into_contracts,
|
46
|
+
fee: '',
|
47
|
+
feeType: '',
|
48
|
+
transferType: transfer_type,
|
49
|
+
investOrder: invest_order,
|
50
|
+
orgTransferOrder: org_transfer_order,
|
51
|
+
busway: busway,
|
52
|
+
returnUrl: return_url,
|
53
|
+
notifyUrl: notify_url,
|
54
|
+
remark: '',
|
55
|
+
applyTime: Time.now.strftime('%Y-%m-%d %H:%M:%S')
|
56
|
+
}
|
57
|
+
|
58
|
+
form_data = Http.get_body(service, params, @config)
|
59
|
+
|
60
|
+
{
|
61
|
+
form_method: {
|
62
|
+
:url => config[:server_url] + post_path,
|
63
|
+
:method => :post,
|
64
|
+
},
|
65
|
+
form_data: form_data
|
66
|
+
}
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
end #SignleTenderTransfer
|
71
|
+
end
|
72
|
+
end
|