0.0
No release in over 3 years
Low commit activity in last 3 years
Access XE currency rate data.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.13
~> 10.0
~> 3.0

Runtime

~> 6.7
>= 1.7.2, ~> 1.7
 Project Readme

XeCurrency

This gem extends Money::Bank::VariableExchange with Money::Bank::XeCurrency and gives you access to the current rates from the XE currency converter.

Usage

require 'xe_currency'

client = XeCurrency::Client.new(
                                account_api_id: '<Account API ID>',
                                account_api_key: '<Account API Key>')

client.fetch_rate('USD', 'EUR')
client.fetch_rates('USD', ['EUR', 'JPY'])
require 'money'
require 'money/bank/xe_currency'

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

# set default bank to instance of XeCurrency
Money.default_bank =
  Money::Bank::XeCurrency.new(
    Money::RatesStore::Memory.new,
    account_api_id: '<Account API ID>',
    account_api_key: '<Account API 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)

License

The gem is available as open source under the terms of the MIT License.