wechat-sns 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7a92efbc1fdf7b1a981c97cf0d85bfe256b4bf40
4
- data.tar.gz: 04d5e4501e77a1c55a34d43b7b1e6f243d2cc97b
3
+ metadata.gz: fd7508abf1e7f1b78fac99e0625b09444804919e
4
+ data.tar.gz: 714405df61964939214c2164110d0765ec4cf987
5
5
  SHA512:
6
- metadata.gz: a1f6c63d59de095cb308292e4a51b44e4fb931f44887c00efe07b1b04ca781be77ccad44ecb0f0384993ca939e1ca43208a21de8e6064a36d926550d0c749fa0
7
- data.tar.gz: 398b25ff51baa781c278db2b7eda7eb7de8ee0ca6d6b1cf80494549b6241d847d68b5b7bb7385150471b8aac857fe627e152b1317c559e1e63569c7ba09b8bd6
6
+ metadata.gz: 9c0d04008964562a5fa1985b4da5047c0dccd36f47ba25293ac87ab3af31eb9ee70bf2ff21e95680ad0aa20e3dc7415ca7e7b338d56fff544c45726a2c41d436
7
+ data.tar.gz: 33f041fe075d26897d49bfa1cf6934ddd18fb2316d985139eb94761e177aa8e85b201e19ba54eabe565fe37ecf3f18b63f54dcb3d32a2cc32748b0b6111dda1d
data/CHANGELOG.md CHANGED
@@ -21,3 +21,7 @@
21
21
  2. Improve the Access Token wrapper class for the argument validation & HTTP request
22
22
  3. Improve the Authorize Link class for the argument validation
23
23
  4. Improve the User Profile wrapper class for the argument validation & HTTP request
24
+
25
+ ## v1.0.2
26
+ 1. Improve the Access Token wrapper class for the HTTP request
27
+ 2. Improve the User Profile wrapper class for the HTTP request
data/Gemfile.lock CHANGED
@@ -1,30 +1,42 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- wechat-sns (1.0)
5
- wechat-core (~> 0.3)
4
+ wechat-sns (1.0.1)
5
+ wechat-core (~> 0.4)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- diff-lcs (1.2.5)
11
- httpclient (2.8.0)
10
+ activesupport (5.0.2)
11
+ concurrent-ruby (~> 1.0, >= 1.0.2)
12
+ i18n (~> 0.7)
13
+ minitest (~> 5.1)
14
+ tzinfo (~> 1.1)
15
+ concurrent-ruby (1.0.5)
16
+ diff-lcs (1.3)
17
+ httpclient (2.8.3)
18
+ i18n (0.8.1)
19
+ minitest (5.10.1)
12
20
  rake (10.5.0)
13
- rspec (3.4.0)
14
- rspec-core (~> 3.4.0)
15
- rspec-expectations (~> 3.4.0)
16
- rspec-mocks (~> 3.4.0)
17
- rspec-core (3.4.4)
18
- rspec-support (~> 3.4.0)
19
- rspec-expectations (3.4.0)
21
+ rspec (3.5.0)
22
+ rspec-core (~> 3.5.0)
23
+ rspec-expectations (~> 3.5.0)
24
+ rspec-mocks (~> 3.5.0)
25
+ rspec-core (3.5.4)
26
+ rspec-support (~> 3.5.0)
27
+ rspec-expectations (3.5.0)
20
28
  diff-lcs (>= 1.2.0, < 2.0)
21
- rspec-support (~> 3.4.0)
22
- rspec-mocks (3.4.1)
29
+ rspec-support (~> 3.5.0)
30
+ rspec-mocks (3.5.0)
23
31
  diff-lcs (>= 1.2.0, < 2.0)
24
- rspec-support (~> 3.4.0)
25
- rspec-support (3.4.1)
26
- wechat-core (0.3)
27
- httpclient (~> 2.7)
32
+ rspec-support (~> 3.5.0)
33
+ rspec-support (3.5.0)
34
+ thread_safe (0.3.6)
35
+ tzinfo (1.2.3)
36
+ thread_safe (~> 0.1)
37
+ wechat-core (0.4.1)
38
+ activesupport (>= 4.2)
39
+ httpclient (>= 2.8)
28
40
 
29
41
  PLATFORMS
30
42
  ruby
@@ -36,4 +48,4 @@ DEPENDENCIES
36
48
  wechat-sns!
37
49
 
38
50
  BUNDLED WITH
39
- 1.12.5
51
+ 1.13.6
data/ROADMAP.md CHANGED
@@ -21,3 +21,7 @@
21
21
  2. Improve the Access Token wrapper class for the argument validation & HTTP request
22
22
  3. Improve the Authorize Link class for the argument validation
23
23
  4. Improve the User Profile wrapper class for the argument validation & HTTP request
24
+
25
+ ## v1.0.2
26
+ 1. Improve the Access Token wrapper class for the HTTP request
27
+ 2. Improve the User Profile wrapper class for the HTTP request
@@ -1,9 +1,13 @@
1
1
  require 'jsonclient'
2
2
 
3
+ ##
4
+ # Access Token 是 SNS 统一登录访问令牌的封装类。
5
+ # 不同于 Wechat::Common::AccessToken 。
3
6
  class Wechat::SNS::AccessToken
4
7
 
5
8
  extend Wechat::Core::Common
6
9
 
10
+ ##
7
11
  # 附:检验授权凭证(access_token)是否有效
8
12
  # http://mp.weixin.qq.com/wiki/9/01f711493b5a02f24b04365ac5d8fd95.html#.E9.99.84.EF.BC.9A.E6.A3.80.E9.AA.8C.E6.8E.88.E6.9D.83.E5.87.AD.E8.AF.81.EF.BC.88access_token.EF.BC.89.E6.98.AF.E5.90.A6.E6.9C.89.E6.95.88
9
13
  #
@@ -24,12 +28,11 @@ class Wechat::SNS::AccessToken
24
28
  assert_present! :opend_id, opend_id
25
29
  #raise ArgumentError.new('The access_token argument is required.') if access_token.blank?
26
30
 
27
- message = get_json 'https://api.weixin.qq.com/sns/auth', body:
31
+ get_json 'https://api.weixin.qq.com/sns/auth', body:
28
32
  {
29
33
  access_token: access_token,
30
34
  openid: opend_id
31
35
  }
32
- message.body
33
36
  end
34
37
 
35
38
  # 第三步:刷新access_token(如果需要)
@@ -55,13 +58,12 @@ class Wechat::SNS::AccessToken
55
58
  assert_present! :refresh_token, refresh_token
56
59
  # raise ArgumentError.new('The app_id argument is required.') if app_id.blank?
57
60
 
58
- message = ::JSONClient.new.get 'https://api.weixin.qq.com/sns/oauth2/refresh_token',
61
+ get_json 'https://api.weixin.qq.com/sns/oauth2/refresh_token', body:
59
62
  {
60
63
  appid: app_id,
61
64
  grant_type: 'refresh_token',
62
65
  refresh_token: refresh_token
63
66
  }
64
- message.body
65
67
  end
66
68
 
67
69
  # 第二步:通过code换取网页授权access_token
@@ -84,18 +86,15 @@ class Wechat::SNS::AccessToken
84
86
  # }
85
87
  def self.create(app_id, app_secret, code, grant_type: 'authorization_code')
86
88
 
87
- raise ArgumentError.new('The app_id argument is required.') if app_id.blank?
89
+ assert_present! :app_id, app_id
88
90
 
89
- message = ::JSONClient.new.get 'https://api.weixin.qq.com/sns/oauth2/access_token',
91
+ get_json 'https://api.weixin.qq.com/sns/oauth2/access_token', body:
90
92
  {
91
93
  appid: app_id,
92
94
  secret: app_secret,
93
95
  code: code,
94
96
  grant_type: grant_type
95
97
  }
96
- message.body
97
- #body = message.body
98
- #body.is_a?(Hash) ? body : JSON.parse(body)
99
98
  end
100
99
 
101
100
  end
@@ -1,3 +1,7 @@
1
+ ##
2
+ # Authorize Link 是授权链接类。用于生成授权链接。如:
3
+ # Wechat::SNS::AuthorizeLink.create wechat_app_id, redirect_link
4
+
1
5
  class Wechat::SNS::AuthorizeLink
2
6
 
3
7
  extend Wechat::Core::Common
@@ -6,6 +10,7 @@ class Wechat::SNS::AuthorizeLink
6
10
  SCOPE_BASE = 'snsapi_base'.freeze
7
11
  SCOPE_FULL = 'snsapi_userinfo'.freeze
8
12
 
13
+ ##
9
14
  # 第一步:用户同意授权,获取code
10
15
  # http://mp.weixin.qq.com/wiki/9/01f711493b5a02f24b04365ac5d8fd95.html#.E7.AC.AC.E4.B8.80.E6.AD.A5.EF.BC.9A.E7.94.A8.E6.88.B7.E5.90.8C.E6.84.8F.E6.8E.88.E6.9D.83.EF.BC.8C.E8.8E.B7.E5.8F.96code
11
16
  def self.create(wechat_app_id, redirect_link, response_type: Wechat::SNS::AuthorizeLink::RESPONSE_TYPE_CODE, scope: Wechat::SNS::AuthorizeLink::SCOPE_FULL, state: nil)
@@ -1,9 +1,12 @@
1
- require 'jsonclient'
1
+ ##
2
+ # User Profile 是用户基本信息的封装类。如:
3
+ # Wechat::SNS::UserProfile.load access_token, open_id
2
4
 
3
5
  class Wechat::SNS::UserProfile
4
6
 
5
7
  extend Wechat::Core::Common
6
8
 
9
+ ##
7
10
  # 第四步:拉取用户信息(需scope为 snsapi_userinfo)
8
11
  # http://mp.weixin.qq.com/wiki/9/01f711493b5a02f24b04365ac5d8fd95.html#.E7.AC.AC.E5.9B.9B.E6.AD.A5.EF.BC.9A.E6.8B.89.E5.8F.96.E7.94.A8.E6.88.B7.E4.BF.A1.E6.81.AF.28.E9.9C.80scope.E4.B8.BA_snsapi_userinfo.29
9
12
  #
@@ -29,17 +32,13 @@ class Wechat::SNS::UserProfile
29
32
 
30
33
  assert_present! :access_token, access_token
31
34
  assert_present! :open_id, open_id
32
- #raise ArgumentError.new('The access_token argument is required.') if access_token.blank?
33
35
 
34
- message = get_json 'https://api.weixin.qq.com/sns/userinfo', body:
36
+ get_json 'https://api.weixin.qq.com/sns/userinfo', body:
35
37
  {
36
38
  access_token: access_token,
37
39
  openid: open_id,
38
40
  lang: language
39
41
  }
40
- message.body
41
- #body = message.body
42
- #body.is_a?(Hash) ? body : JSON.parse(body)
43
42
  end
44
43
 
45
44
  end
@@ -1,5 +1,5 @@
1
1
  module Wechat
2
2
  module SNS
3
- VERSION = '1.0.1'.freeze
3
+ VERSION = '1.0.2'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wechat-sns
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Topbit Du
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-02-03 00:00:00.000000000 Z
11
+ date: 2017-03-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler