BankCredentials is a tiny wrapper for keeping together bank credentials for HBCI or Ebics.
Add this line to your application's Gemfile:
gem 'bank_credentials'
And then execute:
$ bundle
Or install it yourself as:
$ gem install bank_credentials
Ebics credentials require the following attributes:
- key
- Host URL of the ebics server
- Host ID
- Partner ID
- Passphrase
Take a credentials hash and initialize an BankCredentials::Ebics
instance with it.
credential_hash = {
key: "key",
url: "url",
host_id: "host_id",
user_id: "user_id",
partner_id: "partner_id"
passphrase: "passphrase",
}
credentials = BankCredentials::Ebics.new(credential_hash)
At initialization, the completeness of the attributes will be validated. If they are invalid, BankCredentials::Error::Invalid
will be raised.
To create an instance from a base64 encoded json string, use .from_encoded_json
:
credential_hash = {
key: "key",
url: "url",
host_id: "host_id",
user_id: "user_id",
partner_id: "partner_id"
passphrase: "passphrase",
}
encoded_json = Base64.decode64(credential_hash.to_json)
credentials = BankCredentials::Ebics.from_encoded_json(encoded_json)
When the given argument is not valid json, BankCredentials::Errors::Invalid
will be raised.
Attribute accessors are provided:
credentials.key # => "key"
credentials.host_id # => "host_id"
credentials.partner_id # => "partner_id"
credentials.user_id # => "user_id"
credentials.passphrase # => "passphrase"
Ebics credentials require the following attributes:
- Host URL of the HBCI server
- Bank code
- user id
- pin
Take a credentials hash and initialize an BankCredentials::Hbci
instance with it.
credential_hash = {
url: "url",
bank_code: "bank_code",
user_id: "user_id",
pin: "pin"
}
credentials = BankCredentials::Hbci.new(credential_hash)
At initialization, the completeness of the attributes will be validated. If they are invalid, BankCredentials::Error::Invalid
will be raised.
To create an instance from a base64 encoded json string, use .from_encoded_json
:
credential_hash = {
url: "url",
user_id: "user_id",
bank_code: "bank_code",
pin: "pin"
}
encoded_json = Base64.decode64(credential_hash.to_json)
credentials = BankCredentials::Hbci.from_encoded_json(encoded_json)
When the given argument is not valid json, BankCredentials::Errors::Invalid
will be raised.
Attribute accessors are provided:
credentials.pin # => "pin"
credentials.url # => "url"
credentials.user_id # => "user_id"
After checking out the repo, run bin/setup
to install dependencies. Then, run rake rspec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
Bug reports and pull requests are welcome on GitHub at https://github.com/bank_credentials.
The gem is available as open source under the terms of the MIT License.