aitu-wallet 0.0.4 → 0.0.5

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: af33715e0ec523a463b7643e1d6037bcac309f684a4d9496229d23078c675426
4
- data.tar.gz: 55dc24b82c597cd81e507e9a39737bfcb2dd2a46ce5f749016bca6dfe2f4db27
3
+ metadata.gz: 0c86fb8879482891aaa720e0b6674b333ffadcd7be30141971668a0d4bf25ffa
4
+ data.tar.gz: 5f0ea08c0041aaa95e133504f1ea3fe1c5e91c6df53fb760a353c341e3f3ab5e
5
5
  SHA512:
6
- metadata.gz: 68f1bc0ca8b65b06e6e7e3438b793bb227bb8a707280fbd577ce1ce30b80f520c2ef12fc438086781430f0758019002ca5192b101b9b921223dd85f298bc1694
7
- data.tar.gz: abc17bb6c50de26eb6dc2ae7933ce40d52df0ba2ec7a5b7bc1928bf9d1a435977fb85e117ea8853f92c8a43129fc4ad0f537a84a19fc1efec8ca4d6c93a412a7
6
+ metadata.gz: e4386f0c655eb277d3a8669dab0263207e2264601fa56a610049ae39fdb4c3f1ffd92062e79a1bf691ce83f2f10998b63b541d1071c39c5dfa79628d006e223e
7
+ data.tar.gz: a834a403a5266e2f01a8fc8126bc54ba35b40a4c9fa4d56d4c4f0a8f8fcf9c5ae32d43efa70c2c4c14bfa7b83cd8f74417be343dc8e69565b04fe62877e0f183
@@ -12,23 +12,47 @@ module AituWallet
12
12
  passport: '/passport',
13
13
  service: '/ems/service'
14
14
  }
15
+
15
16
  # Client to send Aitu Wallet requests
16
17
  class Client
17
18
  attr_accessor :handler, :auth_headers
18
19
 
19
- # creates connection to Aitu Wallet endpoints and sets basic auth headers
20
+ # Creates connection to Aitu Wallet endpoints and sets basic auth headers
21
+ #
22
+ # @param [String] login
23
+ # @param [String] password
20
24
  def initialize(login, password)
21
25
  @handler = Faraday.new(BASE_URL) do |connection|
22
26
  connection.request :authorization, :basic, login, password
23
27
  end
24
28
  end
25
29
 
30
+ # Gets info about user's account
31
+ #
32
+ # @param [String] phone
33
+ # @return [Hash, NilClass]
26
34
  def get_user_info(phone)
27
35
  get_request(ENDPOINTS[:user] + "/#{phone}")
28
36
  end
29
37
 
38
+ # Builds link to crete Aitu Passport account
39
+ #
40
+ # @param [String] phone
41
+ # @param [String] back_url
42
+ # @return [Hash, NilClass]
43
+ def build_passport_link(phone, back_url)
44
+ post_request(
45
+ ENDPOINTS[:passport],
46
+ get_link_request_data(phone, back_url)
47
+ )
48
+ end
49
+
30
50
  private
31
51
 
52
+ # Executes GET request to specified url
53
+ #
54
+ # @param [String] url
55
+ # @return [NilClass, Hash]
32
56
  def get_request(url)
33
57
  response = @handler.get(url)
34
58
 
@@ -39,5 +63,34 @@ module AituWallet
39
63
  nil
40
64
  end
41
65
  end
66
+
67
+ # Performs POST request to specified URL with specified BODY payload
68
+ #
69
+ # @param [String] url
70
+ # @param [Hash] body
71
+ # @return [Hash, nil]
72
+ def post_request(url, body)
73
+ response = @handler.post(url, body: body)
74
+
75
+ begin
76
+ JSON.parse(response.body) if response
77
+ rescue JSON::ParserError
78
+ puts "Not JSON body returned"
79
+ nil
80
+ end
81
+ end
82
+
83
+ # generates GetLinkRequest data for passport link building routines
84
+ #
85
+ # @param [String] phone
86
+ # @param [String] back_url
87
+ # @return [Hash]
88
+ def get_link_request_data(phone, back_url)
89
+ {
90
+ phone: phone,
91
+ partnerUrl: back_url,
92
+ scope: 0
93
+ }
94
+ end
42
95
  end
43
96
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AituWallet
4
- VERSION = '0.0.4'
4
+ VERSION = '0.0.5'
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.4
4
+ version: 0.0.5
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-27 00:00:00.000000000 Z
11
+ date: 2022-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake