reapal 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- 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,70 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module Reapal
|
4
|
+
module Api
|
5
|
+
module Asset
|
6
|
+
module TenderRepaymentProject
|
7
|
+
|
8
|
+
# 3.14 还款计划
|
9
|
+
#
|
10
|
+
# @param flow_id [String] 还款计划订单号
|
11
|
+
# @param tender_no [String] 商户系统标的号
|
12
|
+
# @param project_details [String] 还款计划明细
|
13
|
+
# * :periods [Integer] 还款期数
|
14
|
+
# * :projPrincipal [BigDecimal] 计划还款本金
|
15
|
+
# * :projInterest [BigDecimal] 计划还款利息
|
16
|
+
# * :projPoundage [BigDecimal] 计划还款手续费
|
17
|
+
# * :projAmount [BigDecimal] 计划还款总金额
|
18
|
+
# * :projTime [String] 计划还款日期
|
19
|
+
# @param busway [String] 设备通道, '00':PC端;'01':手机端(默认);'02':Pad端;'03':其它
|
20
|
+
# @param remark [String] 备注
|
21
|
+
|
22
|
+
# @return [ Hash ] 结果集
|
23
|
+
# * :result [String] 业务结果:'S/F/P'
|
24
|
+
# * :request_params [Hash] 请求参数
|
25
|
+
# * :response [Object] 请求返回对象
|
26
|
+
# * :error_code [String] 错误代号
|
27
|
+
# * :error_msg [String] 错误信息
|
28
|
+
# * :data: 具体业务返回信息
|
29
|
+
# * :orderNo [String] 还款订单号
|
30
|
+
# * :resultCode [String] 结果代码
|
31
|
+
#
|
32
|
+
def tender_repayment_project(flow_id, tender_no, project_details, busway='01', remark='')
|
33
|
+
service = 'reapal.trust.repaymentProject'
|
34
|
+
post_path = '/reagw/tender/rest.htm'
|
35
|
+
|
36
|
+
params = {
|
37
|
+
orderNo: flow_id,
|
38
|
+
tenderNo: tender_no,
|
39
|
+
projectDetails: project_details,
|
40
|
+
busway: busway,
|
41
|
+
remark: remark,
|
42
|
+
applyTime: Time.now.strftime('%Y-%m-%d %H:%M:%S'),
|
43
|
+
}
|
44
|
+
|
45
|
+
response = Http.post(service, params, @config, post_path)
|
46
|
+
|
47
|
+
res = Reapal::Utils.api_result(params, response)
|
48
|
+
|
49
|
+
#非返回类错误
|
50
|
+
return res if response.http_pending? # 比如超时等操作
|
51
|
+
|
52
|
+
# 只有返回码是 '0000'还款信息同步成功
|
53
|
+
if ['0000'].include?(response.data[:resultCode])
|
54
|
+
res[:result] = "S"
|
55
|
+
end
|
56
|
+
|
57
|
+
#确定的错误
|
58
|
+
if Reapal::Api::ErrorCode.tender_repayment_project.include?(response.data[:resultCode])
|
59
|
+
res[:result] = "F"
|
60
|
+
return res
|
61
|
+
end
|
62
|
+
|
63
|
+
# 不能确定的错误 ,pending
|
64
|
+
res
|
65
|
+
end
|
66
|
+
|
67
|
+
end # module TenderRepaymentProject
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Reapal
|
2
|
+
module Api
|
3
|
+
module ErrorCode
|
4
|
+
|
5
|
+
def tender_common
|
6
|
+
@_tender_common = %w(0400 0401 0402 0405 0406 0407 0408 0409 0410)
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.mobile
|
10
|
+
@_mobile ||= ['1108']
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.tender_cancel
|
14
|
+
@_tender_cancel ||= %w(0700 0701 0702 0703 0704 0705 0706 0707 0708 0709
|
15
|
+
0710 0711 0712 0713 0714 0715 0716 0717 0718 0719
|
16
|
+
1501 1502 1503 1504 1505 1506 1507 1508)
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
def self.tender_apply
|
21
|
+
@_tender_apply ||= %w(0500 0501 0502 0503 0504 0505 0506 0507 0508 0509 0510 0511 0512 0513 0514 0515 0516 0517 0518 0519 0520 0521 0522 0523 0524 0525 0526 0527 0528 0529 0530 0531 0532 0533 0534 0535 0536)
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.tender_repayment_project
|
25
|
+
@_tender_repayment_project ||= [].merge(@_tender_common)
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.tender_repayment_complete
|
29
|
+
@_tender_repayment_complete ||= [].merge(@_tender_common)
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.tender_auth_query
|
33
|
+
@_tender_auth_query ||= [].merge(@_tender_common)
|
34
|
+
end
|
35
|
+
|
36
|
+
def tender_auth_cancel
|
37
|
+
@_tender_auth_cancel ||= [].merge(@_tender_common)
|
38
|
+
end
|
39
|
+
|
40
|
+
def tender_finish
|
41
|
+
@_tender_finish ||= [].merge(@_tender_common)
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
File without changes
|
File without changes
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module Reapal
|
4
|
+
module Api
|
5
|
+
module User
|
6
|
+
module BalanceQuery
|
7
|
+
|
8
|
+
# 1.6 查询余额(API)
|
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
|
+
# * :total_amount [BigDecimal] 账户总额
|
20
|
+
# * :usable_amount [BigDecimal] 可用金额
|
21
|
+
# * :tender_amount [BigDecimal] 投标金额
|
22
|
+
#
|
23
|
+
def balance_query(contracts)
|
24
|
+
service = 'reapal.trust.balanceQuery'
|
25
|
+
post_path = '/reagw/agreement/agreeApi.htm'
|
26
|
+
|
27
|
+
params = {
|
28
|
+
contracts: contracts,
|
29
|
+
queryTime: Time.now.strftime('%Y-%m-%d %H:%M:%S'),
|
30
|
+
}
|
31
|
+
|
32
|
+
response = Http.post(service, params, @config, post_path)
|
33
|
+
|
34
|
+
res = Reapal::Utils.api_result(params, response)
|
35
|
+
|
36
|
+
# 查询类 api,http 没成功都返回 pending
|
37
|
+
return res unless response.http_success?
|
38
|
+
|
39
|
+
# 如果查不到这个人
|
40
|
+
if response.data[:errorCode] == '0113'
|
41
|
+
res[:result] = 'F'
|
42
|
+
return res
|
43
|
+
end
|
44
|
+
|
45
|
+
# 其余 api 错误不知道
|
46
|
+
return res unless response.data[:errorCode].nil?
|
47
|
+
|
48
|
+
res[:result] = 'S'
|
49
|
+
res[:data] = {
|
50
|
+
totalAmount: response.data[:totalAmount].to_d,
|
51
|
+
usableAmount: response.data[:usableAmount].to_d,
|
52
|
+
tenderAmount: response.data[:tenderAmount].to_d,
|
53
|
+
}
|
54
|
+
|
55
|
+
res
|
56
|
+
end
|
57
|
+
|
58
|
+
end # module Agree
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module Reapal
|
2
|
+
module Api
|
3
|
+
module User
|
4
|
+
module BankCardAddSms
|
5
|
+
|
6
|
+
# 1.10 一键绑卡申请(API)
|
7
|
+
#
|
8
|
+
# @param order_no [ String ] 订单号
|
9
|
+
# @param contracts [ String ] 用户协议号
|
10
|
+
# @param bank_code [ String ] 银行代码
|
11
|
+
# @param bank_account_no [ String ] 银行卡账号
|
12
|
+
# @param account_province [ String ] 银行所在省
|
13
|
+
# @param account_city [ String ] 银行所在市
|
14
|
+
# @param branch [ String] 银行分行
|
15
|
+
# @param subbranch [ String ] 银行支行
|
16
|
+
# @param mobile_phone [ String ] 银行预留手机
|
17
|
+
|
18
|
+
# @return [ Hash ] 结果集
|
19
|
+
# * :result [String] "S"/"F"/"P"
|
20
|
+
# * :request_params [Hash] 请求参数
|
21
|
+
# * :response [Object] 请求返回对象
|
22
|
+
# * :error_code [String] 错误代号
|
23
|
+
# * :error_msg [String] 错误信息
|
24
|
+
# * :data: 具体业务返回信息
|
25
|
+
# * :order_no [ String ] 订单号
|
26
|
+
# * :result_code [ String ] 结果代码 0000:申请成功
|
27
|
+
#
|
28
|
+
def bank_card_add_sms(order_no, contracts, bank_code, bank_account_no, account_province, account_city, branch, subbranch, mobile_phone)
|
29
|
+
service = 'reapal.trust.bankCardAddSMS'
|
30
|
+
post_path = '/reagw/bankcard/bankCardSMS.htm'
|
31
|
+
|
32
|
+
params = {
|
33
|
+
orderNo: order_no,
|
34
|
+
contracts: contracts,
|
35
|
+
bankCode: bank_code,
|
36
|
+
bankAccountNo: bank_account_no,
|
37
|
+
accountProvince: account_province,
|
38
|
+
accountCity: account_city,
|
39
|
+
branch: branch,
|
40
|
+
subbranch: subbranch,
|
41
|
+
mobilePhone: mobile_phone,
|
42
|
+
applyTime: Time.now.strftime('%Y-%m-%d %H:%M:%S'),
|
43
|
+
}
|
44
|
+
|
45
|
+
response = Http.post(service, params, @config, post_path)
|
46
|
+
|
47
|
+
res = Reapal::Utils.api_result(params, response)
|
48
|
+
|
49
|
+
return res if response.http_pending? # 比如超时等操作
|
50
|
+
|
51
|
+
# 1,明确失败的
|
52
|
+
if Api::ErrorCode.bind_card.include?(response.data[:errorCode])
|
53
|
+
res[:result] = 'F'
|
54
|
+
return res
|
55
|
+
end
|
56
|
+
|
57
|
+
# 2. 明确正确的
|
58
|
+
if ['0000'].include?(response.data[:resultCode])
|
59
|
+
res[:result] = 'S'
|
60
|
+
return res
|
61
|
+
end
|
62
|
+
|
63
|
+
# 3. 其他错误 pending
|
64
|
+
res
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
end # module
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module Reapal
|
4
|
+
module Api
|
5
|
+
module User
|
6
|
+
module BankCardAddSmsAgain
|
7
|
+
|
8
|
+
# 1.11 一键绑卡重发短信(API)
|
9
|
+
#
|
10
|
+
# @param order_no [ String ] 交易订单号(非自动生成,与一键绑卡申请短信订单号保持一致)
|
11
|
+
# @param contracts [ String ] 用户协议号
|
12
|
+
# @param busway [ String ] 设备通道 00:PC端;01:手机端;02:Pad端;03:其它
|
13
|
+
# @param remark [ String ] 业务备注信息
|
14
|
+
#
|
15
|
+
# @return [ Hash ] 结果集
|
16
|
+
# * :result [String] 业务结果:'S/F/P'
|
17
|
+
# * :request_params [Hash] 请求参数
|
18
|
+
# * :response [Object] 请求返回对象
|
19
|
+
# * :error_code [String] 错误代号
|
20
|
+
# * :error_msg [String] 错误信息
|
21
|
+
# * :data: 具体业务返回信息
|
22
|
+
# * :order_no [ String ] 交易订单号
|
23
|
+
# * :result_code [ String ] 结果代码 0000:绑卡成功
|
24
|
+
#
|
25
|
+
def bank_card_add_sms_again(order_no, contracts, busway = '01', remark = "")
|
26
|
+
service = 'reapal.trust.bankCardAddSMSAgain'
|
27
|
+
post_path = '/reagw/bankcard/bankCardSMS.htm'
|
28
|
+
|
29
|
+
params = {
|
30
|
+
orderNo: order_no,
|
31
|
+
contracts: contracts,
|
32
|
+
busway: busway,
|
33
|
+
remark: remark,
|
34
|
+
applyTime: Time.now.strftime('%Y-%m-%d %H:%M:%S'),
|
35
|
+
}
|
36
|
+
|
37
|
+
response = Http.post(service, params, @config, post_path)
|
38
|
+
|
39
|
+
res = Reapal::Utils.api_result(params, response)
|
40
|
+
|
41
|
+
return res if response.http_pending? # 比如超时等操作
|
42
|
+
|
43
|
+
# 1,明确失败的
|
44
|
+
if Api::ErrorCode.deposit.include?(response.data[:errorCode])
|
45
|
+
res[:result] = 'F'
|
46
|
+
return res
|
47
|
+
end
|
48
|
+
|
49
|
+
# 2. 明确正确的
|
50
|
+
if ['0000'].include?(response.data[:resultCode])
|
51
|
+
res[:result] = 'S'
|
52
|
+
return res
|
53
|
+
end
|
54
|
+
|
55
|
+
# 3. pending
|
56
|
+
res
|
57
|
+
end
|
58
|
+
|
59
|
+
end # module
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module Reapal
|
4
|
+
module Api
|
5
|
+
module User
|
6
|
+
module BankCardAddSmsConfirm
|
7
|
+
|
8
|
+
# 1.11 一键绑卡确认(API)
|
9
|
+
#
|
10
|
+
# @param order_no [ String ] 交易订单号(与一键绑卡申请订单号保持一致)
|
11
|
+
# @param check_code [ String ] 短信验证码
|
12
|
+
# @param busway [ String ] 设备通道 00:PC端;01:手机端;02:Pad端;03:其它
|
13
|
+
# @param remark [ String ] 业务备注信息
|
14
|
+
|
15
|
+
# @return [ Hash ] 结果集
|
16
|
+
# * :result [String] "S"/"F"/"P"
|
17
|
+
# * :request_params [Hash] 请求参数
|
18
|
+
# * :response [Object] 请求返回对象
|
19
|
+
# * :error_code [String] 错误代号
|
20
|
+
# * :error_msg [String] 错误信息
|
21
|
+
# * :data: 具体业务返回信息
|
22
|
+
# * :order_no [ String ] 交易订单号
|
23
|
+
# * :result_code [ String ] 结果代码 0000:绑卡成功
|
24
|
+
#
|
25
|
+
def bank_card_add_sms_confirm(order_no, check_code = '123456', busway = '01', remark = "")
|
26
|
+
service = 'reapal.trust.bankCardAddSMSConfirm'
|
27
|
+
post_path = '/reagw/bankcard/bankCardSMS.htm'
|
28
|
+
|
29
|
+
params = {
|
30
|
+
orderNo: order_no,
|
31
|
+
checkCode: check_code,
|
32
|
+
busway: busway,
|
33
|
+
applyTime: Time.now.strftime('%Y-%m-%d %H:%M:%S'),
|
34
|
+
}
|
35
|
+
|
36
|
+
response = Http.post(service, params, @config, post_path)
|
37
|
+
|
38
|
+
res = Reapal::Utils.api_result(params, response)
|
39
|
+
|
40
|
+
return res if response.http_pending? # 比如超时等操作
|
41
|
+
|
42
|
+
# 1,明确失败的
|
43
|
+
if Api::ErrorCode.bind_card.include?(response.data[:errorCode])
|
44
|
+
res[:result] = 'F'
|
45
|
+
return res
|
46
|
+
end
|
47
|
+
|
48
|
+
# 2. 明确正确的
|
49
|
+
if ['0000'].include?(response.data[:resultCode])
|
50
|
+
res[:result] = 'S'
|
51
|
+
return res
|
52
|
+
end
|
53
|
+
|
54
|
+
# 3. pending
|
55
|
+
res
|
56
|
+
end
|
57
|
+
|
58
|
+
end # module
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module Reapal
|
4
|
+
module Api
|
5
|
+
module User
|
6
|
+
module BindCardQuery
|
7
|
+
|
8
|
+
# 1.15 绑卡查询(API)
|
9
|
+
#
|
10
|
+
# @param contracts [ String ] 用户协议号
|
11
|
+
# @param type [ String ] 业务类型 A: 充值和提现; D: 充值; W: 提现 (现只支持提现绑卡查询)
|
12
|
+
#
|
13
|
+
# @return [ Hash ] 结果集
|
14
|
+
# * :result [String] 业务结果:'S/F/P'
|
15
|
+
# * :request_params [Hash] 请求参数
|
16
|
+
# * :response [Object] 请求返回对象
|
17
|
+
# * :error_code [String] 错误代号
|
18
|
+
# * :error_msg [String] 错误信息
|
19
|
+
# * :data: 具体业务返回信息
|
20
|
+
# * :contracts [String] 用户协议号
|
21
|
+
# * :bank_cards [Array] 银行卡信息数组
|
22
|
+
# * :bank_name 银行名称
|
23
|
+
# * :bank_code 银行代码
|
24
|
+
# * :bank_card 银行卡后四位
|
25
|
+
# * :type 业务类型 A: 充值和提现; D: 充值; W: 提现
|
26
|
+
# * :is_safety 绑卡类别 0: 普通卡; 1:安全卡
|
27
|
+
# * :is_required_field 分支行信息 0: 省市分支行信息(系统默认信息); 1:用户自己所填信息
|
28
|
+
# * :account_province 开户行所在省
|
29
|
+
# * :account_city 开户行所在市
|
30
|
+
# * :branch 开户行分行
|
31
|
+
# * :subbranch 开户行支行
|
32
|
+
#
|
33
|
+
def bind_card_query(contracts, type = "W")
|
34
|
+
service = 'reapal.trust.bindQuery'
|
35
|
+
post_path = '/reagw/user/restApi.htm'
|
36
|
+
|
37
|
+
params = {
|
38
|
+
contracts: contracts,
|
39
|
+
type: type,
|
40
|
+
queryTime: Time.now.strftime('%Y-%m-%d %H:%M:%S')
|
41
|
+
}
|
42
|
+
|
43
|
+
response = Http.post(service, params, @config, post_path)
|
44
|
+
|
45
|
+
res = Reapal::Utils.api_result(params, response)
|
46
|
+
|
47
|
+
# 查询类 api,http 没成功都返回 pending
|
48
|
+
return res unless response.http_success?
|
49
|
+
|
50
|
+
if Api::ErrorCode.bind_card.include?(response.data[:errorCode])
|
51
|
+
res[:result] = 'F'
|
52
|
+
return res
|
53
|
+
end
|
54
|
+
|
55
|
+
# 其余 api 错误不知道
|
56
|
+
return res unless response.data[:errorCode].nil?
|
57
|
+
|
58
|
+
res[:result] = 'S'
|
59
|
+
res[:data][:bank_cards] = parse_cards_info(res[:data][:bank_cards])
|
60
|
+
|
61
|
+
res
|
62
|
+
end
|
63
|
+
|
64
|
+
end # module
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|