aitu-wallet 0.0.4 → 0.0.7
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 +59 -4
- 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: 73625eb5b3843fafabe3f7d0661bbfe6c936cd51e1a4cbe85a74c9626ab0d115
|
4
|
+
data.tar.gz: 6a605ff8f90ea30a8b7a4bc0a2201cb93a7625009536747e8e4913adcfe4e73b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec97984e8019754f3ac1ee5c76d56473f038d27d219e23ae6a10ff449cb855717ddf6635295e41705d7ab3a701a19e366659d2474bedb5244f7bda788d7f258f
|
7
|
+
data.tar.gz: 996744165c4c0ffdf37a257a15e469da7504ef33bbfd7bd196f384408b5730516303504e1297e20e39d9769e8449bfa9d2541238c6ae01698b65e6bb00999361
|
data/lib/aitu_wallet/client.rb
CHANGED
@@ -8,27 +8,51 @@ module AituWallet
|
|
8
8
|
BASE_URL = 'https://dev.wallet-web-api.aitupay.kz/api/v1/facade'
|
9
9
|
|
10
10
|
ENDPOINTS = {
|
11
|
-
user: '
|
12
|
-
passport: '
|
13
|
-
service: '
|
11
|
+
user: 'integration/user',
|
12
|
+
passport: 'passport',
|
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
|
-
#
|
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,36 @@ 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) do |request|
|
74
|
+
request.body = body.to_json
|
75
|
+
end
|
76
|
+
|
77
|
+
begin
|
78
|
+
JSON.parse(response.body) if response
|
79
|
+
rescue JSON::ParserError
|
80
|
+
puts "Not JSON body returned"
|
81
|
+
nil
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
# generates GetLinkRequest data for passport link building routines
|
86
|
+
#
|
87
|
+
# @param [String] phone
|
88
|
+
# @param [String] back_url
|
89
|
+
# @return [Hash]
|
90
|
+
def get_link_request_data(phone, back_url)
|
91
|
+
{
|
92
|
+
phone: phone,
|
93
|
+
partnerUrl: back_url,
|
94
|
+
scope: 0
|
95
|
+
}
|
96
|
+
end
|
42
97
|
end
|
43
98
|
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.7
|
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-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|