cheetahmails 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cheetahmails.rb +12 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4482de1f6b194077ffa0c04adc1ae7c6df46d16f
|
4
|
+
data.tar.gz: ec7ed6338e8c3d762aaea90ba9e902da674cac14
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1444c376da2dcd5855efbcca8fcf24eb729848a95ad1dc16c3d6277672e6b8425b2762a8552ecf6cd21f046993416a0bd915c1b6353a92b52581c1ee70791099
|
7
|
+
data.tar.gz: 19e70f3681f5f3dcd650fe5d4c5990fbf5445d5fd03656e3d50afe7e3eabb5e1b17f6d56c29161ad218bbd76fcfcda12d116d1a1311a72da331616ba96ca5519
|
data/lib/cheetahmails.rb
CHANGED
@@ -12,11 +12,14 @@ module Cheetahmails
|
|
12
12
|
def self.get_token(clear_cache = false)
|
13
13
|
tries ||= 2
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
begin
|
16
|
+
redis = Redis.new(Cheetahmails.configuration.redis)
|
17
|
+
redis.del "cheetahmails_access_token" if clear_cache
|
18
|
+
token = redis.get("cheetahmails_access_token")
|
19
|
+
rescue => error
|
20
|
+
end
|
18
21
|
|
19
|
-
if not token
|
22
|
+
if not token
|
20
23
|
|
21
24
|
faraday = Faraday.new(:url => @base_uri) do |faraday|
|
22
25
|
faraday.request :url_encoded # form-encode POST params
|
@@ -41,8 +44,11 @@ module Cheetahmails
|
|
41
44
|
end
|
42
45
|
|
43
46
|
if token = jsonresponse["access_token"]
|
44
|
-
|
45
|
-
|
47
|
+
begin
|
48
|
+
redis.set("cheetahmails_access_token", token)
|
49
|
+
redis.expire("cheetahmails_access_token", jsonresponse["expires_in"])
|
50
|
+
rescue => error
|
51
|
+
end
|
46
52
|
end
|
47
53
|
|
48
54
|
end
|