Europe.cr
This shard provides EU governmental data, extracted from various EU / EC websites. With this shard you can validate VAT numbers, retrieve VAT tax rates and currency exchange rates matched to the Euro. How to use this library is pretty straightforward and written below.
Table of Contents
Installation
Add this to your application's shard.yml
:
dependencies:
europe:
github: VvanGemert/europe.cr
Usage
First require the library;
require "europe"
There are several calls you can make with this library. Below are a few examples where this library can be used for.
Validating VAT numbers
** Updated: Parameter now consists of one value.** Call to validate VAT number (always starts with country code as specified in VIES)
Europe::Vat.validate("GB440627467")
Response
{ valid: true,
country_code: "GB",
vat_number: "440627467",
request_date: "2018-06-16+02:00",
name: "SKY PLC",
address: nil }
Validate VAT number format
Call
Europe::Vat::Format.validate("NL123456789B01")
Response
=> true
Retrieving VAT rates for each EC/EU member
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...
Retrieving currency exchange rates
Call
Europe::Currency::ExchangeRates.retrieve
Response
{ :date => 2018-06-15 00:00:00.0 UTC,
:rates =>
{ "USD" => 1.099,
"JPY" => 132.97,
"BGN" => 1.9558,
"CZK" => 27.022,
"DKK" => 7.4614,
"GBP" => 0.7252,
# etc...
Retrieving currency information
Call
Europe::Currency::CURRENCIES
Response
CURRENCIES = {
EUR: { name: "Euro", symbol: "€", html: "€" },
BGN: { name: "Lev", symbol: "лв", html: "лв" },
# etc...
Retrieving country information
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...
Retrieving country information reversed
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...
Compatibility
This library is tested with the following Crystal versions on Linux and Mac OS X:
- 0.27.x
- 0.28.0
- 0.29.0
- 0.32.1
Todo
- Generate docs
- Cleanup the code
- Eurostat integration (http://ec.europa.eu/eurostat/)
- ..
Contributing
- Fork it ( https://github.com/VvanGemert/europe.cr/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
Contributors
- VvanGemert vvangemert - creator, maintainer