Belvo Ruby Gem

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

🚨 Limited maintenance until 31.12.2023

Please be advised that this SDK has transitioned to limited maintenance mode and will no longer receive updates for new features. Essential security updates will continue to be provided until December 31, 2023.

After this date, the SDK will be archived and no further updates will be released. While you are welcome to continue using the code please note that you will be solely responsible for managing and implementing any required security patches or updates.

đź“• Documentation

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

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

Or if you want to more information about: * Getting Belvo API keys * Using Connect Widget * Testing in sandbox * Using webhooks and recurrent links

Installation

Add this line to your application’s Gemfile:

gem 'belvo'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install belvo

Usage (create link via widget)

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

Usage (create link via SDK)

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 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: - [ ] Tests related to the changed code were executed - [ ] The source code has been coded following the OWASP security best practices (owasp.org/www-pdf-archive/OWASP_SCP_Quick_Reference_Guide_v2.pdf). - [ ] Commit message properly labeled - [ ] There is a ticket associated to each PR.

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.