reapal 0.2.2 → 0.3.0

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.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/Rakefile +1 -5
  4. data/lib/reapal.rb +7 -0
  5. data/lib/reapal/api/api_helper.rb +51 -0
  6. data/lib/reapal/api/money/deposit_apply_api.rb +73 -0
  7. data/lib/reapal/api/money/deposit_confirm_api.rb +49 -0
  8. data/lib/reapal/api/money/deposit_query.rb +36 -0
  9. data/lib/reapal/api/money/deposit_sms_api.rb +48 -0
  10. data/lib/reapal/api/money/sub_account.rb +53 -0
  11. data/lib/reapal/api/money/sub_account_query.rb +45 -0
  12. data/lib/reapal/api/money/withdraw_query.rb +47 -0
  13. data/lib/reapal/api/order/query_by_flow_id.rb +64 -0
  14. data/lib/reapal/api/order/query_by_single_flow_id.rb +55 -0
  15. data/lib/reapal/api/order/tender_serial_no_query.rb +56 -0
  16. data/lib/reapal/api/{asset → tender}/tender_all_cancel.rb +5 -24
  17. data/lib/reapal/api/{asset → tender}/tender_apply.rb +6 -24
  18. data/lib/reapal/api/{asset → tender}/tender_auth_cancel.rb +2 -21
  19. data/lib/reapal/api/{asset → tender}/tender_auth_query.rb +3 -24
  20. data/lib/reapal/api/{asset → tender}/tender_finish.rb +7 -26
  21. data/lib/reapal/api/tender/tender_onkey_invest.rb +52 -0
  22. data/lib/reapal/api/tender/tender_onkey_refund.rb +71 -0
  23. data/lib/reapal/api/tender/tender_onkey_single_transfer.rb +73 -0
  24. data/lib/reapal/api/{asset → tender}/tender_repayment_complete.rb +3 -22
  25. data/lib/reapal/api/{asset → tender}/tender_repayment_project.rb +10 -29
  26. data/lib/reapal/api/user/balance_query.rb +11 -22
  27. data/lib/reapal/api/user/bank_card_add_sms.rb +16 -26
  28. data/lib/reapal/api/user/bank_card_add_sms_again.rb +5 -24
  29. data/lib/reapal/api/user/bank_card_add_sms_confirm.rb +5 -24
  30. data/lib/reapal/api/user/bind_card_query.rb +5 -16
  31. data/lib/reapal/api/user/contract_query.rb +32 -4
  32. data/lib/reapal/api/user/mobile_query.rb +1 -20
  33. data/lib/reapal/api/user/modify_bind_bank_card.rb +55 -0
  34. data/lib/reapal/api/user/onekey_batch_contract.rb +1 -15
  35. data/lib/reapal/api/user/onekey_com_contract.rb +78 -0
  36. data/lib/reapal/api/user/onekey_contract.rb +1 -14
  37. data/lib/reapal/api/user/undo_bind_bank_card.rb +5 -24
  38. data/lib/reapal/client.rb +2 -2
  39. data/lib/reapal/form/business_auth_form.rb +47 -57
  40. data/lib/reapal/form/certificate_form.rb +43 -0
  41. data/lib/reapal/form/find_trade_password_form.rb +2 -10
  42. data/lib/reapal/form/form_helper.rb +35 -0
  43. data/lib/reapal/form/mobile_modify_form.rb +2 -10
  44. data/lib/reapal/form/withdraw_apply_form.rb +2 -10
  45. data/lib/reapal/http/communicate.rb +5 -4
  46. data/lib/reapal/http/decode.rb +29 -0
  47. data/lib/reapal/http/error_code/common.rb +13 -0
  48. data/lib/reapal/http/error_code/money.rb +44 -0
  49. data/lib/reapal/http/error_code/order.rb +17 -0
  50. data/lib/reapal/http/error_code/tender.rb +69 -0
  51. data/lib/reapal/http/error_code/user.rb +45 -0
  52. data/lib/reapal/utils.rb +2 -2
  53. data/lib/reapal/version.rb +1 -1
  54. metadata +33 -15
  55. data/lib/reapal/api/error_codes.rb +0 -46
  56. data/lib/reapal/api/money/.keep +0 -0
  57. data/lib/reapal/api/order/.keep +0 -0
  58. data/lib/reapal/form/signle_tender_transfer_form.rb +0 -72
  59. data/lib/reapal/form/tender_invest_form.rb +0 -62
  60. data/lib/reapal/form/tender_refund_form.rb +0 -84
@@ -18,7 +18,7 @@ module Reapal
18
18
  # * :error_msg [String] 错误信息
19
19
  # * :data: 具体业务返回信息
20
20
  # * :contracts [String] 用户协议号
21
- # * :bank_cards [Array] 银行卡信息数组
21
+ # * :bank_cards [Array] 银行卡信息数组
22
22
  # * :bank_name 银行名称
23
23
  # * :bank_code 银行代码
24
24
  # * :bank_card 银行卡后四位
@@ -40,24 +40,13 @@ module Reapal
40
40
  queryTime: Time.now.strftime('%Y-%m-%d %H:%M:%S')
41
41
  }
42
42
 
43
- response = Http.post(service, params, @config, post_path)
43
+ res = operate_post(:query, service, params, post_path, Http::ErrorCode.bind_card, ['0000'])
44
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
45
+ if 'S' == res[:result]
46
+ # TODO: (tony) 返回的银行字符串解析成数据,便于使用方
47
+ # res[:data][:bank_cards] = parse_cards_info(res[:data][:bank_cards])
53
48
  end
54
49
 
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
50
  res
62
51
  end
63
52
 
@@ -7,12 +7,40 @@ module Reapal
7
7
 
8
8
  # 1.5 签约查询,支持个人和企业(API)
9
9
  #
10
- def contract_query(ori_flow_id)
11
- # TODO(tony): 目前我们只用个人签约,个人签约都是同步返回,所以先不做实现
12
- raise "Not Implement"
10
+ # @param oneket_com_contract_flow_id [ 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
+ # * :orderNo [String] 签约订单号
20
+ # * :contract [String] 企业协议号
21
+ # * :result [String] * :resultCode [String] 结果代码 0000:签约成功 0003:待审核
22
+ # * :corpName [String] 法人代表姓名
23
+ # * :corpIdentity [String] 法人身份证号
24
+ # * :comLicense [String] 组织机构代码/社会征信号
25
+ # * :licStartDate [String] 企业组织机构证起始日
26
+ # * :licEndDate [String] 企业组织机构证截止日
27
+ # * :mobile [String] 手机号
28
+ # * :email [String] 企业邮箱
29
+ # * :remark [String] 备注
30
+ #
31
+ def contract_query(oneket_com_contract_flow_id)
32
+ service = 'reapal.trust.contractQuery'
33
+ post_path = '/reagw/agreement/agreeApi.htm'
34
+
35
+ params = {
36
+ orderNo: oneket_com_contract_flow_id,
37
+ queryTime: Time.now.strftime('%Y-%m-%d %H:%M:%S'),
38
+ }
39
+
40
+ operate_post(:query, service, params, post_path, Http::ErrorCode.contract_query, ['0000'])
13
41
  end
14
42
 
15
- end
43
+ end # module
16
44
  end
17
45
  end
18
46
  end
@@ -19,8 +19,6 @@ module Reapal
19
19
  # * :contracts [String] 用户协议号
20
20
  # * :mobile [String] 用户手机号
21
21
  #
22
-
23
-
24
22
  def mobile_query(contracts)
25
23
  service = 'reapal.trust.mobileQuery'
26
24
  post_path = '/reagw/user/restApi.htm'
@@ -30,24 +28,7 @@ module Reapal
30
28
  queryTime: Time.now.strftime('%Y-%m-%d %H:%M:%S'),
31
29
  }
32
30
 
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
31
+ operate_post(:query, service, params, post_path, Http::ErrorCode.mobile, ['0000'])
51
32
  end
52
33
 
53
34
  end
@@ -0,0 +1,55 @@
1
+ # coding: utf-8
2
+ module Reapal
3
+ module Api
4
+ module User
5
+ module ModifyBankCardAddSms
6
+
7
+ # 1.14 修改绑卡(API)
8
+ #
9
+ # @param flow_id [ String ] 订单号
10
+ # @param contracts [ 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
+ #
17
+ # @return [ Hash ] 结果集
18
+ # * :result [String] "S"/"F"/"P"
19
+ # * :request_params [Hash] 请求参数
20
+ # * :response [Object] 请求返回对象
21
+ # * :error_code [String] 错误代号
22
+ # * :error_msg [String] 错误信息
23
+ # * :data: 具体业务返回信息
24
+ # * :flow_id [ String ] 订单号
25
+ # * :result_code [ String ] 结果代码 0000:申请成功
26
+ #
27
+ def modify_bank_card_add_sms(flow_id,
28
+ contracts,
29
+ bank_account_no,
30
+ account_province,
31
+ account_city,
32
+ branch,
33
+ subbranch)
34
+
35
+ service = 'reapal.trust.modifyBindBankCard'
36
+ post_path = '/reagw/bankcard/modifyBindBankApi.htm'
37
+
38
+ params = {
39
+ orderNo: flow_id,
40
+ contracts: contracts,
41
+ bankAccountNo: bank_account_no,
42
+ accountProvince: account_province,
43
+ accountCity: account_city,
44
+ branch: branch,
45
+ subbranch: subbranch,
46
+ applyTime: Time.now.strftime('%Y-%m-%d %H:%M:%S'),
47
+ }
48
+
49
+ operate_post(:operate, service, params, post_path, Http::ErrorCode.bind_card, ['0000'])
50
+ end
51
+
52
+ end # module
53
+ end
54
+ end
55
+ end
@@ -42,21 +42,7 @@ module Reapal
42
42
  applyTime: Time.now.strftime('%Y-%m-%d %H:%M:%S'),
43
43
  }
44
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
- # 个人签约只有返回码是 '0000', '0007' 才成功
52
- if ['0000', '0007'].include?(response.data[:resultCode])
53
- res[:result] = 'S'
54
- res[:data] = response.data
55
- else
56
- res[:result] = 'F'
57
- end
58
-
59
- res
45
+ operate_post(:operate, service, params, post_path, Http::ErrorCode.contract_create, ['0000', '0007'])
60
46
  end
61
47
 
62
48
  end # module Agree
@@ -0,0 +1,78 @@
1
+ # coding: utf-8
2
+
3
+ module Reapal
4
+ module Api
5
+ module User
6
+ module OnekeyComContract
7
+
8
+ # 1. 企业一键签约(API)
9
+ #
10
+ # @param flow_id [ String ] 订单号
11
+ # @param corp_name [ String ] 法人代表姓名
12
+ # @param identity_id [ String ] 法人身份证号
13
+ # @param com_name [ String ] 企业名称
14
+ # @param com_license [ String ] 组织机构代码/社会征信号
15
+ # @param lic_start_date [ Datetime ] 企业组织机构证起始日
16
+ # @param lic_end_date [ Datetime ] 企业组织机构证截止日
17
+ # @param phone [ String ] 手机号
18
+ # @param return_url [ String ] 回调 URL
19
+ # @param notify_url [ String ] 通知 URL
20
+ # @param email [ String ] 企业邮箱
21
+ # @param busway [ String ] 设备通道,默认手机端 00:PC端;01:手机端;02:Pad端;03:其它
22
+ # @param remark [ String ] 备注
23
+ #
24
+ # @return [ Hash ] 结果集
25
+ # * :result [String] 业务结果:'S/F/P'
26
+ # * :request_params [Hash] 请求参数
27
+ # * :response [Object] 请求返回对象
28
+ # * :error_code [String] 错误代号
29
+ # * :error_msg [String] 错误信息
30
+ # * :data: 具体业务返回信息
31
+ # * :orderNo [String] 订单号
32
+ # * :contracts [String] 企业签约协议号
33
+ # * :resultCode [String] 结果代码 0000:申请成功 0002:签约成功(审核通过)0003:签约失败(审核不通过)0006:再次申请成功(拒绝后)
34
+ # * :corpName [String] 法人代表姓名
35
+ # * :corpIdentity [String] 法人身份证号
36
+ # * :comLicense [String] 组织机构代码/社会征信号
37
+ # * :licStartDate [String] 企业组织机构证起始日
38
+ # * :licEndDate [String] 企业组织机构证截止日
39
+ # * :mobile [String] 手机号
40
+ # * :email [String] 企业邮箱
41
+ # * :remark [String] 备注
42
+ #
43
+ def onekey_com_contract(flow_id, corp_name, identity_id, com_name, com_license,
44
+ lic_start_date, lic_end_date, phone, return_url, notify_url,
45
+ email='', busway='01', remark='')
46
+ service = 'reapal.trust.comContractAPI'
47
+ post_path = '/reagw/agreement/agree.htm'
48
+
49
+ params = {
50
+ orderNo: flow_id,
51
+ corpName: corp_name,
52
+ corpIdentity: identity_id,
53
+ comName: com_name,
54
+ comLicense: com_license,
55
+ licStartDate: lic_start_date,
56
+ licEndDate: lic_end_date,
57
+ mobile: phone,
58
+ email: email,
59
+ busway: busway,
60
+ returnUrl: return_url,
61
+ notifyUrl: notify_url,
62
+ remark: '',
63
+ applyTime: Time.now.strftime('%Y-%m-%d %H:%M:%S'),
64
+ }
65
+
66
+ res = operate_post(:operate, service, params, post_path, Http::ErrorCode.contract_create, ['0002', '0006'])
67
+
68
+ if 'S' == res[:result] && '0003' == res[:data][:resultCode]
69
+ res[:result] = 'F'
70
+ end
71
+
72
+ res
73
+ end
74
+
75
+ end # module
76
+ end
77
+ end
78
+ end
@@ -39,20 +39,7 @@ module Reapal
39
39
  applyTime: Time.now.strftime('%Y-%m-%d %H:%M:%S'),
40
40
  }
41
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
42
+ operate_post(:operate, service, params, post_path, Http::ErrorCode.contract_create, ['0000', '0007'])
56
43
  end
57
44
 
58
45
  end # module
@@ -7,8 +7,8 @@ module Reapal
7
7
 
8
8
  # 1.13 撤销绑卡 (API)
9
9
  #
10
- # @param order_no [ String ] 订单号
11
- # @param contract [ String ] 用户协议号
10
+ # @param flow_id [ String ] 订单号
11
+ # @param contracts [ String ] 用户协议号
12
12
  # @param bank_account_no [ String ] 银行卡信息(卡号后四位)
13
13
  #
14
14
  # @return [ Hash ] 结果集
@@ -21,37 +21,18 @@ module Reapal
21
21
  # * :orderNo [String] 订单号
22
22
  # * :resultCode [String] 结果代码 0000:撤销绑卡成功
23
23
  #
24
- def undo_bind_bank_card(order_no, contracts, bank_account_no)
24
+ def undo_bind_bank_card(flow_id, contracts, bank_account_no)
25
25
  service = 'reapal.trust.undoBindBankCard'
26
26
  post_path = '/reagw/bankcard/undoBindBankApi.htm'
27
27
 
28
28
  params = {
29
- orderNo: order_no,
29
+ orderNo: flow_id,
30
30
  contracts: contracts,
31
31
  bankAccountNo: bank_account_no,
32
32
  applyTime: Time.now.strftime('%Y-%m-%d %H:%M:%S'),
33
33
  }
34
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
35
+ operate_post(:operate, service, params, post_path, Http::ErrorCode.bind_card, ['0000'])
55
36
  end
56
37
 
57
38
  end # module
@@ -23,8 +23,8 @@ module Reapal
23
23
  recursive_include_api('Reapal::Form')
24
24
  end
25
25
 
26
- def decode_data(encryptkey, data)
27
- ::Reapal::Http::decode_data(encryptkey, data, @config)
26
+ def decode_notify_data(encryptkey, data)
27
+ ::Reapal::Http::Decode.decode_notify_data(encryptkey, data, @config)
28
28
  end
29
29
 
30
30
  private
@@ -1,61 +1,51 @@
1
1
  # coding: utf-8
2
2
 
3
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
4
+ module Form
5
+ module BusinessAuthForm
6
+
7
+ # 3.20 标的授权 (Form)
8
+ #
9
+ # @param flow_id [String] 业务订单号
10
+ # @param contracts [String] 用户协议号
11
+ # @param services [String] 授权服务 02一键投标 ,03 为一键还款 04 一键债转
12
+ # @param auth_limit [String] 授权期限日期 YYYYMMDD
13
+ # @param return_url [String] 回调 url
14
+ # @param notify_url [String] 通知 url
15
+ # @param tender_no [String] 标的号,授权为一键还款时必填
16
+ # @param busway [String] 00:PC端;01:手机端;02:Pad端;03:其它
17
+ #
18
+ # @return [ Hash ] 结果集
19
+ # * form_method
20
+ # * url
21
+ # * method
22
+ # * form_data
23
+ # * :merchant_id
24
+ # * :encryptkey
25
+ # * :data
26
+ #
27
+ def business_auth_form(flow_id, contracts, services, auth_limit,
28
+ return_url, notify_url, tender_no=nil, busway='01')
29
+
30
+ service = 'reapal.trust.businessAuth'
31
+ post_path = '/reagw/user/rest.htm'
32
+
33
+ params = {
34
+ orderNo: flow_id,
35
+ contracts: contracts,
36
+ services: services,
37
+ busway: busway,
38
+ authLimit: auth_limit,
39
+ tenderNo: tender_no,
40
+ returnUrl: return_url,
41
+ notifyUrl: notify_url,
42
+ remark: '',
43
+ applyTime: Time.now.strftime('%Y-%m-%d %H:%M:%S')
44
+ }
45
+
46
+ get_form_data(service, params, post_path)
47
+ end
48
+
49
+ end #BusinessAuth
50
+ end
61
51
  end