adk2 0.0.5 → 0.0.6

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: c27e223244b8424eccd608cf2255784b58a43bc7
4
- data.tar.gz: 07dc4daa2a8a478b58a765f0e591c3fe94e8a258
3
+ metadata.gz: e8177e10265e335e9316fc295e5449b07025cd21
4
+ data.tar.gz: ae752dc9e11a830fca930d378dbedafc6595ef6c
5
5
  SHA512:
6
- metadata.gz: 10c851123b45fb3826254a685a3b63aecd0c9d1f856b8a99fc36ed95b9c225e762c9168c1f640e1bf4449d0baf1f6f560619f5454d3d8e8cee7ce5c74b653f1e
7
- data.tar.gz: 907aab5bd7809f6107283cb94b7af071571366a6bbdd92c67d4ad624d014cdcea9b1a9c24d802d0ea9279dfe9debedcf0a60552a5690c0c96a023bd1d492675a
6
+ metadata.gz: 17ebeef0cf4d12a5a8973559020fbcb998455f5649506d31fc2caaa3ce3aed9368f8ce1492f38fa5db92bc000f7ded9874e43ec450d005075367045cafef0f32
7
+ data.tar.gz: ef1a564504290456010201737cb0d47ec19afedc66271b53bc1bdf9835bcd5310c29ee79381b318a2438bbdd0c01135a35beb9ade8c4a28a33393de1e259b342
@@ -5,6 +5,8 @@ require 'retryable'
5
5
 
6
6
  module Adk2
7
7
  class Client
8
+ attr_reader :api_token, :username, :password
9
+
8
10
  def initialize(network_name, opts = {})
9
11
  @api_base_url = "https://#{network_name}.adk2.com"
10
12
  @username = opts[:username]
@@ -26,12 +28,12 @@ module Adk2
26
28
  end
27
29
 
28
30
  def get_api_token
29
- return @api_token = nil if @username.nil? || @password.nil?
31
+ return @api_token = nil if username.nil? || password.nil?
30
32
  response = RestClient.post(
31
33
  api_base_url + '/auth',
32
34
  {
33
- 'email' => @username,
34
- 'password' => @password
35
+ 'email' => username,
36
+ 'password' => password
35
37
  }.to_json
36
38
  )
37
39
 
@@ -47,12 +49,14 @@ module Adk2
47
49
  attr_reader :api_base_url, :api_token
48
50
 
49
51
  def http_get(path, params = {})
52
+ get_api_token if api_token.nil?
53
+
50
54
  Retryable.retryable(tries: 2, on: RestClient::Forbidden) do |_, exception|
51
55
  get_api_token if exception
52
56
 
53
57
  RestClient.get(
54
58
  "#{api_base_url}/denver/#{path}",
55
- params: { fmt: 'json', auth: @api_token }.merge(params)
59
+ params: { fmt: 'json', auth: api_token }.merge(params)
56
60
  )
57
61
  end
58
62
  end
@@ -1,3 +1,3 @@
1
1
  module Adk2
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.6'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adk2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - ad2games GmbH