codepicnic 0.1.7 → 0.1.8

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: 1d61063c8c66256efcca66cf3916fa3c3d1b8150
4
- data.tar.gz: 5aac244cc7cbe31d8dea7316805426d831f646cd
3
+ metadata.gz: 58d7b5b6c53176a9bf8dd601ed6ddd72cb2f0791
4
+ data.tar.gz: a95b8eb875a1abb68e5375d1937527091a0e7a0c
5
5
  SHA512:
6
- metadata.gz: 144c391b95c92696f9d1eaf80d955475fb566982cf0ea409ee3abe30a7011e17e8664ce7146490c16d58dffe6558bccf9005e74ccd83703816b0286855c2db23
7
- data.tar.gz: 60f8920907bed1b72f3f9dc68bbfa93584b75974fd2584c57ece7723fd1832a5285180ac8911be895180c1570a1b459a83be65e64903b57a6b5f78c6f47a79f1
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
@@ -1,3 +1,3 @@
1
1
  module CodePicnic
2
- VERSION = "0.1.7"
2
+ VERSION = "0.1.8"
3
3
  end
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.7
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: