Belvo Ruby Gem

Rubygems.org CircleCI (.com) Coveralls github CodeClimate maintainability

📕 Documentation

How to use belvo-ruby: https://belvo-finance.github.io/belvo-ruby/

If you want to check the full documentation about Belvo API: https://developers.belvo.com

Or if you want to more information about:

Installation

Add this line to your application's Gemfile:

gem 'belvo'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install belvo

When your user successfully links their account using the Connect Widget, your implemented callback funciton will return the link_id required to make further API to retrieve information.

require 'belvo'

belvo = Belvo::Client.new(
  'your-secret-id',
  'your-secret-password',
  'sandbox'
)

begin
    # Get the link_id from the result of your widget callback function
    link_id = result_from_callback_function.id 

    belvo.accounts.retrieve(link: link_id)

    belvo.accounts.list.each do |item|
        puts item
    end
rescue Belvo::RequestError => e
    puts e.status_code
    puts e.detail
end

You can also manually create the link using the SDK. However, for security purposes, we highly recommend, that you use the Connect Widget to create the link and follow the Usage (create link via widget) example.

require 'belvo'

belvo = Belvo::Client.new(
  'your-secret-id',
  'your-secret-password',
  'sandbox'
)

begin
    new_link = belvo.links.register( # Creating the link
        institution: 'erebor_mx_retail', 
        username: 'janedoe', 
        password: 'super-secret',
        options: { access_mode: Belvo::Link::AccessMode::SINGLE }
    )

    belvo.accounts.retrieve(link: new_link['id'])

    belvo.accounts.list.each do |item|
        puts item
    end
rescue Belvo::RequestError => e
    puts e.status_code
    puts e.detail
end

Pagination

All list methods only return the first page of results. If you want to iterate by all pages, you will need to specify the page as a parameter:

    #`api/transactions`
    ...
    belvo.transactions.list(params: {page: "2"})
    ...

When the result of your call is nil, this indicates that there are no more pages to iterate over.

Note: If you create a Link without specifying access_mode, the SDK will respect the default value from the API.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install.

To release a new version:

  • Create a new branch from master.
  • Update the version number in version.rb
  • Run bundle exec rake install to update Gemfile.lock version (might need sudo)
  • Create a new pull request for the new version.
  • Once the new version is merged in master, create a tag matching the new version.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/belvo-finance/belvo-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

If you wish to submit a pull request, please be sure check the items on this list:

Code of Conduct

Everyone interacting in the Belvo project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.