pingpp 2.2.1 → 2.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/lib/data/ca-certificates.crt +211 -828
- data/lib/pingpp/agreement.rb +11 -0
- data/lib/pingpp/balance_settlement.rb +9 -0
- data/lib/pingpp/card_info.rb +14 -0
- data/lib/pingpp/version.rb +1 -1
- data/lib/pingpp/wx_lite_oauth.rb +42 -0
- data/lib/pingpp.rb +13 -1
- data/test/agreement_test.rb +36 -0
- data/test/balance_settlement_test.rb +19 -0
- data/test/card_info_test.rb +18 -0
- data/test/test_data.rb +8 -0
- metadata +12 -2
data/lib/pingpp/version.rb
CHANGED
@@ -0,0 +1,42 @@
|
|
1
|
+
module Pingpp
|
2
|
+
module WxLiteOauth
|
3
|
+
def self.get_openid(app_id, app_secret, code)
|
4
|
+
response = get_session(app_id, app_secret, code)
|
5
|
+
if response['openid'].nil? then
|
6
|
+
return nil, response
|
7
|
+
else
|
8
|
+
return response['openid'], nil
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.get_session(app_id, app_secret, code)
|
13
|
+
url = create_oauth_url_for_openid(app_id, app_secret, code)
|
14
|
+
return get_request(url)
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.create_oauth_url_for_openid(app_id, app_secret, code)
|
18
|
+
query_parts = {
|
19
|
+
'appid' => app_id,
|
20
|
+
'secret' => app_secret,
|
21
|
+
'js_code' => code,
|
22
|
+
'grant_type' => 'authorization_code'
|
23
|
+
}
|
24
|
+
query_str = Util.encode_parameters(query_parts)
|
25
|
+
'https://api.weixin.qq.com/sns/jscode2session?' + query_str
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.get_request(url)
|
29
|
+
request_opts = {
|
30
|
+
:url => url,
|
31
|
+
:verify_ssl => false,
|
32
|
+
:ssl_version => 'TLSv1',
|
33
|
+
:method => 'GET',
|
34
|
+
:headers => false,
|
35
|
+
:open_timeout => 30,
|
36
|
+
:timeout => 30
|
37
|
+
}
|
38
|
+
response = RestClient::Request.execute(request_opts)
|
39
|
+
response = JSON.parse(response.body)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/pingpp.rb
CHANGED
@@ -56,6 +56,9 @@ require 'pingpp/royalty_transaction'
|
|
56
56
|
require 'pingpp/balance_transfer'
|
57
57
|
require 'pingpp/balance_bonus'
|
58
58
|
require 'pingpp/royalty_template'
|
59
|
+
require 'pingpp/balance_settlement'
|
60
|
+
require 'pingpp/card_info'
|
61
|
+
require 'pingpp/agreement'
|
59
62
|
|
60
63
|
# Errors
|
61
64
|
require 'pingpp/errors/pingpp_error'
|
@@ -66,8 +69,9 @@ require 'pingpp/errors/authentication_error'
|
|
66
69
|
require 'pingpp/errors/channel_error'
|
67
70
|
require 'pingpp/errors/rate_limit_error'
|
68
71
|
|
69
|
-
#
|
72
|
+
# WxOAuth
|
70
73
|
require 'pingpp/wx_pub_oauth'
|
74
|
+
require 'pingpp/wx_lite_oauth'
|
71
75
|
|
72
76
|
module Pingpp
|
73
77
|
DEFAULT_CA_BUNDLE_PATH = File.dirname(__FILE__) + '/data/ca-certificates.crt'
|
@@ -186,6 +190,14 @@ module Pingpp
|
|
186
190
|
@max_network_retries = val.to_i
|
187
191
|
end
|
188
192
|
|
193
|
+
def self.ca_bundle
|
194
|
+
@ca_bundle_path
|
195
|
+
end
|
196
|
+
|
197
|
+
def self.ca_bundle=(val)
|
198
|
+
@ca_bundle_path = val
|
199
|
+
end
|
200
|
+
|
189
201
|
private
|
190
202
|
|
191
203
|
def self.user_agent
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require File.expand_path('../test_assistant', __FILE__)
|
2
|
+
|
3
|
+
module Pingpp
|
4
|
+
class AgreementTest < Test::Unit::TestCase
|
5
|
+
should "execute should return a agreement list when passed correct parameters" do
|
6
|
+
l = Pingpp::Agreement.list(
|
7
|
+
:app => get_app_id,
|
8
|
+
:per_page => 3
|
9
|
+
)
|
10
|
+
|
11
|
+
assert l.object == 'list'
|
12
|
+
assert l.data.count <= 3
|
13
|
+
end
|
14
|
+
|
15
|
+
should "execute should return an exist agreement when passed correct agreement id" do
|
16
|
+
agr_id = get_agreement_id
|
17
|
+
c = Pingpp::Agreement.retrieve(agr_id)
|
18
|
+
|
19
|
+
assert c.object == 'agreement'
|
20
|
+
assert c.id == agr_id
|
21
|
+
end
|
22
|
+
|
23
|
+
should "execute should return an canceled agreement" do
|
24
|
+
begin
|
25
|
+
agr_id = get_agreement_id
|
26
|
+
o = Pingpp::Agreement.cancel(agr_id)
|
27
|
+
|
28
|
+
assert o.id == agr_id
|
29
|
+
assert o.status == 'canceled'
|
30
|
+
rescue => e
|
31
|
+
assert e.kind_of?(Pingpp::InvalidRequestError)
|
32
|
+
assert e.message.include?("该签约对象不能被更新状态")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require File.expand_path('../test_assistant', __FILE__)
|
2
|
+
|
3
|
+
module Pingpp
|
4
|
+
class BalanceSettlementTest < Test::Unit::TestCase
|
5
|
+
should "execute should return a balance_settlement list when passed correct parameters" do
|
6
|
+
bss = Pingpp::BalanceSettlement.list({:per_page => 3})
|
7
|
+
|
8
|
+
assert bss.object == 'list'
|
9
|
+
assert bss.data.count <= 3
|
10
|
+
end
|
11
|
+
|
12
|
+
should "execute should return an exist balance_settlement when passed correct id" do
|
13
|
+
bs = Pingpp::BalanceSettlement.retrieve(get_bs_id)
|
14
|
+
|
15
|
+
assert bs.object == 'balance_settlement'
|
16
|
+
assert bs.id == get_bs_id
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require File.expand_path('../test_assistant', __FILE__)
|
2
|
+
|
3
|
+
module Pingpp
|
4
|
+
class CardInfoTest < Test::Unit::TestCase
|
5
|
+
should "execute should return card info" do
|
6
|
+
# 该接口仅支持 live key
|
7
|
+
card_info = Pingpp::CardInfo.query({
|
8
|
+
:app => get_app_id,
|
9
|
+
:bank_account => '6222280012469823'
|
10
|
+
})
|
11
|
+
|
12
|
+
assert card_info.card_bin == '622228'
|
13
|
+
assert card_info.app == get_app_id
|
14
|
+
assert card_info.card_type == 2
|
15
|
+
assert card_info.open_bank_code == '0310'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/test/test_data.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pingpp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Xufeng Weng
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -40,6 +40,7 @@ extra_rdoc_files: []
|
|
40
40
|
files:
|
41
41
|
- lib/data/ca-certificates.crt
|
42
42
|
- lib/pingpp.rb
|
43
|
+
- lib/pingpp/agreement.rb
|
43
44
|
- lib/pingpp/api_operations/create.rb
|
44
45
|
- lib/pingpp/api_operations/delete.rb
|
45
46
|
- lib/pingpp/api_operations/list.rb
|
@@ -48,11 +49,13 @@ files:
|
|
48
49
|
- lib/pingpp/api_resource.rb
|
49
50
|
- lib/pingpp/app_based_resource.rb
|
50
51
|
- lib/pingpp/balance_bonus.rb
|
52
|
+
- lib/pingpp/balance_settlement.rb
|
51
53
|
- lib/pingpp/balance_transaction.rb
|
52
54
|
- lib/pingpp/balance_transfer.rb
|
53
55
|
- lib/pingpp/batch_refund.rb
|
54
56
|
- lib/pingpp/batch_transfer.rb
|
55
57
|
- lib/pingpp/batch_withdrawal.rb
|
58
|
+
- lib/pingpp/card_info.rb
|
56
59
|
- lib/pingpp/channel.rb
|
57
60
|
- lib/pingpp/charge.rb
|
58
61
|
- lib/pingpp/coupon.rb
|
@@ -89,13 +92,17 @@ files:
|
|
89
92
|
- lib/pingpp/version.rb
|
90
93
|
- lib/pingpp/webhook.rb
|
91
94
|
- lib/pingpp/withdrawal.rb
|
95
|
+
- lib/pingpp/wx_lite_oauth.rb
|
92
96
|
- lib/pingpp/wx_pub_oauth.rb
|
97
|
+
- test/agreement_test.rb
|
93
98
|
- test/balance_bonus_test.rb
|
99
|
+
- test/balance_settlement_test.rb
|
94
100
|
- test/balance_transaction_test.rb
|
95
101
|
- test/balance_transfer_test.rb
|
96
102
|
- test/batch_refund_test.rb
|
97
103
|
- test/batch_transfer_test.rb
|
98
104
|
- test/batch_withdrawal_test.rb
|
105
|
+
- test/card_info_test.rb
|
99
106
|
- test/charge_test.rb
|
100
107
|
- test/coupon_template_test.rb
|
101
108
|
- test/coupon_test.rb
|
@@ -145,14 +152,17 @@ test_files:
|
|
145
152
|
- test/sub_app_test.rb
|
146
153
|
- test/batch_refund_test.rb
|
147
154
|
- test/sub_app_channel_test.rb
|
155
|
+
- test/balance_settlement_test.rb
|
148
156
|
- test/test_data.rb
|
149
157
|
- test/royalty_transaction_test.rb
|
150
158
|
- test/royalty_test.rb
|
151
159
|
- test/charge_test.rb
|
160
|
+
- test/agreement_test.rb
|
152
161
|
- test/balance_bonus_test.rb
|
153
162
|
- test/withdrawal_test.rb
|
154
163
|
- test/coupon_test.rb
|
155
164
|
- test/royalty_settlement_test.rb
|
165
|
+
- test/card_info_test.rb
|
156
166
|
- test/order_test.rb
|
157
167
|
- test/recharge_test.rb
|
158
168
|
- test/settle_account_test.rb
|