Class: Vatsense::Resources::Rates
- Inherits:
-
Object
- Object
- Vatsense::Resources::Rates
- Defined in:
- lib/vatsense/resources/rates.rb
Overview
VAT/GST rate lookups for countries worldwide
Instance Method Summary collapse
-
#calculate_price(price:, tax_type:, country_code: nil, eu: nil, ip_address: nil, province_code: nil, type: nil, request_options: {}) ⇒ Vatsense::Models::RateCalculatePriceResponse
Some parameter documentations has been truncated, see Models::RateCalculatePriceParams for more details.
-
#details(country_code: nil, eu: nil, ip_address: nil, period: nil, province_code: nil, type: nil, request_options: {}) ⇒ Vatsense::Models::FindRate
Some parameter documentations has been truncated, see Models::RateDetailsParams for more details.
-
#find(country_code: nil, eu: nil, ip_address: nil, period: nil, province_code: nil, type: nil, request_options: {}) ⇒ Vatsense::Models::FindRate
Some parameter documentations has been truncated, see Models::RateFindParams for more details.
-
#initialize(client:) ⇒ Rates
constructor
private
A new instance of Rates.
-
#list(country_code: nil, eu: nil, ip_address: nil, period: nil, request_options: {}) ⇒ Vatsense::Models::RateListResponse
Some parameter documentations has been truncated, see Models::RateListParams for more details.
-
#list_types(request_options: {}) ⇒ Vatsense::Models::RateListTypesResponse
Returns a list of all available product types that can be used to filter tax rates.
Constructor Details
#initialize(client:) ⇒ Rates
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 Rates.
185 186 187 |
# File 'lib/vatsense/resources/rates.rb', line 185 def initialize(client:) @client = client end |
Instance Method Details
#calculate_price(price:, tax_type:, country_code: nil, eu: nil, ip_address: nil, province_code: nil, type: nil, request_options: {}) ⇒ Vatsense::Models::RateCalculatePriceResponse
Some parameter documentations has been truncated, see Models::RateCalculatePriceParams for more details.
Combines the functionality of the “Find a tax rate” and “VAT price calculation” endpoints to return the particular VAT price for an applicable VAT rate. Requires both a location (country_code or ip_address) and a price to calculate.
71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/vatsense/resources/rates.rb', line 71 def calculate_price(params) parsed, = Vatsense::RateCalculatePriceParams.dump_request(params) query = Vatsense::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: "rates/price", query: query, model: Vatsense::Models::RateCalculatePriceResponse, options: ) end |
#details(country_code: nil, eu: nil, ip_address: nil, period: nil, province_code: nil, type: nil, request_options: {}) ⇒ Vatsense::Models::FindRate
Some parameter documentations has been truncated, see Models::RateDetailsParams for more details.
Get detailed tax rate information for a location, including all applicable rate classes (standard, reduced, zero, etc.).
108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/vatsense/resources/rates.rb', line 108 def details(params = {}) parsed, = Vatsense::RateDetailsParams.dump_request(params) query = Vatsense::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: "rates/tax_rate", query: query, model: Vatsense::FindRate, options: ) end |
#find(country_code: nil, eu: nil, ip_address: nil, period: nil, province_code: nil, type: nil, request_options: {}) ⇒ Vatsense::Models::FindRate
Some parameter documentations has been truncated, see Models::RateFindParams for more details.
A handy endpoint for finding a rate that applies to a particular country and optional product type, based on country code or IP address.
If no type is provided, or no specific rate is applied to the given type, then the standard rate will be returned if the country is subject to tax.
If the country is not subject to VAT/GST then an error response will be returned, indicating no tax applies.
151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/vatsense/resources/rates.rb', line 151 def find(params = {}) parsed, = Vatsense::RateFindParams.dump_request(params) query = Vatsense::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: "rates/rate", query: query, model: Vatsense::FindRate, options: ) end |
#list(country_code: nil, eu: nil, ip_address: nil, period: nil, request_options: {}) ⇒ Vatsense::Models::RateListResponse
Some parameter documentations has been truncated, see Models::RateListParams for more details.
Returns a list of VAT/GST rates for all countries, sorted alphabetically by country code. Each rate is returned as a rate object containing the standard rate and any other applicable rates.
You can optionally filter by country code, IP address, or EU membership.
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/vatsense/resources/rates.rb', line 31 def list(params = {}) parsed, = Vatsense::RateListParams.dump_request(params) query = Vatsense::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: "rates", query: query, model: Vatsense::Models::RateListResponse, options: ) end |
#list_types(request_options: {}) ⇒ Vatsense::Models::RateListTypesResponse
Returns a list of all available product types that can be used to filter tax rates.
173 174 175 176 177 178 179 180 |
# File 'lib/vatsense/resources/rates.rb', line 173 def list_types(params = {}) @client.request( method: :get, path: "rates/types", model: Vatsense::Models::RateListTypesResponse, options: params[:request_options] ) end |