finswitz 1.0.0 → 1.1.0

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +99 -18
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 54616ae6e0c27453ac0bec222a63a10352624e4f27e40f061de18e271bb967ab
4
- data.tar.gz: 243f2e913bfc0b05850f0d9d6c4d40f173e57d09662618b1c28591a9929557e9
3
+ metadata.gz: ff7e66f15c0e05025c3c2f6cd9c0c32d972bbc3fbe4d13faae1dff8d91d6960b
4
+ data.tar.gz: afd04594a00f3cb76983d9aeedc6ce3500c731bd0affdb1c426a7335370c2222
5
5
  SHA512:
6
- metadata.gz: db5db1fe3248c3f3fd5e643e4bd981cbabcc121214077ab4d526779f8664229d2ab888fff788b24ced65932320a1b3549310f305f4b40e950269ff172d62c225
7
- data.tar.gz: a74e0b7c30517790226d03d928a02c83c5030fc573ece590f6996ebfa8f39093f82b2a41dab3a0f5947a36fd22cfacfd3951c3e17347e9956bb1f17b7282ee70
6
+ metadata.gz: f9103ff9bd1c7929a10f3c86e01f750c7359d2c4d809a5f5cc4dea84f6e6285b25a6030d5cf521d5767390740944f1081e081fe72e457f9845b248a8c42bc214
7
+ data.tar.gz: 06f58232bec6a63c5b0f550ad46c9b574ff358cca2da416276e78e5a4a36a8507ce6f27b56bf738399d5afc7fe38b5d945c21a6ef6bf5068164de9398cbe774b
data/README.md CHANGED
@@ -1,35 +1,116 @@
1
- # Finswitz
1
+ # Finswitz Ruby SDK
2
2
 
3
- TODO: Delete this and the text below, and describe your gem
4
-
5
- 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/finswitz`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ Ruby client for the Finswitz API.
6
4
 
7
5
  ## Installation
8
6
 
9
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
7
+ The Ruby SDK is currently distributed as a source client. Add `finswitz.rb` to your application and require it from your server-side code.
8
+
9
+ When a gem is published, this README should be updated with the gem install command.
10
+
11
+ ## Requirements
12
+
13
+ - Ruby 3.0 or newer
14
+ - A Finswitz test or live secret key
15
+
16
+ ## Quick Start
10
17
 
11
- Install the gem and add to the application's Gemfile by executing:
18
+ ```ruby
19
+ require_relative "finswitz"
12
20
 
13
- ```bash
14
- bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
21
+ client = Finswitz::Client.new(api_key: ENV.fetch("FINSWITZ_SECRET_KEY"))
22
+
23
+ link = client.create_payment_link(
24
+ {
25
+ amount: 5000,
26
+ currency: "NGN",
27
+ title: "Order #1234",
28
+ email: "buyer@example.com",
29
+ callback_url: "https://merchant.example/complete"
30
+ },
31
+ idempotency_key: "order-1234-link"
32
+ )
33
+
34
+ puts link["checkoutUrl"]
15
35
  ```
16
36
 
17
- If bundler is not being used to manage dependencies, install the gem by executing:
37
+ ## Custom Base URL
18
38
 
19
- ```bash
20
- gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
39
+ ```ruby
40
+ client = Finswitz::Client.new(
41
+ api_key: ENV.fetch("FINSWITZ_SECRET_KEY"),
42
+ base_url: "http://localhost:4000"
43
+ )
21
44
  ```
22
45
 
23
- ## Usage
46
+ ## Payments
24
47
 
25
- TODO: Write usage instructions here
48
+ ```ruby
49
+ client.transfer(
50
+ {
51
+ amount: 5000,
52
+ currency: "NGN",
53
+ bank_code: "058",
54
+ account_number: "0123456789",
55
+ narration: "Vendor payout"
56
+ },
57
+ idempotency_key: "transfer-001"
58
+ )
26
59
 
27
- ## Development
60
+ client.mobile_money(
61
+ {
62
+ amount: 1500,
63
+ currency: "GHS",
64
+ phone: "+233501112222",
65
+ country: "GH"
66
+ },
67
+ idempotency_key: "momo-001"
68
+ )
69
+
70
+ transaction = client.get_transaction("reference")
71
+ ```
28
72
 
29
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
73
+ ## Dashboard JWT Helpers
30
74
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
75
+ ```ruby
76
+ client = Finswitz::Client.new(
77
+ api_key: ENV.fetch("FINSWITZ_SECRET_KEY"),
78
+ dashboard_token: ENV.fetch("FINSWITZ_DASHBOARD_TOKEN")
79
+ )
32
80
 
33
- ## Contributing
81
+ client.update_webhooks({
82
+ mode: "test",
83
+ url: "https://merchant.example/webhooks/finswitz"
84
+ })
34
85
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/finswitz.
86
+ wallets = client.wallets
87
+ treasury = client.treasury
88
+ ```
89
+
90
+ ## Collections
91
+
92
+ ```ruby
93
+ collection = client.public_collection("school-fees")
94
+
95
+ payment = client.pay_collection(
96
+ "school-fees",
97
+ {
98
+ fullName: "Grace Johnson",
99
+ email: "grace@example.com",
100
+ amount: 10000,
101
+ phone: "+2348012345678"
102
+ }
103
+ )
104
+ ```
105
+
106
+ ## Error Handling
107
+
108
+ ```ruby
109
+ begin
110
+ client.get_transaction("missing-reference")
111
+ rescue Finswitz::ApiError => error
112
+ warn error.status
113
+ warn error.response
114
+ raise
115
+ end
116
+ ```
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: finswitz
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taiwo Ayomide TBWLJ