wework 0.1.4 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/wework.rb +2 -2
- data/lib/wework/api/base.rb +4 -0
- data/lib/wework/js_ticket/redis_store.rb +11 -9
- data/lib/wework/token/redis_store.rb +10 -9
- data/lib/wework/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 714896d468c99ed325dfa1b8e94afd4ad6de85a8
|
4
|
+
data.tar.gz: ca5b3a044abd35673167c57033e8efbc554b8cb5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efe9dabd28e852f5082311c9116cfef327d36f007a2c3bd17c47f03b5df57e0cd6c16e21245c81ee640293923a63c0ce3f47a5e57321f071bf0a01315ca85ea4
|
7
|
+
data.tar.gz: 02e82e258a1b8be84959777890007f5d29051093eadc5bb53bc108fffab60eb65503d1314e6233c3686885e81de33af7213a863a0b52d8721c961d3c6d1cf990
|
data/lib/wework.rb
CHANGED
@@ -13,8 +13,8 @@ require 'wework/api/contact'
|
|
13
13
|
module Wework
|
14
14
|
API_ENDPOINT = 'https://qyapi.weixin.qq.com/cgi-bin/'.freeze
|
15
15
|
AUTHORIZE_ENDPOINT = 'https://open.weixin.qq.com/connect/oauth2/authorize'.freeze
|
16
|
-
ACCESS_TOKEN_PREFIX = '
|
17
|
-
JSAPI_TOKEN_PREFIX = '
|
16
|
+
ACCESS_TOKEN_PREFIX = 'WX_TOKEN'.freeze
|
17
|
+
JSAPI_TOKEN_PREFIX = 'WX_JST'.freeze
|
18
18
|
CONTACT_AGENT_ID = 'CONTACT'.freeze
|
19
19
|
HTTP_OK_STATUS = [200, 201].freeze
|
20
20
|
SUCCESS_CODE = 0
|
data/lib/wework/api/base.rb
CHANGED
@@ -26,6 +26,10 @@ module Wework
|
|
26
26
|
@request ||= Wework::Request.new(API_ENDPOINT, false)
|
27
27
|
end
|
28
28
|
|
29
|
+
def valid?
|
30
|
+
access_token.present?
|
31
|
+
end
|
32
|
+
|
29
33
|
def get(path, headers = {})
|
30
34
|
with_access_token(headers[:params]) do |params|
|
31
35
|
request.get path, headers.merge(params: params)
|
@@ -9,7 +9,7 @@ module Wework
|
|
9
9
|
|
10
10
|
def jsapi_ticket
|
11
11
|
super
|
12
|
-
redis.hget(key, "
|
12
|
+
redis.hget(key, "ticket")
|
13
13
|
end
|
14
14
|
|
15
15
|
def expired?
|
@@ -18,14 +18,16 @@ module Wework
|
|
18
18
|
|
19
19
|
def refresh_token
|
20
20
|
result = super
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
21
|
+
if result.success?
|
22
|
+
expires_at = Time.now.to_i + result.expires_in.to_i - 100
|
23
|
+
redis.hmset(
|
24
|
+
key,
|
25
|
+
"ticket", result.ticket,
|
26
|
+
"expires_at", expires_at
|
27
|
+
)
|
28
|
+
|
29
|
+
redis.expireat(key, expires_at)
|
30
|
+
end
|
29
31
|
end
|
30
32
|
|
31
33
|
private
|
@@ -18,15 +18,16 @@ module Wework
|
|
18
18
|
|
19
19
|
def refresh_token
|
20
20
|
result = super
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
21
|
+
if result.success?
|
22
|
+
expires_at = Time.now.to_i + result.expires_in.to_i - 100
|
23
|
+
redis.hmset(
|
24
|
+
key,
|
25
|
+
"access_token", result.access_token,
|
26
|
+
"expires_at", expires_at
|
27
|
+
)
|
28
|
+
|
29
|
+
redis.expireat(key, expires_at)
|
30
|
+
end
|
30
31
|
end
|
31
32
|
|
32
33
|
private
|
data/lib/wework/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wework
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- seandong
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http
|