bitzlato 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/exe/bitzlato-cli +4 -9
- data/lib/bitzlato.rb +1 -2
- data/lib/bitzlato/client.rb +3 -1
- data/lib/bitzlato/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52ac8eed7ada8363c97899f1c8919916150c7647cebcc42be4c5156b84e51c39
|
4
|
+
data.tar.gz: 85f143d37881b374f5c7ba20ffa617c43ba256cbb337319924e583ebfcb4adde
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a640a87353032fb04d49dd597621fd41bec3fe067eaf58fc4839a30ad106a504efc7acbdf8cd954460edc5b1cb0fae02744b67651aa73b91d050f76d75b685ce
|
7
|
+
data.tar.gz: 62feabf34dca0199eb56b3f79fa65a8f836660d7b89fd9c7e194f2d9c410f76c45bd12f268207dc4966a70cf26c0557e6f410159ee904108e7f36591d929455c
|
data/Gemfile.lock
CHANGED
data/exe/bitzlato-cli
CHANGED
@@ -1,10 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
require 'rubygems'
|
3
|
-
require 'bundler/setup'
|
4
2
|
|
5
|
-
|
6
|
-
|
7
|
-
require 'bitzlato/client'
|
3
|
+
require 'bitzlato'
|
8
4
|
|
9
5
|
key = JSON.parse(ENV.fetch('BITZLATO_API_KEY')).transform_keys(&:to_sym)
|
10
6
|
|
@@ -12,12 +8,11 @@ client = Bitzlato::Client
|
|
12
8
|
.new(home_url: ENV.fetch('BITZLATO_API_URL'), key: key, uid: ENV.fetch('BITZLATO_API_CLIENT_UID').to_i, logger: ENV.key?('BITZLATO_API_LOGGER'))
|
13
9
|
|
14
10
|
if ARGV.length == 1
|
15
|
-
puts client.get ARGV[0] || '/api/auth/whoami'
|
11
|
+
puts JSON.pretty_generate(client.get ARGV[0] || '/api/auth/whoami')
|
16
12
|
elsif ARGV.length == 2
|
17
|
-
puts client.send(ARGV[0], ARGV[1])
|
13
|
+
puts JSON.pretty_generate(client.send(ARGV[0], ARGV[1]))
|
18
14
|
elsif ARGV.length == 3
|
19
|
-
puts client.send(ARGV[0], ARGV[1], JSON.parse(ARGV[2]))
|
15
|
+
puts JSON.pretty_generate(client.send(ARGV[0], ARGV[1], JSON.parse(ARGV[2])))
|
20
16
|
else
|
21
17
|
puts "Run example: #{$0} get /api/auth/whoami"
|
22
18
|
end
|
23
|
-
|
data/lib/bitzlato.rb
CHANGED
data/lib/bitzlato/client.rb
CHANGED
@@ -8,13 +8,14 @@ module Bitzlato
|
|
8
8
|
class Client
|
9
9
|
WrongResponse = Class.new Error
|
10
10
|
|
11
|
-
def initialize(home_url: , key: , logger: false, email: nil, uid: nil)
|
11
|
+
def initialize(home_url: , key: , logger: false, email: nil, uid: nil, adapter: nil)
|
12
12
|
raise ArgumentError, 'email or uid must be presented' if uid.nil? && email.nil?
|
13
13
|
@email = email
|
14
14
|
@uid = uid
|
15
15
|
@jwk = JWT::JWK.import key
|
16
16
|
@home_url = home_url
|
17
17
|
@logger = logger
|
18
|
+
@adapter = adapter || Faraday.default_adapter
|
18
19
|
end
|
19
20
|
|
20
21
|
def get(path, params = {})
|
@@ -52,6 +53,7 @@ module Bitzlato
|
|
52
53
|
'Accept' => 'application/json'
|
53
54
|
}
|
54
55
|
c.authorization :Bearer, bearer
|
56
|
+
c.adapter @adapter
|
55
57
|
end
|
56
58
|
end
|
57
59
|
|
data/lib/bitzlato/version.rb
CHANGED