aitu-wallet 0.0.1 → 0.0.4

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: ecfa5b4671d6fc4c43db44251699f9a9baf3de1245545113bf81df99914581e7
4
- data.tar.gz: 96b53f074d5acc3c88611aeb63ff3a973ce469c5fe63cddbb6b7c59e4ea21896
3
+ metadata.gz: af33715e0ec523a463b7643e1d6037bcac309f684a4d9496229d23078c675426
4
+ data.tar.gz: 55dc24b82c597cd81e507e9a39737bfcb2dd2a46ce5f749016bca6dfe2f4db27
5
5
  SHA512:
6
- metadata.gz: f1ccf7939129b972f3e09ee5699efdd7e5797b94cc27980ebd498794b01fb50194b68030d5a2478af8b821784204557ab80cfb17a0ef6bb7b9f95a193386559e
7
- data.tar.gz: dbd79b7c86ee923f584c09fa5f64df6aa5bca69ddc8599b4bcc9d33c001b6ba8d4bece3228c8e19e720a9bc9b91a7af94c2a0a1550449bb97b6cf49beeaeeb64
6
+ metadata.gz: 68f1bc0ca8b65b06e6e7e3438b793bb227bb8a707280fbd577ce1ce30b80f520c2ef12fc438086781430f0758019002ca5192b101b9b921223dd85f298bc1694
7
+ data.tar.gz: abc17bb6c50de26eb6dc2ae7933ce40d52df0ba2ec7a5b7bc1928bf9d1a435977fb85e117ea8853f92c8a43129fc4ad0f537a84a19fc1efec8ca4d6c93a412a7
@@ -14,25 +14,30 @@ module AituWallet
14
14
  }
15
15
  # Client to send Aitu Wallet requests
16
16
  class Client
17
- attr_accessor :handler, :headers
17
+ attr_accessor :handler, :auth_headers
18
18
 
19
- def initialize(auth_token)
20
- @handler = Faraday.new
21
- @headers = { 'Authorization': "Basic #{auth_token}" }
19
+ # creates connection to Aitu Wallet endpoints and sets basic auth headers
20
+ def initialize(login, password)
21
+ @handler = Faraday.new(BASE_URL) do |connection|
22
+ connection.request :authorization, :basic, login, password
23
+ end
22
24
  end
23
25
 
24
26
  def get_user_info(phone)
25
- url = build_request_url(:user) + "/#{phone}"
26
- response = @handler.get(url: url, headers: @headers)
27
- JSON.parse(response) if response
27
+ get_request(ENDPOINTS[:user] + "/#{phone}")
28
28
  end
29
29
 
30
30
  private
31
31
 
32
- def build_request_url(endpoint)
33
- raise StandardError, "No such endpoint: #{endpoint}" unless ENDPOINTS[endpoint]
32
+ def get_request(url)
33
+ response = @handler.get(url)
34
34
 
35
- BASE_URL + ENDPOINTS[endpoint]
35
+ begin
36
+ JSON.parse(response.body) if response
37
+ rescue JSON::ParserError
38
+ puts "Not JSON body returned"
39
+ nil
40
+ end
36
41
  end
37
42
  end
38
43
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AituWallet
4
- VERSION = '0.0.1'
4
+ VERSION = '0.0.4'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aitu-wallet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yaroslav Shevchenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-25 00:00:00.000000000 Z
11
+ date: 2022-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake