regaliator 4.0.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 (108) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +16 -0
  3. data/.ruby-version +1 -0
  4. data/Gemfile +4 -0
  5. data/Guardfile +36 -0
  6. data/LICENSE.txt +22 -0
  7. data/README.md +116 -0
  8. data/Rakefile +11 -0
  9. data/lib/regaliator/api_version_error.rb +7 -0
  10. data/lib/regaliator/client.rb +9 -0
  11. data/lib/regaliator/configuration.rb +25 -0
  12. data/lib/regaliator/endpoint.rb +17 -0
  13. data/lib/regaliator/request.rb +100 -0
  14. data/lib/regaliator/response.rb +40 -0
  15. data/lib/regaliator/v15/account.rb +11 -0
  16. data/lib/regaliator/v15/bill.rb +23 -0
  17. data/lib/regaliator/v15/biller.rb +15 -0
  18. data/lib/regaliator/v15/client.rb +32 -0
  19. data/lib/regaliator/v15/rate.rb +15 -0
  20. data/lib/regaliator/v15/transaction.rb +23 -0
  21. data/lib/regaliator/v15.rb +7 -0
  22. data/lib/regaliator/v30/account.rb +11 -0
  23. data/lib/regaliator/v30/bill.rb +35 -0
  24. data/lib/regaliator/v30/biller.rb +19 -0
  25. data/lib/regaliator/v30/client.rb +32 -0
  26. data/lib/regaliator/v30/rate.rb +15 -0
  27. data/lib/regaliator/v30/transaction.rb +11 -0
  28. data/lib/regaliator/v30.rb +7 -0
  29. data/lib/regaliator/v31.rb +14 -0
  30. data/lib/regaliator/version.rb +3 -0
  31. data/lib/regaliator.rb +59 -0
  32. data/regaliator.gemspec +34 -0
  33. data/test/fixtures/vcr_cassettes/V31/account/failed_info.yml +48 -0
  34. data/test/fixtures/vcr_cassettes/V31/account/successful_info.yml +50 -0
  35. data/test/fixtures/vcr_cassettes/V31/bill/create.yml +52 -0
  36. data/test/fixtures/vcr_cassettes/V31/bill/list.yml +71 -0
  37. data/test/fixtures/vcr_cassettes/V31/bill/pay.yml +52 -0
  38. data/test/fixtures/vcr_cassettes/V31/bill/refresh.yml +52 -0
  39. data/test/fixtures/vcr_cassettes/V31/bill/show.yml +51 -0
  40. data/test/fixtures/vcr_cassettes/V31/bill/update.yml +53 -0
  41. data/test/fixtures/vcr_cassettes/V31/bill/xdata.yml +51 -0
  42. data/test/fixtures/vcr_cassettes/V31/biller/credentials.yml +256 -0
  43. data/test/fixtures/vcr_cassettes/V31/biller/topups.yml +209 -0
  44. data/test/fixtures/vcr_cassettes/V31/biller/utilities.yml +611 -0
  45. data/test/fixtures/vcr_cassettes/V31/rate/history.yml +50 -0
  46. data/test/fixtures/vcr_cassettes/V31/rate/list.yml +50 -0
  47. data/test/fixtures/vcr_cassettes/V31/transaction/list.yml +52 -0
  48. data/test/fixtures/vcr_cassettes/V31/transaction/search.yml +52 -0
  49. data/test/fixtures/vcr_cassettes/v15/account/failed_info.yml +50 -0
  50. data/test/fixtures/vcr_cassettes/v15/account/successful_info.yml +52 -0
  51. data/test/fixtures/vcr_cassettes/v15/bill/check.yml +52 -0
  52. data/test/fixtures/vcr_cassettes/v15/bill/consult.yml +52 -0
  53. data/test/fixtures/vcr_cassettes/v15/bill/index.yml +176 -0
  54. data/test/fixtures/vcr_cassettes/v15/bill/pay.yml +52 -0
  55. data/test/fixtures/vcr_cassettes/v15/biller/topups.yml +212 -0
  56. data/test/fixtures/vcr_cassettes/v15/biller/utilities.yml +611 -0
  57. data/test/fixtures/vcr_cassettes/v15/rate/history.yml +52 -0
  58. data/test/fixtures/vcr_cassettes/v15/rate/list.yml +52 -0
  59. data/test/fixtures/vcr_cassettes/v15/transaction/cancel.yml +52 -0
  60. data/test/fixtures/vcr_cassettes/v15/transaction/list.yml +54 -0
  61. data/test/fixtures/vcr_cassettes/v15/transaction/pay.yml +52 -0
  62. data/test/fixtures/vcr_cassettes/v15/transaction/reverse.yml +52 -0
  63. data/test/fixtures/vcr_cassettes/v15/transaction/search.yml +54 -0
  64. data/test/fixtures/vcr_cassettes/v30/account/failed_info.yml +48 -0
  65. data/test/fixtures/vcr_cassettes/v30/account/successful_info.yml +50 -0
  66. data/test/fixtures/vcr_cassettes/v30/bill/create.yml +56 -0
  67. data/test/fixtures/vcr_cassettes/v30/bill/list.yml +54 -0
  68. data/test/fixtures/vcr_cassettes/v30/bill/pay.yml +56 -0
  69. data/test/fixtures/vcr_cassettes/v30/bill/refresh.yml +56 -0
  70. data/test/fixtures/vcr_cassettes/v30/bill/show.yml +55 -0
  71. data/test/fixtures/vcr_cassettes/v30/bill/update.yml +57 -0
  72. data/test/fixtures/vcr_cassettes/v30/bill/xdata.yml +50 -0
  73. data/test/fixtures/vcr_cassettes/v30/biller/credentials.yml +54 -0
  74. data/test/fixtures/vcr_cassettes/v30/biller/topups.yml +54 -0
  75. data/test/fixtures/vcr_cassettes/v30/biller/utilities.yml +54 -0
  76. data/test/fixtures/vcr_cassettes/v30/rate/history.yml +54 -0
  77. data/test/fixtures/vcr_cassettes/v30/rate/list.yml +54 -0
  78. data/test/fixtures/vcr_cassettes/v30/transaction/list.yml +56 -0
  79. data/test/fixtures/vcr_cassettes/v30/transaction/search.yml +56 -0
  80. data/test/regaliator/api_version_error_test.rb +14 -0
  81. data/test/regaliator/client_test.rb +19 -0
  82. data/test/regaliator/configuration_test.rb +115 -0
  83. data/test/regaliator/endpoint_test.rb +19 -0
  84. data/test/regaliator/v15/account_test.rb +37 -0
  85. data/test/regaliator/v15/bill_test.rb +67 -0
  86. data/test/regaliator/v15/biller_test.rb +35 -0
  87. data/test/regaliator/v15/client_test.rb +23 -0
  88. data/test/regaliator/v15/rate_test.rb +35 -0
  89. data/test/regaliator/v15/transaction_test.rb +62 -0
  90. data/test/regaliator/v15_test.rb +10 -0
  91. data/test/regaliator/v30/account_test.rb +37 -0
  92. data/test/regaliator/v30/bill_test.rb +80 -0
  93. data/test/regaliator/v30/biller_test.rb +44 -0
  94. data/test/regaliator/v30/client_test.rb +23 -0
  95. data/test/regaliator/v30/rate_test.rb +35 -0
  96. data/test/regaliator/v30/transaction_test.rb +35 -0
  97. data/test/regaliator/v30_test.rb +10 -0
  98. data/test/regaliator/v31/account_test.rb +37 -0
  99. data/test/regaliator/v31/bill_test.rb +84 -0
  100. data/test/regaliator/v31/biller_test.rb +44 -0
  101. data/test/regaliator/v31/client_test.rb +23 -0
  102. data/test/regaliator/v31/rate_test.rb +35 -0
  103. data/test/regaliator/v31/transaction_test.rb +35 -0
  104. data/test/regaliator/v31_test.rb +10 -0
  105. data/test/regaliator/version_test.rb +10 -0
  106. data/test/regaliator_test.rb +66 -0
  107. data/test/test_helper.rb +26 -0
  108. metadata +394 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: efcf64f576bc7a9431e43534c2f9198c77fbb485
4
+ data.tar.gz: bc6e231c1cba489c8eeef2dbd7fc3a829a867463
5
+ SHA512:
6
+ metadata.gz: c3275c4f56fb2a72c00d5d0574c7143cd98a3409d34b264ea6ea2d6b60c1ec8eea002dc4c298f9cce0e9c755fd3b39b754a450b282d02fa654fc3b0a151add50
7
+ data.tar.gz: b5b4a82649400cc05219c00152d89e5d23d07c20d3318afe1f218318148dfd1bd5bb97fb9081efc4f70652a33e68b6a268c5603325a8bde676922d8b245d83d2
data/.gitignore ADDED
@@ -0,0 +1,16 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /vendor/bundle
11
+ *.bundle
12
+ *.so
13
+ *.o
14
+ *.a
15
+ mkmf.log
16
+ *.gem
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.1.10
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in regaliator.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,36 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ ## Uncomment and set this to only include directories you want to watch
5
+ directories %w(lib test)
6
+
7
+ ## Uncomment to clear the screen before every task
8
+ clearing :on
9
+
10
+ ## Guard internally checks for changes in the Guardfile and exits.
11
+ ## If you want Guard to automatically start up again, run guard in a
12
+ ## shell loop, e.g.:
13
+ ##
14
+ ## $ while bundle exec guard; do echo "Restarting Guard..."; done
15
+ ##
16
+ ## Note: if you are using the `directories` clause above and you are not
17
+ ## watching the project directory ('.'), the you will want to move the Guardfile
18
+ ## to a watched dir and symlink it back, e.g.
19
+ #
20
+ # $ mkdir config
21
+ # $ mv Guardfile config/
22
+ # $ ln -s config/Guardfile .
23
+ #
24
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
25
+
26
+ guard :minitest do
27
+ # with Minitest::Unit
28
+ watch(%r{^test/(.*)\/?(.*)_test\.rb$})
29
+ watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { |m| "test/#{m[1]}#{m[2]}_test.rb" }
30
+ watch(%r{^test/test_helper\.rb$}) { 'test' }
31
+
32
+ # with Minitest::Spec
33
+ # watch(%r{^spec/(.*)_spec\.rb$})
34
+ # watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
35
+ # watch(%r{^spec/spec_helper\.rb$}) { 'spec' }
36
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Hesham
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,116 @@
1
+ # Regaliator
2
+
3
+ Ruby wrapper for Regalii's API. The full API docs:
4
+ * Version 3.1 (recommended): https://www.regalii.com/api/v3/overview ;
5
+ * Version 3.0 : https://www.regalii.com/api/v3/overview ;
6
+ * Version 1.5 : https://www.regalii.com/api/v1/overview
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem 'regaliator', github: 'regalii/regaliator'
14
+ ```
15
+
16
+ And then execute:
17
+
18
+ ```
19
+ $ bundle
20
+ ```
21
+
22
+ ## Configuration
23
+
24
+ Add the following to config/initializers/regaliator.rb:
25
+
26
+ ```ruby
27
+ Regaliator.configure do |config|
28
+ # Version target
29
+ config.version = '3.1'
30
+
31
+ # Authentication settings
32
+ config.api_key = 'your-api-key'
33
+ config.secret_key = 'your-secret-key'
34
+
35
+ # API host settings
36
+ config.host = 'api.casiregalii.com'
37
+ config.open_timeout = 5
38
+ config.read_timeout = 10
39
+ config.use_ssl = true
40
+
41
+ # Proxy settings
42
+ config.proxy_host = nil
43
+ config.proxy_port = nil
44
+ config.proxy_user = nil
45
+ config.proxy_pass = nil
46
+ end
47
+ ```
48
+
49
+ ## Versions
50
+
51
+ To switch the version API, you have just to set the version in the configuration,
52
+ for instance, the version `1.5`:
53
+
54
+ ```ruby
55
+ Regaliator.configure do |config|
56
+ # Version target
57
+ config.version = '1.5'
58
+
59
+ # ...
60
+ end
61
+ ```
62
+
63
+ The available versions are: `1.5`, `3.0` and `3.1` (recommended).
64
+
65
+ ## Requests
66
+
67
+ **Success:**
68
+
69
+ ```ruby
70
+ > response = Regaliator.new.bill.show(1)
71
+ > response.success?
72
+ => true
73
+ > response.data
74
+ => {...}
75
+ ```
76
+
77
+ ```ruby
78
+ > response = Regaliator.new.bill.pay(1, amount: 13.0, currency: 'MXN')
79
+ > response.success?
80
+ => true
81
+ > response.data
82
+ => {...}
83
+ ```
84
+
85
+ **Failure:**
86
+
87
+ ```ruby
88
+ > response = Regaliator.new.bill.pay(biller_id: 1, account_number: '12345', amount: 0.0, currency: 'MXN')
89
+ > response.success?
90
+ => false
91
+ > response.data
92
+ => {"code" => "R3", "message" => "Invalid Payment Amount"}
93
+ ```
94
+
95
+ ## Examples
96
+
97
+ The following examples will show how to use the Regaliator gem to connect to the different Regalii API endpoints.
98
+
99
+ ### Billers List
100
+ https://www.regalii.com/billers
101
+ ```ruby
102
+ response = Regaliator.new.biller.utilities
103
+ ```
104
+
105
+ ## Tests
106
+
107
+ To run the tests, run:
108
+ ```
109
+ $ bundle exec rake test
110
+ ```
111
+
112
+ To test on each file change, run:
113
+
114
+ ```
115
+ $ bundle exec guard
116
+ ```
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new do |test|
5
+ test.libs << 'lib' << 'test'
6
+ test.pattern = 'test/**/*_test.rb'
7
+ test.verbose = true
8
+ end
9
+
10
+ desc "Run tests"
11
+ task :default => :test
@@ -0,0 +1,7 @@
1
+ module Regaliator
2
+ class APIVersionError < StandardError
3
+ def initialize(api_version)
4
+ super("API version `#{api_version}' isn't supported!")
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ module Regaliator
2
+ class Client
3
+ attr_accessor :config
4
+
5
+ def initialize(config = Regaliator.configuration)
6
+ @config = config
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,25 @@
1
+ module Regaliator
2
+ class Configuration
3
+ attr_accessor :api_key, :secret_key, :host, :open_timeout, :read_timeout,
4
+ :use_ssl, :proxy_host, :proxy_port, :proxy_user, :proxy_pass, :version
5
+
6
+ def initialize
7
+ @api_key = nil
8
+ @secret_key = nil
9
+ @host = nil
10
+ @version = nil
11
+ @open_timeout = 10
12
+ @read_timeout = 60
13
+ @use_ssl = true
14
+
15
+ @proxy_host = nil
16
+ @proxy_port = nil
17
+ @proxy_user = nil
18
+ @proxy_pass = nil
19
+ end
20
+
21
+ def secure?
22
+ use_ssl == true
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,17 @@
1
+ require 'regaliator/request'
2
+
3
+ module Regaliator
4
+ class Endpoint
5
+ attr_reader :config
6
+
7
+ def initialize(config)
8
+ @config = config
9
+ end
10
+
11
+ private
12
+
13
+ def request(*args)
14
+ Request.new(config, *args)
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,100 @@
1
+ require 'base64'
2
+ require 'digest'
3
+ require 'net/http'
4
+ require 'openssl'
5
+ require 'uri'
6
+ require 'regaliator/response'
7
+ require 'regaliator/version'
8
+
9
+ module Regaliator
10
+ class Request
11
+ CONTENT_TYPE = 'application/json'.freeze
12
+
13
+ attr_reader :config, :http, :http_request, :uri, :endpoint, :params, :timestamp
14
+
15
+ def initialize(config, endpoint, params = {})
16
+ @config = config
17
+ @timestamp = Time.now.utc.httpdate.to_s
18
+ @endpoint = endpoint
19
+ @params = params
20
+ @uri = build_uri
21
+ @http = build_http
22
+ end
23
+
24
+ def post
25
+ @http_request = Net::HTTP::Post.new(uri.request_uri)
26
+ @http_request.body = params.to_json
27
+
28
+ send_request
29
+ end
30
+
31
+ def get
32
+ uri.query = URI.encode_www_form(params) if !params.empty?
33
+ @http_request = Net::HTTP::Get.new(uri.request_uri)
34
+
35
+ send_request
36
+ end
37
+
38
+ def patch
39
+ @http_request = Net::HTTP::Patch.new(uri.request_uri)
40
+ @http_request.body = params.to_json
41
+
42
+ send_request
43
+ end
44
+
45
+ def send_request
46
+ apply_headers
47
+
48
+ response = http.request(http_request)
49
+ Regaliator::Response.new(response)
50
+ end
51
+
52
+ private
53
+
54
+ def build_uri
55
+ protocol = config.secure? ? 'https' : 'http'
56
+ url = ["#{protocol}://#{config.host}", endpoint].join
57
+ URI.parse(url)
58
+ end
59
+
60
+ def build_http
61
+ http = Net::HTTP::Proxy(config.proxy_host,
62
+ config.proxy_port,
63
+ config.proxy_user,
64
+ config.proxy_pass).new(uri.host, uri.port)
65
+
66
+ http.read_timeout = config.read_timeout
67
+ http.open_timeout = config.open_timeout
68
+ http.use_ssl = config.secure?
69
+ http.ssl_version = :TLSv1
70
+
71
+ http
72
+ end
73
+
74
+ def apply_headers
75
+ {
76
+ 'User-Agent' => "Regaliator gem v#{Regaliator::VERSION}",
77
+ 'Accept' => "application/vnd.regalii.v#{config.version}+json",
78
+ 'Content-Type' => CONTENT_TYPE,
79
+ 'Date' => timestamp,
80
+ 'Content-MD5' => content_md5,
81
+ 'Authorization' => authorization
82
+ }.each { |k,v| http_request[k] = v }
83
+ end
84
+
85
+ def authorization
86
+ digest = OpenSSL::Digest.new('sha1')
87
+ auth = Base64.strict_encode64(OpenSSL::HMAC.digest(digest, config.secret_key, canonical_string))
88
+
89
+ "APIAuth #{config.api_key}:#{auth}"
90
+ end
91
+
92
+ def canonical_string
93
+ [CONTENT_TYPE, content_md5, http_request.path, timestamp].join(',')
94
+ end
95
+
96
+ def content_md5
97
+ Digest::MD5.base64digest(http_request.body) if http_request.body
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,40 @@
1
+ require 'json'
2
+ require 'net/http'
3
+
4
+ module Regaliator
5
+ class Response
6
+ PAGINATION_HEADER = 'X-Pagination'.freeze
7
+
8
+ attr_reader :http_response
9
+
10
+ def initialize(http_response)
11
+ @http_response = http_response
12
+ end
13
+
14
+ def data
15
+ @data ||= begin
16
+ JSON::parse(http_response.body).tap do |hsh|
17
+ hsh.merge!('pagination' => pagination) if paginated?
18
+ end
19
+ rescue
20
+ { message: 'Server returned a non-json error' }
21
+ end
22
+ end
23
+
24
+ def success?
25
+ @success ||= http_response.kind_of?(Net::HTTPSuccess)
26
+ end
27
+
28
+ def fail?
29
+ !success?
30
+ end
31
+
32
+ def paginated?
33
+ http_response.key?(PAGINATION_HEADER)
34
+ end
35
+
36
+ def pagination
37
+ @pagination ||= JSON::parse(http_response[PAGINATION_HEADER])
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,11 @@
1
+ require 'regaliator/endpoint'
2
+
3
+ module Regaliator
4
+ module V15
5
+ class Account < Endpoint
6
+ def info
7
+ request('/account').post
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,23 @@
1
+ require 'regaliator/endpoint'
2
+
3
+ module Regaliator
4
+ module V15
5
+ class Bill < Endpoint
6
+ def index(params = {})
7
+ request('/bills', params).post
8
+ end
9
+
10
+ def consult(params = {})
11
+ request('/bill/consult', params).post
12
+ end
13
+
14
+ def pay(params = {})
15
+ request('/bill/pay', params).post
16
+ end
17
+
18
+ def check(params = {})
19
+ request('/bill/check', params).post
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,15 @@
1
+ require 'regaliator/endpoint'
2
+
3
+ module Regaliator
4
+ module V15
5
+ class Biller < Endpoint
6
+ def topups(params = {})
7
+ request('/billers/topups', params).post
8
+ end
9
+
10
+ def utilities(params = {})
11
+ request('/billers/utilities', params).post
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,32 @@
1
+ require 'regaliator/client'
2
+ require 'regaliator/v15/account'
3
+ require 'regaliator/v15/bill'
4
+ require 'regaliator/v15/biller'
5
+ require 'regaliator/v15/rate'
6
+ require 'regaliator/v15/transaction'
7
+
8
+ module Regaliator
9
+ module V15
10
+ class Client < Client
11
+ def account
12
+ Account.new(config)
13
+ end
14
+
15
+ def bill
16
+ Bill.new(config)
17
+ end
18
+
19
+ def biller
20
+ Biller.new(config)
21
+ end
22
+
23
+ def rate
24
+ Rate.new(config)
25
+ end
26
+
27
+ def transaction
28
+ Transaction.new(config)
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,15 @@
1
+ require 'regaliator/endpoint'
2
+
3
+ module Regaliator
4
+ module V15
5
+ class Rate < Endpoint
6
+ def list
7
+ request('/rates').post
8
+ end
9
+
10
+ def history
11
+ request('/rates/history').post
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,23 @@
1
+ require 'regaliator/endpoint'
2
+
3
+ module Regaliator
4
+ module V15
5
+ class Transaction < Endpoint
6
+ def list(params = {})
7
+ request('/transactions', params).post
8
+ end
9
+
10
+ def pay(params = {})
11
+ request('/transaction/pay', params).post
12
+ end
13
+
14
+ def reverse(params = {})
15
+ request('/transaction/reverse', params).post
16
+ end
17
+
18
+ def cancel(params = {})
19
+ request('/transaction/cancel', params).post
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,7 @@
1
+ require 'regaliator/v15/client'
2
+
3
+ module Regaliator
4
+ module V15
5
+ API_VERSION = '1.5'.freeze
6
+ end
7
+ end
@@ -0,0 +1,11 @@
1
+ require 'regaliator/endpoint'
2
+
3
+ module Regaliator
4
+ module V30
5
+ class Account < Endpoint
6
+ def info
7
+ request('/account').get
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,35 @@
1
+ require 'regaliator/endpoint'
2
+
3
+ module Regaliator
4
+ module V30
5
+ class Bill < Endpoint
6
+ def create(params = {})
7
+ request('/bills', params).post
8
+ end
9
+
10
+ def show(id)
11
+ request("/bills/#{id}").get
12
+ end
13
+
14
+ def update(id, params = {})
15
+ request("/bills/#{id}", params).patch
16
+ end
17
+
18
+ def refresh(id)
19
+ request("/bills/#{id}/refresh").post
20
+ end
21
+
22
+ def pay(id, params = {})
23
+ request("/bills/#{id}/pay", params).post
24
+ end
25
+
26
+ def xdata(id)
27
+ request("/bills/#{id}/xdata").get
28
+ end
29
+
30
+ def list(params = {})
31
+ request('/bills', params).get
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,19 @@
1
+ require 'regaliator/endpoint'
2
+
3
+ module Regaliator
4
+ module V30
5
+ class Biller < Endpoint
6
+ def credentials(params = {})
7
+ request('/billers/credentials', params).get
8
+ end
9
+
10
+ def topups(params = {})
11
+ request('/billers/topups', params).get
12
+ end
13
+
14
+ def utilities(params = {})
15
+ request('/billers/utilities', params).get
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,32 @@
1
+ require 'regaliator/client'
2
+ require 'regaliator/v30/account'
3
+ require 'regaliator/v30/bill'
4
+ require 'regaliator/v30/biller'
5
+ require 'regaliator/v30/rate'
6
+ require 'regaliator/v30/transaction'
7
+
8
+ module Regaliator
9
+ module V30
10
+ class Client < Client
11
+ def account
12
+ Account.new(config)
13
+ end
14
+
15
+ def bill
16
+ Bill.new(config)
17
+ end
18
+
19
+ def biller
20
+ Biller.new(config)
21
+ end
22
+
23
+ def rate
24
+ Rate.new(config)
25
+ end
26
+
27
+ def transaction
28
+ Transaction.new(config)
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,15 @@
1
+ require 'regaliator/endpoint'
2
+
3
+ module Regaliator
4
+ module V30
5
+ class Rate < Endpoint
6
+ def list
7
+ request('/rates').get
8
+ end
9
+
10
+ def history
11
+ request('/rates/history').get
12
+ end
13
+ end
14
+ end
15
+ end