Regaliator
Ruby wrapper for Regalii's API. The full API docs:
Installation
Add this line to your application's Gemfile:
gem 'regaliator', github: 'regalii/regaliator'
And then execute:
$ bundle
Configuration
Add the following to config/initializers/regaliator.rb:
Regaliator.configure do |config|
config.version = '3.1'
config.api_key = 'your-api-key'
config.secret_key = 'your-secret-key'
config.host = 'api.casiregalii.com'
config.open_timeout = 5
config.read_timeout = 60
config.use_ssl = true
config.proxy_host = nil
config.proxy_port = nil
config.proxy_user = nil
config.proxy_pass = nil
end
Versions
To switch the version API, you have just to set the version in the configuration,
for instance, the version 1.5
:
Regaliator.configure do |config|
config.version = '1.5'
end
The available versions are: 1.5
, 3.0
and 3.1
(recommended).
Requests
Success:
> response = Regaliator.bill.show(1)
> response.success?
=> true
> response.data
=> {...}
> response = Regaliator.bill.pay(1, amount: 13.0, currency: 'MXN')
> response.success?
=> true
> response.data
=> {...}
Failure:
> response = Regaliator.bill.pay(biller_id: 1, account_number: '12345', amount: 0.0, currency: 'MXN')
> response.success?
=> false
> response.data
=> {"code" => "R3", "message" => "Invalid Payment Amount"}
Examples
The following examples will show how to use the Regaliator gem to connect to the different Regalii API endpoints.
Billers List
https://www.regalii.com/billers
response = Regaliator.biller.utilities
Tests
To run the tests, run:
$ bundle exec rake test
To test on each file change, run:
$ bundle exec guard