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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 26408b56dadbb4cca23a9227bde63308729f7393c35adb982d5d83b8fe97f4d3
4
- data.tar.gz: 02bc9776579bd77f49d6fc92dd9d086b8e4430503d53f486e97ae629d12f9951
3
+ metadata.gz: 52ac8eed7ada8363c97899f1c8919916150c7647cebcc42be4c5156b84e51c39
4
+ data.tar.gz: 85f143d37881b374f5c7ba20ffa617c43ba256cbb337319924e583ebfcb4adde
5
5
  SHA512:
6
- metadata.gz: 8ec6dce0334d287c64cffb23ada0de56fa932b449203301023262e2f7447e142e1994ed75ad0df253938fc760e49b837571b538f2ae04e0b283b5ab5af145b10
7
- data.tar.gz: 771a02c15844d6d592fa4450ebf14d61f1f2cde83be62e9624ef016cefd2fe203e148eec497cf415692f9c7dbc29290aaf99cee1d1d9089f93a17d744826bd08
6
+ metadata.gz: a640a87353032fb04d49dd597621fd41bec3fe067eaf58fc4839a30ad106a504efc7acbdf8cd954460edc5b1cb0fae02744b67651aa73b91d050f76d75b685ce
7
+ data.tar.gz: 62feabf34dca0199eb56b3f79fa65a8f836660d7b89fd9c7e194f2d9c410f76c45bd12f268207dc4966a70cf26c0557e6f410159ee904108e7f36591d929455c
data/Gemfile.lock CHANGED
@@ -7,7 +7,7 @@ GIT
7
7
  PATH
8
8
  remote: .
9
9
  specs:
10
- bitzlato (0.1.2)
10
+ bitzlato (0.1.3)
11
11
  faraday (>= 0.17)
12
12
  json (~> 2.0)
13
13
  jwt (~> 2.3.0.dev)
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
- Bundler.require(:default)
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
@@ -1,7 +1,6 @@
1
1
  require "bitzlato/version"
2
- require "bitzlato/client"
3
2
 
4
3
  module Bitzlato
5
4
  class Error < StandardError; end
6
- # Your code goes here...
5
+ require "bitzlato/client"
7
6
  end
@@ -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
 
@@ -1,3 +1,3 @@
1
1
  module Bitzlato
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bitzlato
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danil Pismenny