aitu-wallet 0.0.2 → 0.0.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: 7c2c064589dc9130d7efb2d4329766c8759abce83f9f038dd942f7cbfaa23898
4
- data.tar.gz: 14ec7ef585fee3ec24ee6740f4d3dc3e919a7bb223e90c24766b7e52bc791341
3
+ metadata.gz: 50f56be2eb2c5b736bfcf67261c4116162fa34dd421ac6bed2845d319010005d
4
+ data.tar.gz: 7808f737f9fca6d7dfb8aa5b06ba0daf5c21571154555f319f99e6c8b21d923d
5
5
  SHA512:
6
- metadata.gz: 014a02cdefad449074e47c4d2f401bc1c73d99a007277846611ab528e4c0b1a61dcb2fc74881555ba30ea78bfe2afc3bab47093c784306554db07080940d5c16
7
- data.tar.gz: a635643c35a042c022d92dd6ae7a65fd0f9768ceeb61e59abe77028aae46e93c397dd3dadb26dd058fe81ce8312f19100f16f605aefd4de740e8de4f054203c0
6
+ metadata.gz: 917169696555a3d7e3301e77dfe5347b6cb071f27be0b19b7a269bc2ee0a287de52eabcb4b94a61e0f5bcdcdaa30ebc4727f961db0758a0d23fb94862ef41b7f
7
+ data.tar.gz: 69695e6dfb8582baff1521f05d95919ef246d54c82a750b31535574116228e9226af99750fd3acbf866e912a0453f56810d624eaddeb3afd667a6ca62f152381
@@ -14,25 +14,29 @@ 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)
22
+ @handler.basic_auth(login, password)
22
23
  end
23
24
 
24
25
  def get_user_info(phone)
25
- url = build_request_url(:user) + "/#{phone}"
26
- response = @handler.get(url, headers: @headers)
27
- JSON.parse(response) if response
26
+ get_request(ENDPOINTS[:user] + "/#{phone}")
28
27
  end
29
28
 
30
29
  private
31
30
 
32
- def build_request_url(endpoint)
33
- raise StandardError, "No such endpoint: #{endpoint}" unless ENDPOINTS[endpoint]
31
+ def get_request(url)
32
+ response = @handler.get(url)
34
33
 
35
- BASE_URL + ENDPOINTS[endpoint]
34
+ begin
35
+ JSON.parse(response.body) if response
36
+ rescue JSON::ParserError
37
+ puts "Not JSON body returned"
38
+ nil
39
+ end
36
40
  end
37
41
  end
38
42
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AituWallet
4
- VERSION = '0.0.2'
4
+ VERSION = '0.0.3'
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.2
4
+ version: 0.0.3
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