aitu-wallet 0.0.2 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/aitu_wallet/client.rb +68 -10
- data/lib/aitu_wallet/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c86fb8879482891aaa720e0b6674b333ffadcd7be30141971668a0d4bf25ffa
|
4
|
+
data.tar.gz: 5f0ea08c0041aaa95e133504f1ea3fe1c5e91c6df53fb760a353c341e3f3ab5e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4386f0c655eb277d3a8669dab0263207e2264601fa56a610049ae39fdb4c3f1ffd92062e79a1bf691ce83f2f10998b63b541d1071c39c5dfa79628d006e223e
|
7
|
+
data.tar.gz: a834a403a5266e2f01a8fc8126bc54ba35b40a4c9fa4d56d4c4f0a8f8fcf9c5ae32d43efa70c2c4c14bfa7b83cd8f74417be343dc8e69565b04fe62877e0f183
|
data/lib/aitu_wallet/client.rb
CHANGED
@@ -12,27 +12,85 @@ 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
|
-
attr_accessor :handler, :
|
18
|
+
attr_accessor :handler, :auth_headers
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
20
|
+
# Creates connection to Aitu Wallet endpoints and sets basic auth headers
|
21
|
+
#
|
22
|
+
# @param [String] login
|
23
|
+
# @param [String] password
|
24
|
+
def initialize(login, password)
|
25
|
+
@handler = Faraday.new(BASE_URL) do |connection|
|
26
|
+
connection.request :authorization, :basic, login, password
|
27
|
+
end
|
22
28
|
end
|
23
29
|
|
30
|
+
# Gets info about user's account
|
31
|
+
#
|
32
|
+
# @param [String] phone
|
33
|
+
# @return [Hash, NilClass]
|
24
34
|
def get_user_info(phone)
|
25
|
-
|
26
|
-
|
27
|
-
|
35
|
+
get_request(ENDPOINTS[:user] + "/#{phone}")
|
36
|
+
end
|
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
|
+
)
|
28
48
|
end
|
29
49
|
|
30
50
|
private
|
31
51
|
|
32
|
-
|
33
|
-
|
52
|
+
# Executes GET request to specified url
|
53
|
+
#
|
54
|
+
# @param [String] url
|
55
|
+
# @return [NilClass, Hash]
|
56
|
+
def get_request(url)
|
57
|
+
response = @handler.get(url)
|
58
|
+
|
59
|
+
begin
|
60
|
+
JSON.parse(response.body) if response
|
61
|
+
rescue JSON::ParserError
|
62
|
+
puts "Not JSON body returned"
|
63
|
+
nil
|
64
|
+
end
|
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
|
34
82
|
|
35
|
-
|
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
|
+
}
|
36
94
|
end
|
37
95
|
end
|
38
96
|
end
|
data/lib/aitu_wallet/version.rb
CHANGED
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
|
+
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-
|
11
|
+
date: 2022-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|