tazapay 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b977bb2c645361ecfec78c427b2c225e81cc0a23d0f9075558d57d4549b43ba4
4
- data.tar.gz: 8d2eff6f8f83b4e199c77b5ec5dd0c2d4eb13645626782fc65f4d8bd6fb37a87
3
+ metadata.gz: b450d94fc7d24206476c392110db8e1defd931c6a8b9f31b127ecbe1f4ff6cf0
4
+ data.tar.gz: 6c082cdd772f23a90fc78ed6aadd8d4d0ab0538ec7254d3c6dbe7f229a6e6537
5
5
  SHA512:
6
- metadata.gz: 2ee04358c3e84821b6262f38a7a1fd1ceab05885de7a0488f41e78f2a0979cc4be61e465f88d9759fec82b6b20421aa3f3f2fb97e5a08bd420617591ae6eb6c7
7
- data.tar.gz: 10c190ff09e1d965c345a4d2f58c807196be14c4baee8a874c96c56c06fe6bfd8508831f717dbcbd3fbe3bb5ab5d4ae5dbad5f77decafc479e33826ee30965e6
6
+ metadata.gz: 07f5a205b8d63fa6459e9ca0af995e3b215c358761fd444bc8b9100451c2f1d6106ba4f179785ec7f3908022d5f1f2a408dec31366d3c0f61429508f0760698e
7
+ data.tar.gz: b2c84373e543b873bd1aac04dcb33802db28e02ed0ea391b9b7ef0723dd298ec813dcafd1ca9b5c4bc40f4e10da88ce817eee61048e8cd56796fbeaeed478884
data/CHANGELOG.md CHANGED
@@ -3,3 +3,19 @@
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
+
18
+
19
+ ## [0.1.3] - 2023-02-25
20
+
21
+ - Add Metadata API
data/CODE_OF_CONDUCT.md CHANGED
@@ -39,7 +39,7 @@ This Code of Conduct applies within all community spaces, and also applies when
39
39
 
40
40
  ## Enforcement
41
41
 
42
- Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at a.kuznetsov@okft.io. All complaints will be reviewed and investigated promptly and fairly.
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at m2lxkuz@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
43
 
44
44
  All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
45
 
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.3)
5
5
  faraday (~> 1.0)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -1,8 +1,7 @@
1
1
  # Tazapay
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/tazapay`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ Tazapay API ruby client
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
6
5
 
7
6
  ## Installation
8
7
 
@@ -44,6 +43,99 @@ data = tazapay_checkout.get_status(tx_number)
44
43
 
45
44
  ```
46
45
 
46
+ ### User
47
+
48
+ ```ruby
49
+
50
+ tazapay_user = Tazapay::User.new
51
+
52
+ data = {
53
+ email: "sometest+12@mail.io",
54
+ country: "SG",
55
+ ind_bus_type: "Business",
56
+ business_name: "TEST SANDBOX",
57
+ contact_code: "+65",
58
+ contact_number: "9999999999",
59
+ partners_customer_id: "test-123"
60
+ }
61
+
62
+ # Create user
63
+ user_id = tazapay_user.create(data)["data"]["account_id"]
64
+
65
+ # Update user
66
+ tazapay_user.update(user_id, new_data)
67
+
68
+ # Find user by ID
69
+ tazapay_user.find(user_id)
70
+
71
+ # Find user by Email
72
+ tazapay_user.find(email)
73
+
74
+ ```
75
+
76
+ See more details in tests
77
+
78
+ ### Bank
79
+
80
+ ```ruby
81
+
82
+ tazapay_bank = Tazapay::Bank.new
83
+
84
+ data = {
85
+ email: "sometest+12@mail.io",
86
+ country: "SG",
87
+ ind_bus_type: "Business",
88
+ business_name: "TEST SANDBOX",
89
+ contact_code: "+65",
90
+ contact_number: "9999999999",
91
+ partners_customer_id: "test-123"
92
+ }
93
+
94
+ # Add bank account
95
+ bank_id = tazapay_bank.add(
96
+ account_id: user_id, bank_data: new_data
97
+ )['data']['bank_id']
98
+
99
+ # List user banks
100
+ tazapay_bank.list(user_id)
101
+
102
+ # Make bank account primary
103
+ tazapay_bank.make_primary(bank_id: bank_id, account_id: user_id)
104
+
105
+ ```
106
+
107
+ See more details in tests
108
+
109
+
110
+ ### Metadata
111
+
112
+ ```ruby
113
+
114
+ tazapay_metadata = Tazapay::Metadata.new
115
+
116
+ # See https://docs.tazapay.com/reference/country-configuration-api
117
+ tazapay_metadata.country_config(country)
118
+
119
+ # See https://docs.tazapay.com/reference/invoice-currency-api
120
+ tazapay_metadata.invoice_currency(buyer_country:, seller_country:)
121
+
122
+ # See https://docs.tazapay.com/reference/collection-methods-api
123
+ tazapay_metadata.collection_methods(buyer_country:, seller_country:, invoice_currency:, amount:)
124
+
125
+ # See https://docs.tazapay.com/reference/disburse-methods-api
126
+ tazapay_metadata.disbursement_methods(buyer_country:, seller_country:, invoice_currency:, amount:)
127
+
128
+ # Doc upload URL
129
+ tazapay_metadata.doc_upload_url
130
+
131
+ # KYB Doc
132
+ tazapay_metadata.kyb_doc(country)
133
+
134
+ # See https://docs.tazapay.com/reference/get-milestone-schemes
135
+ tazapay_metadata.milestone_scheme
136
+
137
+ ```
138
+
47
139
  See more details in tests
48
140
 
49
141
 
@@ -55,7 +147,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
55
147
 
56
148
  ## Contributing
57
149
 
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).
150
+ 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
151
 
60
152
  ## License
61
153
 
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "tazapay/config"
4
+ require "tazapay/client"
5
+
6
+ module Tazapay
7
+ # Bank API
8
+ class Bank < Client
9
+ def add(account_id:, bank_data:)
10
+ path = "v1/bank"
11
+ data = bank_data.merge(account_id: account_id)
12
+ send_request(method: :post, path: path, body: data)
13
+ end
14
+
15
+ def list(account_id)
16
+ path = "v1/bank/#{account_id}"
17
+ send_request(method: :get, path: path)
18
+ end
19
+
20
+ def make_primary(account_id:, bank_id:)
21
+ path = "v1/bank/primary"
22
+ send_request(method: :put, path: path, body: {
23
+ account_id: account_id,
24
+ bank_id: bank_id
25
+ })
26
+ end
27
+ end
28
+ end
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Implementation of the MTN API remittances client
4
-
5
3
  require "tazapay/config"
6
4
  require "tazapay/client"
7
5
 
@@ -1,9 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Base implementation of the MTN API client
4
-
5
- # Includes methods common to collections, disbursements and remittances
6
-
7
3
  require "faraday"
8
4
 
9
5
  require "tazapay/config"
@@ -13,12 +9,11 @@ module Tazapay
13
9
  # Base API client
14
10
  class Client
15
11
  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)
12
+ conn = prepare_connection(headers)
19
13
  case method.to_s
20
14
  when "get" then response = conn.get(path)
21
15
  when "post" then response = conn.post(path, body.to_json)
16
+ when "put" then response = conn.put(path, body.to_json)
22
17
  end
23
18
  interpret_response(response)
24
19
  end
@@ -39,6 +34,13 @@ module Tazapay
39
34
 
40
35
  private
41
36
 
37
+ def prepare_connection(headers)
38
+ conn = faraday_with_block(url: Tazapay.config.base_url)
39
+ conn.headers = headers
40
+ conn.basic_auth(Tazapay.config.access_key, Tazapay.config.secret_key)
41
+ conn
42
+ end
43
+
42
44
  def faraday_with_block(options)
43
45
  Faraday.new(options)
44
46
  block = Tazapay.config.faraday_block
@@ -3,12 +3,13 @@
3
3
  # Error handling for unsuccessful responses from the Tazapay API
4
4
 
5
5
  module Tazapay
6
- # Stanadrd API error
6
+ # Standard 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
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "tazapay/config"
4
+ require "tazapay/client"
5
+
6
+ module Tazapay
7
+ # Metadata API
8
+ class Metadata < Client
9
+ def country_config(country)
10
+ path = "v1/metadata/countryconfig?country=#{country}"
11
+ send_request(method: :get, path: path)
12
+ end
13
+
14
+ def invoice_currency(buyer_country:, seller_country:)
15
+ path = "v1/metadata/invoicecurrency?buyer_country=#{buyer_country}&seller_country=#{seller_country}"
16
+ send_request(method: :get, path: path)
17
+ end
18
+
19
+ def collection_methods(buyer_country:, seller_country:, invoice_currency:, amount:)
20
+ path = "v1/metadata/collect?buyer_country=#{buyer_country}" \
21
+ "&seller_country=#{seller_country}&invoice_currency=#{invoice_currency}" \
22
+ "&amount=#{amount}"
23
+ send_request(method: :get, path: path)
24
+ end
25
+
26
+ def disbursement_methods(buyer_country:, seller_country:, invoice_currency:, amount:)
27
+ path = "v1/metadata/disburse?buyer_country=#{buyer_country}" \
28
+ "&seller_country=#{seller_country}&invoice_currency=#{invoice_currency}" \
29
+ "&amount=#{amount}"
30
+ send_request(method: :get, path: path)
31
+ end
32
+
33
+ def doc_upload_url
34
+ path = "/v1/metadata/doc/upload"
35
+ send_request(method: :get, path: path)
36
+ end
37
+
38
+ def kyb_doc(country)
39
+ path = "/v1/metadata/kyb/doc?country=#{country}"
40
+ send_request(method: :get, path: path)
41
+ end
42
+
43
+ def milestone_scheme
44
+ path = "v1/metadata/milestone/scheme"
45
+ send_request(method: :get, path: path)
46
+ end
47
+ end
48
+ end
data/lib/tazapay/user.rb CHANGED
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Implementation of the MTN API remittances client
4
-
5
3
  require "tazapay/config"
6
4
  require "tazapay/client"
7
5
 
@@ -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.3"
5
5
  end
data/lib/tazapay.rb CHANGED
@@ -4,6 +4,8 @@ require "tazapay/config"
4
4
  require "tazapay/version"
5
5
  require "tazapay/checkout"
6
6
  require "tazapay/user"
7
+ require "tazapay/bank"
8
+ require "tazapay/metadata"
7
9
 
8
10
  # Head module
9
11
  module Tazapay
data/tazapay.gemspec CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
8
8
  spec.name = "tazapay"
9
9
  spec.version = Tazapay::VERSION
10
10
  spec.authors = ["Alexey Kuznetsov"]
11
- spec.email = ["a.kuznetsov@okft.io"]
11
+ spec.email = ["m2lxkuz@gmail.com"]
12
12
 
13
13
  spec.summary = "Tazapay payments API ruby client"
14
14
  spec.description = "Tazapay payments API ruby client"
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.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexey Kuznetsov
@@ -68,7 +68,7 @@ dependencies:
68
68
  version: '3.18'
69
69
  description: Tazapay payments API ruby client
70
70
  email:
71
- - a.kuznetsov@okft.io
71
+ - m2lxkuz@gmail.com
72
72
  executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
@@ -79,15 +79,16 @@ 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
90
90
  - lib/tazapay/errors.rb
91
+ - lib/tazapay/metadata.rb
91
92
  - lib/tazapay/user.rb
92
93
  - lib/tazapay/version.rb
93
94
  - sig/tazapay.rbs
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.