0.0
No commit activity in last 3 years
No release in over 3 years
FixerCurrency extends Money::Bank::Base and gives you access to the current fixer.io exchange rates.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 3.0.0
>= 0.5.8

Runtime

~> 6.7
 Project Readme

Fixer Currency

This gem extends Money::Bank::VariableExchange with Money::Bank::FixerCurrency and gives you access to the current fixer.io exchange rates.

This gem was forked from the Money::Bank::GoogleCurrency gem.

Installation

If the money gem is not already installed:

gem install money

Install the fixer_currency gem:

gem install fixer_currency

Usage

require 'money'
require 'money/bank/fixer_currency'

# (optional)
# set the seconds after than the current rates are automatically expired
# by default, they never expire
Money::Bank::FixerCurrency.ttl_in_seconds = 86400

# set default bank to instance of FixerCurrency with access key parameter
# being your access_key from fixer.io
Money.default_bank = Money::Bank::FixerCurrency.new('your_access_key')

# create a new money object, and use the standard #exchange_to method
money = Money.new(1_00, "USD") # amount is in cents
money.exchange_to(:EUR)

# or install and use the 'monetize' gem
require 'monetize'
money = 1.to_money(:USD)
money.exchange_to(:EUR)

An UnknownRate will be thrown if #exchange_to is called with a Currency that Money knows, but fixer.io does not.

An UnknownCurrency will be thrown if #exchange_to is called with a Currency that Money does not know.

A FixerCurrencyFetchError will be thrown if there is an unknown issue with parsing the response including rates from fixer.io's API.

Caveats

This gem uses fixer.io under the hood.