Ruby
Our API is RESTful and responds in JSON. Gerencianet uses OAuth to provide authorized access to the API. Our NodeJS SDK is already prepared to perform this authentication automatically.
Below, check out the procedures for installing the Gerencianet SDK in Ruby:
Installing via RubyGems
Add this line to your application's Gemfile:
gem 'gerencianet'
And then run:
$ bundle
Or install it as:
$ gem install gerencianet
Testesd with
- Ruby
2.1.0
Basic use
- Ruby
require "gerencianet"
options = {
client_id: "client_id",
client_secret: "client_secret",
sandbox: true
}
gerencianet = Gerencianet.new(options)
charge = {
items: [{
name: "Product A",
value: 1000,
amount: 2
}]
}
response = gerencianet.create_charge(body: charge)
}
Examples
You can run the examples inside the examples
directory with:
$ ruby examples/create_charge.rb
Remember to set the correct credentials inside examples/credentials.rb
before running.
Tests
To run the tests, just run rspec:
$ rspec
Or use guard
to monitor files and automatically run rspec:
$ guard -n false -c