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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: af33715e0ec523a463b7643e1d6037bcac309f684a4d9496229d23078c675426
4
- data.tar.gz: 55dc24b82c597cd81e507e9a39737bfcb2dd2a46ce5f749016bca6dfe2f4db27
3
+ metadata.gz: 73625eb5b3843fafabe3f7d0661bbfe6c936cd51e1a4cbe85a74c9626ab0d115
4
+ data.tar.gz: 6a605ff8f90ea30a8b7a4bc0a2201cb93a7625009536747e8e4913adcfe4e73b
5
5
  SHA512:
6
- metadata.gz: 68f1bc0ca8b65b06e6e7e3438b793bb227bb8a707280fbd577ce1ce30b80f520c2ef12fc438086781430f0758019002ca5192b101b9b921223dd85f298bc1694
7
- data.tar.gz: abc17bb6c50de26eb6dc2ae7933ce40d52df0ba2ec7a5b7bc1928bf9d1a435977fb85e117ea8853f92c8a43129fc4ad0f537a84a19fc1efec8ca4d6c93a412a7
6
+ metadata.gz: ec97984e8019754f3ac1ee5c76d56473f038d27d219e23ae6a10ff449cb855717ddf6635295e41705d7ab3a701a19e366659d2474bedb5244f7bda788d7f258f
7
+ data.tar.gz: 996744165c4c0ffdf37a257a15e469da7504ef33bbfd7bd196f384408b5730516303504e1297e20e39d9769e8449bfa9d2541238c6ae01698b65e6bb00999361
@@ -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: '/integration/user',
12
- passport: '/passport',
13
- service: '/ems/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
- # 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,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
@@ -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.7'
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.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-27 00:00:00.000000000 Z
11
+ date: 2022-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake