billplz-api 0.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.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/Gemfile +2 -0
- data/LICENSE.txt +21 -0
- data/README.md +98 -0
- data/Rakefile +22 -0
- data/billplz-api.gemspec +21 -0
- data/bin/console +8 -0
- data/bin/setup +8 -0
- data/lib/billplz-api.rb +14 -0
- data/lib/billplz/bill.rb +26 -0
- data/lib/billplz/collection.rb +18 -0
- data/lib/billplz/configuration.rb +39 -0
- data/lib/billplz/model.rb +19 -0
- data/lib/billplz/registration_check.rb +15 -0
- data/lib/billplz/version.rb +3 -0
- metadata +88 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3c8e7487e7ab2562d1b626736595fea3e9c2ace7
|
4
|
+
data.tar.gz: 76ca3c83e80279763ed03b9331fded601c61092e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5582ce59f03a11e37b455dea2edb60687f099ea1fe4e70ce11b12679804f4d233603fa3e93f196cfe136ebe8b56dd04c66dd4326cf9b419c2bbd5817657edeae
|
7
|
+
data.tar.gz: ac5d267d9bb9316c79ab5f17530b2a01759b0ebacac281f2c968224932f73690d02ce76cd17da79fd17bed711003346ac25088fb04aac07fbd482e517ac90829
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Nobody
|
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
|
13
|
+
all 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
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
# Billplz
|
2
|
+
|
3
|
+
[Billplz-API](https://www.billplz.com/api) Client API for ruby
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'billplz-api'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
```
|
16
|
+
$ bundle
|
17
|
+
```
|
18
|
+
|
19
|
+
Or manually install
|
20
|
+
|
21
|
+
```
|
22
|
+
$ gem install billplz-api
|
23
|
+
```
|
24
|
+
|
25
|
+
##Configuration
|
26
|
+
You need to store your Billplz configuration setting in billplz.rb
|
27
|
+
```
|
28
|
+
# config/initializers/billplz.rb
|
29
|
+
Billplz.configure do |config|
|
30
|
+
config.api_key = ENV['API_KEY_BILLPLZ']
|
31
|
+
config.api_url = ENV['API_URL_BILLPLZ']
|
32
|
+
end
|
33
|
+
```
|
34
|
+
|
35
|
+
##Usage
|
36
|
+
**Collection**
|
37
|
+
|
38
|
+
**Create a collection**
|
39
|
+
```ruby
|
40
|
+
collection = Billplz::Collection.create(title: "Billplz Testing Collection")
|
41
|
+
# { "id": "inbmmepb", "title": "Billplz Testing Collection"}
|
42
|
+
```
|
43
|
+
|
44
|
+
**Deactivate a collection**
|
45
|
+
```ruby
|
46
|
+
collection = Billplz::Collection.deactivate(id: "alocpanfu")
|
47
|
+
```
|
48
|
+
|
49
|
+
**Activate a collection**
|
50
|
+
```ruby
|
51
|
+
collection = Billplz::Collection.activate(id: "alocpanfu")
|
52
|
+
```
|
53
|
+
|
54
|
+
**Open Collection**
|
55
|
+
|
56
|
+
**Create an open collection**
|
57
|
+
```ruby
|
58
|
+
open_collection = Billplz::Collection.create_open_collection(title: "Billplz Testing Collection",description: "Maecenas eu placerat ante. Fusce ut neque justo, et aliquet enim. In hac habitasse platea dictumst.", amount: 299)
|
59
|
+
```
|
60
|
+
|
61
|
+
**Bill**
|
62
|
+
|
63
|
+
**Create a bill**
|
64
|
+
```ruby
|
65
|
+
bill = Billplz::Bill.create( collection_id: "ajij091j",email: "admin@billplz.com",name:"Admin BillPlz",amount: 200,callback_url: "billplz.com",description: "Shopping Items")
|
66
|
+
```
|
67
|
+
|
68
|
+
**Get a bill**
|
69
|
+
```ruby
|
70
|
+
bill = Billplz::Bill.find(id: "arutnv89")
|
71
|
+
```
|
72
|
+
|
73
|
+
**Delete a bill**
|
74
|
+
```ruby
|
75
|
+
bill = Billplz::Bill.delete(id: "arutnv89")
|
76
|
+
```
|
77
|
+
|
78
|
+
**Registration Check**
|
79
|
+
|
80
|
+
Enter bank account number
|
81
|
+
```ruby
|
82
|
+
registration_check = Billplz::RegistrationCheck.find("123465782312")
|
83
|
+
```
|
84
|
+
|
85
|
+
|
86
|
+
## Contributing
|
87
|
+
|
88
|
+
Bug reports and pull requests are welcome .
|
89
|
+
|
90
|
+
1. Fork it
|
91
|
+
2. Create your feature branch (git checkout -b my-new-feature)
|
92
|
+
3. Commit your changes (git commit -am 'Add some feature')
|
93
|
+
4. Push to the branch (git push origin my-new-feature)
|
94
|
+
5. Create new Pull Request
|
95
|
+
|
96
|
+
## License
|
97
|
+
|
98
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rake/testtask"
|
3
|
+
|
4
|
+
desc "Run the unit test suite"
|
5
|
+
task :default => 'test:unit'
|
6
|
+
task :test => 'test:unit'
|
7
|
+
|
8
|
+
namespace :test do
|
9
|
+
Rake::TestTask.new(:unit) do |t|
|
10
|
+
t.pattern = 'test/unit/**/*_test.rb'
|
11
|
+
t.ruby_opts << '-rubygems -w'
|
12
|
+
t.libs << 'test'
|
13
|
+
t.verbose = true
|
14
|
+
end
|
15
|
+
|
16
|
+
Rake::TestTask.new(:remote) do |t|
|
17
|
+
t.pattern = 'test/remote/**/*_test.rb'
|
18
|
+
t.ruby_opts << '-rubygems -w'
|
19
|
+
t.libs << 'test'
|
20
|
+
t.verbose = true
|
21
|
+
end
|
22
|
+
end
|
data/billplz-api.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'billplz/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "billplz-api"
|
8
|
+
spec.version = Billplz::VERSION
|
9
|
+
|
10
|
+
spec.summary = 'Billplz Api Client'
|
11
|
+
spec.license = 'MIT'
|
12
|
+
spec.author = ['mkhairi','fathiabdulrahim']
|
13
|
+
spec.email = ['khairi@labs.my']
|
14
|
+
spec.homepage = 'https://github.com/mkhairi/billplz-api'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.require_paths = ["lib"]
|
18
|
+
|
19
|
+
spec.add_development_dependency "rake"
|
20
|
+
spec.add_dependency "flexirest"
|
21
|
+
end
|
data/bin/console
ADDED
data/bin/setup
ADDED
data/lib/billplz-api.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'uri'
|
3
|
+
require 'json'
|
4
|
+
require 'base64'
|
5
|
+
|
6
|
+
require "billplz/version"
|
7
|
+
require "billplz/configuration"
|
8
|
+
require "billplz/model"
|
9
|
+
require "billplz/bill"
|
10
|
+
require "billplz/collection"
|
11
|
+
require "billplz/registration_check"
|
12
|
+
|
13
|
+
module Billplz
|
14
|
+
end
|
data/lib/billplz/bill.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
module Billplz
|
2
|
+
class Bill < Model
|
3
|
+
|
4
|
+
before_request :set_base_url
|
5
|
+
before_request :replace_body
|
6
|
+
|
7
|
+
get :find, "/:id"
|
8
|
+
post :create, ""
|
9
|
+
delete :delete, "/:id"
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def set_base_url(name, request)
|
14
|
+
Flexirest::Base.base_url = "#{Billplz.configuration.api_url}/bills"
|
15
|
+
end
|
16
|
+
|
17
|
+
def replace_body(name, request)
|
18
|
+
if name == :create
|
19
|
+
#add collection id here
|
20
|
+
request.post_params = request.post_params.merge(collection_id: "#{ENV['BILLPLZ_COLLECTION_ID']}")
|
21
|
+
request.body = request.post_params.to_json
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Billplz
|
2
|
+
class Collection < Model
|
3
|
+
before_request :set_base_url
|
4
|
+
#before_request :replace_body
|
5
|
+
|
6
|
+
post :create, "/collections/"
|
7
|
+
post :create_open_collection, "/open_collections"
|
8
|
+
post :deactivate, "/collections/:id/deactivate"
|
9
|
+
post :activate, "/collections/:id/activate"
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def set_base_url(name, request)
|
14
|
+
Flexirest::Base.base_url = "#{Billplz.configuration.api_url}"
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Billplz
|
2
|
+
class Configuration
|
3
|
+
attr_accessor :api_key,:api_url, :http_timeout, :mode
|
4
|
+
|
5
|
+
def initialize(options={})
|
6
|
+
@http_timeout = 30
|
7
|
+
@mode = 'live'
|
8
|
+
end
|
9
|
+
|
10
|
+
def options
|
11
|
+
hash = Hash.new
|
12
|
+
%w[api_key api_url http_timeout mode].map{|key| hash[key.to_sym] = send(key) }
|
13
|
+
hash
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.configuration
|
18
|
+
@configuration ||= Configuration.new
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.configuration=(args)
|
22
|
+
@configuration ||= Configuration.new
|
23
|
+
args.each do |arg|
|
24
|
+
@configuration.send("#{arg.first}=", arg.last)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.options
|
29
|
+
@configuration.options
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.configure
|
33
|
+
yield configuration
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.reset
|
37
|
+
@configuration = nil
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Billplz
|
2
|
+
class Model < Flexirest::Base
|
3
|
+
perform_caching false
|
4
|
+
#verbose!
|
5
|
+
request_body_type :json
|
6
|
+
|
7
|
+
before_request :replace_token_in_url
|
8
|
+
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def replace_token_in_url(name, request)
|
13
|
+
auth = "Basic " + Base64.encode64(Billplz.configuration.api_key + ":").strip
|
14
|
+
request.headers["Authorization"] = auth
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Billplz
|
2
|
+
class RegistrationCheck < Model
|
3
|
+
before_request :set_base_url
|
4
|
+
#before_request :replace_body
|
5
|
+
|
6
|
+
get :find, "/:id"
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def set_base_url(name, request)
|
11
|
+
Flexirest::Base.base_url = "#{Billplz.configuration.api_url}/check/bank_account_number"
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: billplz-api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- mkhairi
|
8
|
+
- fathiabdulrahim
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2016-11-10 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
21
|
+
type: :development
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: flexirest
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
description:
|
43
|
+
email:
|
44
|
+
- khairi@labs.my
|
45
|
+
executables: []
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- ".gitignore"
|
50
|
+
- Gemfile
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- billplz-api.gemspec
|
55
|
+
- bin/console
|
56
|
+
- bin/setup
|
57
|
+
- lib/billplz-api.rb
|
58
|
+
- lib/billplz/bill.rb
|
59
|
+
- lib/billplz/collection.rb
|
60
|
+
- lib/billplz/configuration.rb
|
61
|
+
- lib/billplz/model.rb
|
62
|
+
- lib/billplz/registration_check.rb
|
63
|
+
- lib/billplz/version.rb
|
64
|
+
homepage: https://github.com/mkhairi/billplz-api
|
65
|
+
licenses:
|
66
|
+
- MIT
|
67
|
+
metadata: {}
|
68
|
+
post_install_message:
|
69
|
+
rdoc_options: []
|
70
|
+
require_paths:
|
71
|
+
- lib
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
requirements: []
|
83
|
+
rubyforge_project:
|
84
|
+
rubygems_version: 2.5.1
|
85
|
+
signing_key:
|
86
|
+
specification_version: 4
|
87
|
+
summary: Billplz Api Client
|
88
|
+
test_files: []
|