tazapay 0.1.1 → 0.1.2

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: b977bb2c645361ecfec78c427b2c225e81cc0a23d0f9075558d57d4549b43ba4
4
- data.tar.gz: 8d2eff6f8f83b4e199c77b5ec5dd0c2d4eb13645626782fc65f4d8bd6fb37a87
3
+ metadata.gz: 11df37a78614be73791738660b0c7b8c449101ea8e920bfff7b30b0f5e752a03
4
+ data.tar.gz: 2f72d20bdc2498e817e3d7a2e4e202fc5e97c164f106b4c5fdbb639ab8a53bf1
5
5
  SHA512:
6
- metadata.gz: 2ee04358c3e84821b6262f38a7a1fd1ceab05885de7a0488f41e78f2a0979cc4be61e465f88d9759fec82b6b20421aa3f3f2fb97e5a08bd420617591ae6eb6c7
7
- data.tar.gz: 10c190ff09e1d965c345a4d2f58c807196be14c4baee8a874c96c56c06fe6bfd8508831f717dbcbd3fbe3bb5ab5d4ae5dbad5f77decafc479e33826ee30965e6
6
+ metadata.gz: 12ab6bdad83dc4f993114f82d152da5683a0c8f20153e71e0fbfdc5b6baebca426dbb2e27fcba7cb006f18803e78e0f924c82fc4c50005c456ee99815730d3e4
7
+ data.tar.gz: 2e3b49a30e61533b7ecf4ca7c43f47b2aefb5a0213c939e9e4d5ffe9cd55182b7eb76c39ca8108c36d1861aff5acd49209fab4f573a4e0bae698da972934ff30
data/CHANGELOG.md CHANGED
@@ -3,3 +3,15 @@
3
3
  ## [0.1.0] - 2023-02-23
4
4
 
5
5
  - Initial release
6
+ - Add Checkout API
7
+
8
+
9
+ ## [0.1.1] - 2023-02-24
10
+
11
+ - Add User API
12
+
13
+
14
+ ## [0.1.2] - 2023-02-25
15
+
16
+ - Add Bank API
17
+
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tazapay (0.1.1)
4
+ tazapay (0.1.2)
5
5
  faraday (~> 1.0)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -44,6 +44,67 @@ data = tazapay_checkout.get_status(tx_number)
44
44
 
45
45
  ```
46
46
 
47
+ ### User
48
+
49
+ ```ruby
50
+
51
+ tazapay_user = Tazapay::User.new
52
+
53
+ data = {
54
+ email: "sometest+12@mail.io",
55
+ country: "SG",
56
+ ind_bus_type: "Business",
57
+ business_name: "TEST SANDBOX",
58
+ contact_code: "+65",
59
+ contact_number: "9999999999",
60
+ partners_customer_id: "test-123"
61
+ }
62
+
63
+ # Create user
64
+ user_id = tazapay_user.create(data)["data"]["account_id"]
65
+
66
+ # Update user
67
+ tazapay_user.update(user_id, new_data)
68
+
69
+ # Find user by ID
70
+ tazapay_user.find(user_id)
71
+
72
+ # Find user by Email
73
+ tazapay_user.find(email)
74
+
75
+ ```
76
+
77
+ See more details in tests
78
+
79
+ ### Bank
80
+
81
+ ```ruby
82
+
83
+ tazapay_bank = Tazapay::Bank.new
84
+
85
+ data = {
86
+ email: "sometest+12@mail.io",
87
+ country: "SG",
88
+ ind_bus_type: "Business",
89
+ business_name: "TEST SANDBOX",
90
+ contact_code: "+65",
91
+ contact_number: "9999999999",
92
+ partners_customer_id: "test-123"
93
+ }
94
+
95
+ # Add bank account
96
+ bank_id = tazapay_bank.add(
97
+ account_id: user_id, bank_data: new_data
98
+ )['data']['bank_id']
99
+
100
+ # List user banks
101
+ tazapay_bank.list(user_id)
102
+
103
+ # Make bank account primary
104
+ tazapay_bank.make_primary(bank_id: bank_id, account_id: user_id)
105
+
106
+ ```
107
+
47
108
  See more details in tests
48
109
 
49
110
 
@@ -55,7 +116,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
55
116
 
56
117
  ## Contributing
57
118
 
58
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/tazapay. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/tazapay/blob/main/CODE_OF_CONDUCT.md).
119
+ Bug reports and pull requests are welcome on GitHub at https://github.com/lxkuz/tazapay. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/tazapay/blob/main/CODE_OF_CONDUCT.md).
59
120
 
60
121
  ## License
61
122
 
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Implementation of the MTN API remittances client
4
+
5
+ require "tazapay/config"
6
+ require "tazapay/client"
7
+
8
+ module Tazapay
9
+ # Bank API
10
+ class Bank < Client
11
+ def add(account_id:, bank_data:)
12
+ path = "v1/bank"
13
+ data = bank_data.merge(account_id: account_id)
14
+ send_request(method: :post, path: path, body: data)
15
+ end
16
+
17
+ def list(account_id)
18
+ path = "v1/bank/#{account_id}"
19
+ send_request(method: :get, path: path)
20
+ end
21
+
22
+ def make_primary(account_id:, bank_id:)
23
+ path = "v1/bank/primary"
24
+ send_request(method: :put, path: path, body: {
25
+ account_id: account_id,
26
+ bank_id: bank_id
27
+ })
28
+ end
29
+ end
30
+ end
@@ -13,12 +13,11 @@ module Tazapay
13
13
  # Base API client
14
14
  class Client
15
15
  def send_request(method:, path:, headers: default_headers, body: {})
16
- conn = faraday_with_block(url: Tazapay.config.base_url)
17
- conn.headers = headers
18
- conn.basic_auth(Tazapay.config.access_key, Tazapay.config.secret_key)
16
+ conn = prepare_connection(headers)
19
17
  case method.to_s
20
18
  when "get" then response = conn.get(path)
21
19
  when "post" then response = conn.post(path, body.to_json)
20
+ when "put" then response = conn.put(path, body.to_json)
22
21
  end
23
22
  interpret_response(response)
24
23
  end
@@ -39,6 +38,13 @@ module Tazapay
39
38
 
40
39
  private
41
40
 
41
+ def prepare_connection(headers)
42
+ conn = faraday_with_block(url: Tazapay.config.base_url)
43
+ conn.headers = headers
44
+ conn.basic_auth(Tazapay.config.access_key, Tazapay.config.secret_key)
45
+ conn
46
+ end
47
+
42
48
  def faraday_with_block(options)
43
49
  Faraday.new(options)
44
50
  block = Tazapay.config.faraday_block
@@ -5,10 +5,11 @@
5
5
  module Tazapay
6
6
  # Stanadrd API error
7
7
  class Error < StandardError
8
- attr_reader :code
8
+ attr_reader :code, :response_body
9
9
 
10
10
  def initialize(message, code)
11
11
  @code = code
12
+ @response_body = message
12
13
  super("Error code #{code} #{message}")
13
14
  end
14
15
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Tazapay
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
data/lib/tazapay.rb CHANGED
@@ -4,6 +4,7 @@ require "tazapay/config"
4
4
  require "tazapay/version"
5
5
  require "tazapay/checkout"
6
6
  require "tazapay/user"
7
+ require "tazapay/bank"
7
8
 
8
9
  # Head module
9
10
  module Tazapay
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tazapay
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexey Kuznetsov
@@ -79,11 +79,11 @@ files:
79
79
  - CODE_OF_CONDUCT.md
80
80
  - Gemfile
81
81
  - Gemfile.lock
82
- - LICENSE
83
82
  - LICENSE.txt
84
83
  - README.md
85
84
  - Rakefile
86
85
  - lib/tazapay.rb
86
+ - lib/tazapay/bank.rb
87
87
  - lib/tazapay/checkout.rb
88
88
  - lib/tazapay/client.rb
89
89
  - lib/tazapay/config.rb
data/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2023 Alexey
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.