This gem provides EU governmental data, extracted from various EU / EC websites. With this gem you can validate VAT numbers, retrieve VAT tax rates and currency exchange rates matched to the Euro. How to use this gem is pretty straightforward and written below.
Add this line to your application's Gemfile:
gem 'europe'
And then execute:
$ bundle
Or install it yourself as:
$ gem install europe
There are several calls you can make with this gem. Below are a few examples where this gem can be used for.
** Updated: Parameter now consists of one value.** Call to validate VAT number (always starts with country code as specified in VIES)
Europe::Vat.validate('NL009291477B01')
Response
{ :country_code => "NL",
:vat_number => "009291477B01",
:request_date => #<Date: 2015-12-15 ((2457372j,0s,0n),+0s,2299161j)>,
:valid => true,
:name => "KONINKLIJKE POSTNL B.V.",
:address => nil }
Call
Europe::Vat::Format.validate('NL123456789B01')
Response
=> true
Call
Europe::Postal.validate('NL', '1000 AP')
Response
=> true
Call
Europe::Vat::Rates.retrieve
Response
{ :AT=>20.0,
:BE=>21.0,
:BG=>20.0,
:CY=>19.0,
:CZ=>21.0,
:DE=>19.0,
:DK=>25.0,
# etc...
Call
Europe::Currency::ExchangeRates.retrieve
Response
{ :date=>#<Date: 2015-12-15 ((2457372j,0s,0n),+0s,2299161j)>,
:rates=>
{ :USD=>1.099,
:JPY=>132.97,
:BGN=>1.9558,
:CZK=>27.022,
:DKK=>7.4614,
:GBP=>0.7252,
# etc...
Call
Europe::Currency::CURRENCIES
Response
CURRENCIES = {
EUR: { name: 'Euro', symbol: '€', html: '€' },
BGN: { name: 'Lev', symbol: 'лв', html: 'лв' },
# etc...
Call
Europe::Countries::COUNTRIES
Response
{
:BE=>
{:name=>"Belgium",
:source_name=>"Belgique/België",
:official_name=>"Kingdom of Belgium",
:tld=>".be",
:currency=>:EUR,
:capital=>"Brussels"},
:BG=>
{:name=>"Bulgaria",
:source_name=>"България",
:official_name=>"Republic of Bulgaria",
:tld=>".bg",
:currency=>:BGN,
:capital=>"Sofia"},
# etc...
Call with optional parameters (name, currency, source_name, official_name, tld, currency and capital)
Europe::Countries::Reversed.generate('name')
Response
{ "Belgium" => :BE,
"Bulgaria" => :BG,
"Czech Republic" => :CZ,
"Denmark" => :DK,
"Germany" => :DE,
"Estonia" => :EE,
# etc...
This gem is tested with the following Ruby versions on Linux and Mac OS X:
- Ruby > 2.2.2
VAT number format validation (http://ec.europa.eu/taxation_customs/vies/faqvies.do#item11)Add more country information- Eurostat integration (http://ec.europa.eu/eurostat/)
- ..
- Fork it ( https://github.com/gem-shards/europe.rb/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request