codepicnic 0.1.7 → 0.1.8
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/codepicnic/token.rb +31 -0
- data/lib/codepicnic/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58d7b5b6c53176a9bf8dd601ed6ddd72cb2f0791
|
4
|
+
data.tar.gz: a95b8eb875a1abb68e5375d1937527091a0e7a0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6cd6cab62b4d5cea9e5dba5e1546d6397ffee1f6ed9ff89e14be87d75db10086af8ec8ff555d5532eb4b8c13779c96563a0dd16549bd92b02c4e4f31a8e35d6
|
7
|
+
data.tar.gz: fa9df17e250a9f111514d9966f1a8ec56db9cf5a0402ce34f7cb6c90042805908e24ff094bf1b750416c78a10cfca74266910d896e4eba3e3ef6d06a5b79f9c3
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module CodePicnic
|
2
|
+
class Token
|
3
|
+
|
4
|
+
@api_url = "https://codepicnic.com/oauth/token"
|
5
|
+
|
6
|
+
class << self
|
7
|
+
attr_accessor :api_url
|
8
|
+
end
|
9
|
+
|
10
|
+
attr_accessor :created_at, :expires_in, :access_token
|
11
|
+
|
12
|
+
def initialize(client_id, client_secret)
|
13
|
+
puts client_id
|
14
|
+
puts client_secret
|
15
|
+
response = RestClient.post Token.api_url, {
|
16
|
+
grant_type: "client_credentials",
|
17
|
+
client_id: client_id,
|
18
|
+
client_secret: client_secret
|
19
|
+
}
|
20
|
+
|
21
|
+
parsed_response = JSON.parse(response)
|
22
|
+
@access_token = parsed_response["access_token"]
|
23
|
+
@created_at = parsed_response["created_at"].to_i
|
24
|
+
@expires_in = parsed_response["expires_in"].to_i
|
25
|
+
end
|
26
|
+
|
27
|
+
def expired?
|
28
|
+
Time.now.to_i > (@created_at + @expires_in)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/codepicnic/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: codepicnic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alvaro Pereyra
|
@@ -73,6 +73,7 @@ files:
|
|
73
73
|
- lib/codepicnic/api_request.rb
|
74
74
|
- lib/codepicnic/console.rb
|
75
75
|
- lib/codepicnic/request.rb
|
76
|
+
- lib/codepicnic/token.rb
|
76
77
|
- lib/codepicnic/version.rb
|
77
78
|
homepage: https://github.com/codepicnic/codepicnic-ruby
|
78
79
|
licenses:
|