codepicnic 0.1.6 → 0.1.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ffe3b2bc168ccc173b5873d6ea16ff6d26d86e01
4
- data.tar.gz: b30addb8f8025495d3e9a1a2d9f15fac7c666f93
3
+ metadata.gz: 1d61063c8c66256efcca66cf3916fa3c3d1b8150
4
+ data.tar.gz: 5aac244cc7cbe31d8dea7316805426d831f646cd
5
5
  SHA512:
6
- metadata.gz: b3171536e65baa1883c0b15f9bdf1848668036d60a657af9b85c042905e2c73be03d37a15f22bb8a9482a0b31999173506a481329669f2627a23b9f09e72e4a0
7
- data.tar.gz: 4bf872676ef99468455afddc0f459a00ea982cf20bd512b2b598d3f240f3d8d3a4296a375c83ba9280e98464284047c5d7d354559f45902f468d7dfba9ccff5a
6
+ metadata.gz: 144c391b95c92696f9d1eaf80d955475fb566982cf0ea409ee3abe30a7011e17e8664ce7146490c16d58dffe6558bccf9005e74ccd83703816b0286855c2db23
7
+ data.tar.gz: 60f8920907bed1b72f3f9dc68bbfa93584b75974fd2584c57ece7723fd1832a5285180ac8911be895180c1570a1b459a83be65e64903b57a6b5f78c6f47a79f1
@@ -4,10 +4,6 @@ module CodePicnic
4
4
 
5
5
  @api_url = "https://codepicnic.com/api/consoles"
6
6
 
7
- class << self
8
- attr_accessor :api_url
9
- end
10
-
11
7
  attr_accessor :id, :name, :container_name, :container_type, :custom_image, :created_at, :permalink, :url, :is_headless
12
8
 
13
9
  def initialize(opts={})
@@ -1,3 +1,3 @@
1
1
  module CodePicnic
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
data/lib/codepicnic.rb CHANGED
@@ -1,19 +1,20 @@
1
1
  require 'json'
2
2
  require 'rest_client'
3
3
  require 'codepicnic/api_request'
4
+ require 'codepicnic/token'
4
5
  require 'codepicnic/request'
5
6
  require 'codepicnic/console'
6
7
  require 'codepicnic/version'
7
8
 
8
9
  module CodePicnic
9
10
 
10
- @api_url = "https://codepicnic.com/oauth/token"
11
-
12
11
  class << self
13
- attr_accessor :api_url, :client_id, :client_secret, :token
12
+ attr_accessor :client_id, :client_secret, :token
14
13
 
15
14
  def token
16
15
  @token ||= get_token
16
+ refresh_token if @token.expired?
17
+ @token.access_token
17
18
  end
18
19
 
19
20
  def refresh_token
@@ -21,12 +22,7 @@ module CodePicnic
21
22
  end
22
23
 
23
24
  def get_token
24
- response = RestClient.post @api_url, {
25
- grant_type: "client_credentials",
26
- client_id: @client_id,
27
- client_secret: @client_secret
28
- }
29
- JSON.parse(response)["access_token"]
25
+ Token.new(@client_id, @client_secret)
30
26
  end
31
27
 
32
28
  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.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alvaro Pereyra