webirr 0.1.4 → 0.1.5

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: a58f69399972243af73a6d145553b69620e2e529404d94eebb98cbe74fa5b54c
4
- data.tar.gz: e2b79637d60fb9c4b8f605ab2ef5cc2423c45f37b0c4e60d5757847bade732db
3
+ metadata.gz: d3c0cc887b42d61cbfe75ecb0f01cb1786a9939375ebaa2c3aaf4a2450295219
4
+ data.tar.gz: 4f51f4a4ccb1f7017a99b11122861571b5d5f934daf269c281bdf20e23637db4
5
5
  SHA512:
6
- metadata.gz: 3c535eb9761eb175ce32136cc6dffcb65944dc6323c2fd52edde66d60328253a0ea42de26285e0e552f68223f4b6b73becf26daf8515aa4dfbeb28353bc72648
7
- data.tar.gz: aa3ee6f965398424b8e034edafac3824ed0f15d4068285ea5cea5b408d1055038111e36cb00e8ef99d6acc7cb22b8d50d91f15da3a743333dc8ba3253eb892fc
6
+ metadata.gz: 3c44c63531e08b3e8ead77a290fd9b7c955c1344cd0e28b434afca667ec32129c3e1aca551b127e5c219b2be2ef906502c6f379b58c1a8a795506265652e6f38
7
+ data.tar.gz: 4a9b4eed7e56fcb3b64c97c35dccbf5c2304f7f44cfa54fe7cd4a42f538f64725fd6fd339e1009f124e2e489b722a4b45d0132c3210efb4afd0fc7dcc14eb03a
data/Gemfile.lock CHANGED
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- webirr (0.1.0)
4
+ webirr (0.1.5)
5
+ faraday (~> 2.5)
5
6
 
6
7
  GEM
7
8
  remote: https://rubygems.org/
@@ -53,7 +54,6 @@ PLATFORMS
53
54
  x86_64-linux
54
55
 
55
56
  DEPENDENCIES
56
- faraday (~> 2.5)
57
57
  rake (~> 13.0)
58
58
  rspec (~> 3.0)
59
59
  rubocop (~> 1.21)
data/README.md CHANGED
@@ -24,14 +24,14 @@ Or install it yourself as:
24
24
 
25
25
  The library needs to be configured with a *merchant Id* & *API key*. You can get it by contacting [webirr.com](https://webirr.com)
26
26
 
27
- > You can use this library for production or test environments. you will need to set is_test_env=true for test, and false for production apps when creating objects of class WeBirrClient
27
+ > You can use this library for production or test environments. you will need to set is_test_env=true for test, and false for production apps when creating objects of class WeBirr::Client
28
28
 
29
29
  ## Examples
30
30
  ### Creating a new Bill / Updating an existing Bill on WeBirr Servers
31
31
 
32
32
  ```rb
33
- require 'bill'
34
- require 'webirr_client'
33
+ require 'webirr/bill'
34
+ require 'webirr/webirr_client'
35
35
 
36
36
  # Create & Update Bill
37
37
  def create_bill
@@ -39,9 +39,9 @@ def create_bill
39
39
  merchant_id = 'YOUR_MERCHANT_ID'
40
40
 
41
41
  # client to use test envionment
42
- webirr_client = WeBirrClient.new(api_key, true)
42
+ webirr_client = WeBirr::Client.new(api_key, true)
43
43
 
44
- bill = Bill.new
44
+ bill = Webirr::Bill.new
45
45
  bill.amount = "120.45"
46
46
  bill.customer_code = "C001" # it can be email address or phone number if you dont have customer code
47
47
  bill.customer_name = "Yohannes Aregay Hailu"
@@ -93,8 +93,8 @@ create_bill()
93
93
  ### Getting Payment status of an existing Bill from WeBirr Servers
94
94
 
95
95
  ```rb
96
- require 'bill'
97
- require 'webirr_client'
96
+ require 'webirr/bill'
97
+ require 'webirr/webirr_client'
98
98
 
99
99
  # Get Payment Status of Bill
100
100
  def get_webirr_payment_status
@@ -102,7 +102,7 @@ def get_webirr_payment_status
102
102
  merchant_id = 'YOUR_MERCHANT_ID'
103
103
 
104
104
  # client to use test envionment
105
- webirr_client = WeBirrClient.new(api_key, true)
105
+ webirr_client = WeBirr::Client.new(api_key, true)
106
106
 
107
107
  payment_code = 'PAYMENT_CODE_YOU_SAVED_AFTER_CREATING_A_NEW_BILL' # suchas as '141 263 782'
108
108
 
@@ -161,15 +161,15 @@ get_webirr_payment_status()
161
161
  ### Getting Payment status of an existing Bill from WeBirr Servers
162
162
 
163
163
  ```rb
164
- require 'bill'
165
- require 'webirr_client'
164
+ require 'webirr/bill'
165
+ require 'webirr/webirr_client'
166
166
 
167
- // Get Payment Status of Bill
167
+ // Get Payment Status of Webirr::Bill
168
168
  def get_webirr_payment_status
169
169
  api_key = 'YOUR_API_KEY'
170
170
  merchant_id = 'YOUR_MERCHANT_ID'
171
171
 
172
- webirr_client = WeBirrClient.new(api_key, true)
172
+ webirr_client = WeBirr::Client.new(api_key, true)
173
173
 
174
174
  payment_code = 'PAYMENT_CODE_YOU_SAVED_AFTER_CREATING_A_NEW_BILL' // suchas as '141 263 782'
175
175
 
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+
5
+ module Webirr
6
+ class Bill
7
+ attr_accessor :customer_code,
8
+ :customer_name,
9
+ :amount,
10
+ :description,
11
+ :bill_reference,
12
+ :merchant_id,
13
+ :time
14
+
15
+ def as_json(_options = {})
16
+ {
17
+ customerCode: @customer_code,
18
+ customerName: @customer_name,
19
+ amount: @amount,
20
+ description: @description,
21
+ billReference: @bill_reference,
22
+ merchantID: @merchant_id,
23
+ time: @time
24
+ }
25
+ end
26
+
27
+ def to_json(*options)
28
+ as_json(*options).to_json(*options)
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "faraday"
4
+
5
+ module Webirr
6
+ class Client
7
+ def initialize(api_key, is_test_env)
8
+ @api_key = api_key
9
+ @client =
10
+ Faraday.new(
11
+ url:
12
+ (is_test_env ? "https://api.webirr.com/" : "https://api.webirr.com:8080/").to_s,
13
+ params: {
14
+ "api_key" => @api_key
15
+ },
16
+ headers: {
17
+ "Content-Type" => "application/json"
18
+ }
19
+ )
20
+ end
21
+
22
+ def create_bill(bill)
23
+ response =
24
+ @client.post("einvoice/api/postbill") { |req| req.body = bill.to_json }
25
+ if response.success?
26
+ JSON.parse(response.body)
27
+ else
28
+ { "error" => "http error #{response.status} #{response.reason_phrase}" }
29
+ end
30
+ end
31
+
32
+ def update_bill(bill)
33
+ response =
34
+ @client.put("einvoice/api/postbill") { |req| req.body = bill.to_json }
35
+ if response.success?
36
+ JSON.parse(response.body)
37
+ else
38
+ { "error" => "http error #{response.status} #{response.reason_phrase}" }
39
+ end
40
+ end
41
+
42
+ def delete_bill(payment_code)
43
+ response = @client.put("einvoice/api/deletebill?wbc_code=#{payment_code}")
44
+ if response.success?
45
+ JSON.parse(response.body)
46
+ else
47
+ { "error" => "http error #{response.status} #{response.reason_phrase}" }
48
+ end
49
+ end
50
+
51
+ def get_payment_status(payment_code)
52
+ response =
53
+ @client.get("einvoice/api/getPaymentStatus?wbc_code=#{payment_code}")
54
+ if response.success?
55
+ JSON.parse(response.body)
56
+ else
57
+ { "error" => "http error #{response.status} #{response.reason_phrase}" }
58
+ end
59
+ end
60
+
61
+ def get_stat
62
+ response = @client.get("merchant/stat")
63
+ if response.success?
64
+ JSON.parse(response.body)
65
+ else
66
+ { "error" => "http error #{response.status} #{response.reason_phrase}" }
67
+ end
68
+ end
69
+ end
70
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Webirr
4
- VERSION = "0.1.4"
4
+ VERSION = "0.1.5"
5
5
  end
data/webirr.gemspec ADDED
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/webirr/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "webirr"
7
+ spec.version = Webirr::VERSION
8
+ spec.authors = ["Yohannes Aregay"]
9
+ spec.email = ["emailtoyohannes@gmail.com"]
10
+
11
+ spec.summary = "Official Ruby Client Library for WeBirr Payment Gateway APIs"
12
+ spec.description = "Official Ruby Client Library for WeBirr Payment Gateway APIs"
13
+ spec.homepage = "https://github.com/johnhailu/webirr"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 2.6.0"
16
+
17
+ spec.metadata["allowed_push_host"] = "https://rubygems.org/"
18
+
19
+ spec.metadata["homepage_uri"] = spec.homepage
20
+ spec.metadata["source_code_uri"] = "https://github.com/johnhailu/webirr"
21
+ spec.metadata["changelog_uri"] = "https://github.com/johnhailu/webirr/CHANGELOG.md"
22
+
23
+ # Specify which files should be added to the gem when it is released.
24
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
26
+ `git ls-files -z`.split("\x0").reject do |f|
27
+ (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
28
+ end
29
+ end
30
+ spec.bindir = "exe"
31
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
32
+ spec.require_paths = ["lib"]
33
+
34
+ # Uncomment to register a new dependency of your gem
35
+ spec.add_dependency "faraday", "~> 2.5"
36
+
37
+ # For more information and examples about making a new gem, check out our
38
+ # guide at: https://bundler.io/guides/creating_gem.html
39
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webirr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yohannes Aregay
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-09-06 00:00:00.000000000 Z
11
+ date: 2022-09-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -40,11 +40,12 @@ files:
40
40
  - LICENSE.txt
41
41
  - README.md
42
42
  - Rakefile
43
- - lib/bill.rb
44
43
  - lib/webirr.rb
44
+ - lib/webirr/bill.rb
45
+ - lib/webirr/client.rb
45
46
  - lib/webirr/version.rb
46
- - lib/webirr_client.rb
47
47
  - sig/webirr.rbs
48
+ - webirr.gemspec
48
49
  homepage: https://github.com/johnhailu/webirr
49
50
  licenses:
50
51
  - MIT
data/lib/bill.rb DELETED
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "json"
4
-
5
- class Bill
6
- attr_accessor :customer_code,
7
- :customer_name,
8
- :amount,
9
- :description,
10
- :bill_reference,
11
- :merchant_id,
12
- :time
13
-
14
- def as_json(_options = {})
15
- {
16
- customerCode: @customer_code,
17
- customerName: @customer_name,
18
- amount: @amount,
19
- description: @description,
20
- billReference: @bill_reference,
21
- merchantID: @merchant_id,
22
- time: @time
23
- }
24
- end
25
-
26
- def to_json(*options)
27
- as_json(*options).to_json(*options)
28
- end
29
- end
data/lib/webirr_client.rb DELETED
@@ -1,59 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "faraday"
4
-
5
- class WebirrClient
6
- def initialize(api_key, is_test_env)
7
- @api_key = api_key
8
- @client =
9
- Faraday.new(
10
- url:
11
- (is_test_env ? "https://api.webirr.com/einvoice/api/" : "https://api.webirr.com:8080/einvoice/api/").to_s,
12
- params: {
13
- "api_key" => @api_key
14
- },
15
- headers: {
16
- "Content-Type" => "application/json"
17
- }
18
- )
19
- end
20
-
21
- def create_bill(bill)
22
- response =
23
- @client.post("postbill") { |req| req.body = bill.to_json }
24
- if response.success?
25
- JSON.parse(response.body)
26
- else
27
- { "error" => "http error #{response.status} #{response.reason_phrase}" }
28
- end
29
- end
30
-
31
- def update_bill(bill)
32
- response =
33
- @client.put("postbill") { |req| req.body = bill.to_json }
34
- if response.success?
35
- JSON.parse(response.body)
36
- else
37
- { "error" => "http error #{response.status} #{response.reason_phrase}" }
38
- end
39
- end
40
-
41
- def delete_bill(payment_code)
42
- response = @client.put("deletebill?wbc_code=#{payment_code}")
43
- if response.success?
44
- JSON.parse(response.body)
45
- else
46
- { "error" => "http error #{response.status} #{response.reason_phrase}" }
47
- end
48
- end
49
-
50
- def get_payment_status(payment_code)
51
- response =
52
- @client.get("getPaymentStatus?wbc_code=#{payment_code}")
53
- if response.success?
54
- JSON.parse(response.body)
55
- else
56
- { "error" => "http error #{response.status} #{response.reason_phrase}" }
57
- end
58
- end
59
- end