bitzlato 0.1.3 → 0.1.5

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
  SHA256:
3
- metadata.gz: 52ac8eed7ada8363c97899f1c8919916150c7647cebcc42be4c5156b84e51c39
4
- data.tar.gz: 85f143d37881b374f5c7ba20ffa617c43ba256cbb337319924e583ebfcb4adde
3
+ metadata.gz: d91921f4c6bbdeb0a48fd99aa9e089a7e66b303bcbfc21ec8877d34457eab6f3
4
+ data.tar.gz: deea11939ca45bd761f0c63262db5bf5b3e5d29678b8ac7bb9068257942fb26f
5
5
  SHA512:
6
- metadata.gz: a640a87353032fb04d49dd597621fd41bec3fe067eaf58fc4839a30ad106a504efc7acbdf8cd954460edc5b1cb0fae02744b67651aa73b91d050f76d75b685ce
7
- data.tar.gz: 62feabf34dca0199eb56b3f79fa65a8f836660d7b89fd9c7e194f2d9c410f76c45bd12f268207dc4966a70cf26c0557e6f410159ee904108e7f36591d929455c
6
+ metadata.gz: 885eeaa0e95d6e36ec4aefe7fde2bae4011601ec6fcbf26156b3eed2059613e63e2ff6d1a2feea093b53713b4b759d665bda7a3bdb6b96568c8996be1ec26ee5
7
+ data.tar.gz: 6ecc9ce0d74cca0fa0673146bb50ec80604ee9f61b0aa69f979220cab89b23ba4fa5db93bf8ed3758878360ed2f21c7a04d251405069e3cfd3e40dd36c543d63
data/Gemfile.lock CHANGED
@@ -7,7 +7,7 @@ GIT
7
7
  PATH
8
8
  remote: .
9
9
  specs:
10
- bitzlato (0.1.3)
10
+ bitzlato (0.1.5)
11
11
  faraday (>= 0.17)
12
12
  json (~> 2.0)
13
13
  jwt (~> 2.3.0.dev)
data/exe/bitzlato-cli CHANGED
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ require 'rubygems'
4
+ require 'bundler/setup'
3
5
  require 'bitzlato'
4
6
 
5
7
  key = JSON.parse(ENV.fetch('BITZLATO_API_KEY')).transform_keys(&:to_sym)
@@ -10,9 +12,11 @@ client = Bitzlato::Client
10
12
  if ARGV.length == 1
11
13
  puts JSON.pretty_generate(client.get ARGV[0] || '/api/auth/whoami')
12
14
  elsif ARGV.length == 2
13
- puts JSON.pretty_generate(client.send(ARGV[0], ARGV[1]))
15
+ puts JSON.pretty_generate(client.send(ARGV[0].downcase, ARGV[1]))
14
16
  elsif ARGV.length == 3
15
- puts JSON.pretty_generate(client.send(ARGV[0], ARGV[1], JSON.parse(ARGV[2])))
17
+ puts JSON.pretty_generate(client.send(ARGV[0].downcase, ARGV[1], JSON.parse(ARGV[2])))
16
18
  else
17
- puts "Run example: #{$0} get /api/auth/whoami"
19
+ puts "bitzlato-cli v#{Bitzlato::VERSION}"
20
+ puts "Usage: bitzlato-cli [get/post] PATH [PARAMS]"
21
+ puts "Example: bitzlato-cli get /api/auth/whoami"
18
22
  end
data/lib/bitzlato.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  require "bitzlato/version"
2
2
 
3
3
  module Bitzlato
4
- class Error < StandardError; end
5
4
  require "bitzlato/client"
6
5
  end
@@ -6,6 +6,7 @@ require 'bitzlato'
6
6
 
7
7
  module Bitzlato
8
8
  class Client
9
+ class Error < StandardError; end
9
10
  WrongResponse = Class.new Error
10
11
 
11
12
  def initialize(home_url: , key: , logger: false, email: nil, uid: nil, adapter: nil)
@@ -14,8 +15,12 @@ module Bitzlato
14
15
  @uid = uid
15
16
  @jwk = JWT::JWK.import key
16
17
  @home_url = home_url
17
- @logger = logger
18
18
  @adapter = adapter || Faraday.default_adapter
19
+ if logger == true
20
+ @logger = Faraday::Response::Logger.new(STDOUT)
21
+ else
22
+ @logger = logger
23
+ end
19
24
  end
20
25
 
21
26
  def get(path, params = {})
@@ -30,7 +35,7 @@ module Bitzlato
30
35
 
31
36
  def parse_response(response)
32
37
  raise WrongResponse, "Wrong response status (#{response.status})" unless response.success?
33
- raise WrongResponse, "Wrong content type (#{response['content-type']})" unless response['content-type'] == 'application/json'
38
+ raise WrongResponse, "Wrong content type (#{response['content-type']})" if !response.body.blank? && response['content-type'] != 'application/json'
34
39
  JSON.parse response.body
35
40
  end
36
41
 
@@ -47,11 +52,12 @@ module Bitzlato
47
52
 
48
53
  def connection
49
54
  @connection ||= Faraday.new url: @home_url do |c|
50
- c.use Faraday::Response::Logger if @logger
55
+ c.use Faraday::Response::Logger unless @logger.nil?
51
56
  c.headers = {
52
57
  'Content-Type' => 'application/json',
53
58
  'Accept' => 'application/json'
54
59
  }
60
+ c.request :curl, logger, :warn if ENV['BITZLATO_CURL_LOGGER']
55
61
  c.authorization :Bearer, bearer
56
62
  c.adapter @adapter
57
63
  end
@@ -1,3 +1,3 @@
1
1
  module Bitzlato
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bitzlato
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danil Pismenny
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-10 00:00:00.000000000 Z
11
+ date: 2021-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday