Class: Vatsense::Resources::Currency
- Inherits:
-
Object
- Object
- Vatsense::Resources::Currency
- Defined in:
- lib/vatsense/resources/currency.rb
Overview
Currency exchange rates and conversion
Instance Method Summary collapse
-
#calculate_vat_price(price:, tax_type:, vat_rate:, request_options: {}) ⇒ Vatsense::Models::CurrencyCalculateVatPriceResponse
Some parameter documentations has been truncated, see Models::CurrencyCalculateVatPriceParams for more details.
-
#convert(amount:, from:, to:, request_options: {}) ⇒ Vatsense::Models::CurrencyConvertResponse
Some parameter documentations has been truncated, see Models::CurrencyConvertParams for more details.
-
#initialize(client:) ⇒ Currency
constructor
private
A new instance of Currency.
-
#list(from: nil, to: nil, request_options: {}) ⇒ Vatsense::Models::CurrencyListResponse
Some parameter documentations has been truncated, see Models::CurrencyListParams for more details.
Constructor Details
#initialize(client:) ⇒ Currency
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Currency.
106 107 108 |
# File 'lib/vatsense/resources/currency.rb', line 106 def initialize(client:) @client = client end |
Instance Method Details
#calculate_vat_price(price:, tax_type:, vat_rate:, request_options: {}) ⇒ Vatsense::Models::CurrencyCalculateVatPriceResponse
Some parameter documentations has been truncated, see Models::CurrencyCalculateVatPriceParams for more details.
Calculate the inclusive and exclusive VAT price on a given amount and VAT rate. This is a standalone calculation that does not look up rates by country.
57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/vatsense/resources/currency.rb', line 57 def calculate_vat_price(params) parsed, = Vatsense::CurrencyCalculateVatPriceParams.dump_request(params) query = Vatsense::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: "currency/price", query: query, model: Vatsense::Models::CurrencyCalculateVatPriceResponse, options: ) end |
#convert(amount:, from:, to:, request_options: {}) ⇒ Vatsense::Models::CurrencyConvertResponse
Some parameter documentations has been truncated, see Models::CurrencyConvertParams for more details.
Convert a foreign currency amount to either GBP or EUR using official exchange rates.
GBP rates are from HMRC (updated on the 1st of every month). EUR rates are from the European Central Bank (updated around 16:00 CET on working days).
91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/vatsense/resources/currency.rb', line 91 def convert(params) parsed, = Vatsense::CurrencyConvertParams.dump_request(params) query = Vatsense::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: "currency/convert", query: query, model: Vatsense::Models::CurrencyConvertResponse, options: ) end |
#list(from: nil, to: nil, request_options: {}) ⇒ Vatsense::Models::CurrencyListResponse
Some parameter documentations has been truncated, see Models::CurrencyListParams for more details.
Returns a list of all currency conversion rates sourced from HMRC (GBP) and the European Central Bank (EUR).
You can optionally filter by source and target currency.
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/vatsense/resources/currency.rb', line 26 def list(params = {}) parsed, = Vatsense::CurrencyListParams.dump_request(params) query = Vatsense::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: "currency", query: query, model: Vatsense::Models::CurrencyListResponse, options: ) end |