FidorApi
Simple ruby client for the Fidor Bank REST-API: http://docs.fidor.de
💡 This branch contains the 0.x.x / 1.x.x versions. For 2.x.x versions see master branch.
Installation
Add this line to your application's Gemfile:
gem 'fidor_api'
And then execute:
$ bundle
Or install it yourself as:
$ gem install fidor_api
Usage
0. Configure
FidorApi.configure do |config|
config.oauth_url = ENV["FIDOR_OAUTH_URL"]
config.api_url = ENV["FIDOR_API_URL"]
config.callback_url = ENV["FIDOR_API_CALLBACK"]
config.client_id = ENV["FIDOR_API_CLIENT_ID"]
config.client_secret = ENV["FIDOR_API_CLIENT_SECRET"]
config.htauth_user = ENV["FIDOR_API_HTAUTH_USER"]
config.htauth_password = ENV["FIDOR_API_HTAUTH_PASSWORD"]
config.affiliate_uid = ENV["FIDOR_API_AFFILIATE_UID"]
end
1. oAuth (Rails)
Redirect the user to the authorize URL:
redirect_to FidorApi::Auth.
Use code passed to the callback URL and fetch the access token:
session[:api_token] = FidorApi::Auth.fetch_token(params[:code]).to_hash
Renew token after it has expired:
def api_token
FidorApi::Token.new session[:api_token] if session[:api_token]
end
if api_token && !api_token.valid?
session[:api_token] = FidorApi::Auth.refresh_token(api_token).to_hash
end
2. Fetching data
FidorApi::Connectivity.access_token = "f859032a6ca0a4abb2be0583b8347937"
user = FidorApi::User.current
# => FidorApi::User
transactions = FidorApi::Transaction.all
# => FidorApi::Collection
transaction = transactions.first
# => FidorApi::Transaction
3. Creating transfers
FidorApi::Connectivity.access_token = "f859032a6ca0a4abb2be0583b8347937"
transfer = FidorApi::Transfer::Internal.new(
account_id: 875,
receiver: "[email protected]",
external_uid: "4279762F5",
subject: "Money for you",
amount: 1000
)
# => FidorApi::Transfer::Internal
transfer.save
# => true
# or
# => false and `transfer.errors` containing details
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.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/fidor/fidor_api.
Changelog
Have a look at the CHANGELOG for details.
License
The gem is available as open source under the terms of the MIT License.