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 +4 -4
- data/CHANGELOG.md +12 -0
- data/Gemfile.lock +1 -1
- data/README.md +62 -1
- data/lib/tazapay/bank.rb +30 -0
- data/lib/tazapay/client.rb +9 -3
- data/lib/tazapay/errors.rb +2 -1
- data/lib/tazapay/version.rb +1 -1
- data/lib/tazapay.rb +1 -0
- metadata +2 -2
- data/LICENSE +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11df37a78614be73791738660b0c7b8c449101ea8e920bfff7b30b0f5e752a03
|
4
|
+
data.tar.gz: 2f72d20bdc2498e817e3d7a2e4e202fc5e97c164f106b4c5fdbb639ab8a53bf1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12ab6bdad83dc4f993114f82d152da5683a0c8f20153e71e0fbfdc5b6baebca426dbb2e27fcba7cb006f18803e78e0f924c82fc4c50005c456ee99815730d3e4
|
7
|
+
data.tar.gz: 2e3b49a30e61533b7ecf4ca7c43f47b2aefb5a0213c939e9e4d5ffe9cd55182b7eb76c39ca8108c36d1861aff5acd49209fab4f573a4e0bae698da972934ff30
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
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/
|
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
|
|
data/lib/tazapay/bank.rb
ADDED
@@ -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
|
data/lib/tazapay/client.rb
CHANGED
@@ -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 =
|
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
|
data/lib/tazapay/errors.rb
CHANGED
@@ -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
|
data/lib/tazapay/version.rb
CHANGED
data/lib/tazapay.rb
CHANGED
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.
|
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.
|