The Ruby gem for accessing the Vatlayer API painlessly, easily and awesomely! Be sure to check the branch for the version you're using.
Important and helpful links:
Add this line to your application's Gemfile:
gem 'vatlayer'
And then execute:
$ bundle
Or install it yourself as:
$ gem install vatlayer
require 'vatlayer'
vatlayer = Vatlayer.new('Your API access key')
You can find your API key in your Vatlayer account, by reference. API access is available for every Vatlayer account.
API keys must be configured in the gem setup. You can do this anywhere in your application before you make API calls using the gem. You can find your API key in your Vatlayer account, by reference. API access is available for every Vatlayer account.
Vatlayer.configure do |config|
config.access_key = 'a1sad2f4g2srf'
config.https = true
end
config.access_key
- your Vatlayer access keyconfig.https
- you can use https mode, defaultfalse
Please note that the https configuration is optional and only available to paid-accounts. If unset, these configuration-values are just nil.
Creating an instance of the Vatlayer client:
vatlayer = Vatlayer.new('Your API access key')
If you've configured the gem with a default access_key
, then you can just instantiate the class.
vatlayer = Vatlayer.new
vatlayer.validate(vat_number: 'LU26375245')
# <Vatlayer::Response::Data:0x0000555fd334ba10
# @valid=true,
# @database="ok",
# @format_valid=true,
# @query="LU26375245",
# @country_code="LU",
# @vat_number="26375245",
# @company_name="AMAZON EUROPE CORE S.A R.L.",
# @company_address="5, RUE PLAETIS L-2338 LUXEMBOURG">
vatlayer.rate(country_code: 'gb')
# <Vatlayer::Response::Data:0x000055c949f35210
# @success=true,
# @country_code="GB",
# @country_name="United Kingdom",
# @standard_rate=20,
# @reduced_rates=#<Vatlayer::Response::Data:0x000055c949f344f0
# @property_renovations=5,
# @foodstuffs=0,
# @books=0,
# @pharmaceuticals=0,
# @medical=0,
# @passenger_transport=0,
# @newspapers=0,
# @childrens_clothing=0>>
Also rate method takes parameters like ip_address
, use_client_ip
.
vatlayer.rate_list
# <Vatlayer::Response::Data:0x0000564e0063b308
# @rates=#<Vatlayer::Response::Data:0x0000564e00639d78
# @at=#<Vatlayer::Response::Data:0x0000564e00638b30
# @country_name="Austria",
# @reduced_rates=#<Vatlayer::Response::Data:0x0000564e0062e270
# @admission_to_cultural_events=10,
# @admission_to_entertainment_events=10,
# @books=10,
# @foodstuffs=10,
# @hotels=10,
# @newspapers=10,
# @passenger_transport=10,
# @pharmaceuticals=10>,
# @standard_rate=20>
vatlayer.price(amount: 100, country_code: 'GB', options: { type: 'medical' })
# <Vatlayer::Response::Data:0x00005564aa23e880
# @success=true,
# @country_code="GB",
# @country_name="United Kingdom",
# @price_excl_vat=100,
# @price_incl_vat=100,
# @type="medical",
# @vat_rate=0>
Also price method takes parameters like ip_address
, use_client_ip
and optional parameters type
, incl
.
vatlayer = Vatlayer.new('invalid_access_key')
vatlayer.validate('LU26375245')
# <Vatlayer::Response::Data:0x0000555fd3379c80
# @success=false,
# @error=#<Vatlayer::Response::Error:0x0000555fd33797d0
# @code=101,
# @type="invalid_access_key",
# @info="You have not supplied a valid API Access Key. [Technical Support: [email protected]]">
The Vatlayer GEM is released under the MIT License.
- Fork it
- 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