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 +4 -4
- data/lib/adk2/client.rb +8 -4
- data/lib/adk2/version.rb +1 -1
- 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: e8177e10265e335e9316fc295e5449b07025cd21
|
4
|
+
data.tar.gz: ae752dc9e11a830fca930d378dbedafc6595ef6c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17ebeef0cf4d12a5a8973559020fbcb998455f5649506d31fc2caaa3ce3aed9368f8ce1492f38fa5db92bc000f7ded9874e43ec450d005075367045cafef0f32
|
7
|
+
data.tar.gz: ef1a564504290456010201737cb0d47ec19afedc66271b53bc1bdf9835bcd5310c29ee79381b318a2438bbdd0c01135a35beb9ade8c4a28a33393de1e259b342
|
data/lib/adk2/client.rb
CHANGED
@@ -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
|
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' =>
|
34
|
-
'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:
|
59
|
+
params: { fmt: 'json', auth: api_token }.merge(params)
|
56
60
|
)
|
57
61
|
end
|
58
62
|
end
|
data/lib/adk2/version.rb
CHANGED