Class: Vatsense::Resources::Countries

Inherits:
Object
  • Object
show all
Defined in:
lib/vatsense/resources/countries.rb

Overview

Country and province information

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Countries

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 Countries.

Parameters:



65
66
67
# File 'lib/vatsense/resources/countries.rb', line 65

def initialize(client:)
  @client = client
end

Instance Method Details

#list(country_code: nil, ip_address: nil, request_options: {}) ⇒ Vatsense::Models::CountryListResponse

Some parameter documentations has been truncated, see Models::CountryListParams for more details.

Returns a list of all countries, including whether they are subject to VAT/GST and whether they are subject to EU VAT. Each country is returned as a country object.

You can optionally filter by country code or IP address.

Parameters:

  • country_code (String)

    A 2-character ISO 3166-1 alpha-2 country code (e.g. “GB”, “FR”).

  • ip_address (String)

    An IPv4 or IPv6 address. If provided, the country will be determined from the IP

  • request_options (Vatsense::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/vatsense/resources/countries.rb', line 27

def list(params = {})
  parsed, options = Vatsense::CountryListParams.dump_request(params)
  query = Vatsense::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "countries",
    query: query,
    model: Vatsense::Models::CountryListResponse,
    options: options
  )
end

#list_provinces(country_code:, request_options: {}) ⇒ Vatsense::Models::CountryListProvincesResponse

Retrieve a list of all provinces within a given country.

Parameters:

  • country_code (String)

    A 2-character ISO 3166-1 alpha-2 country code (e.g. “CA”).

  • request_options (Vatsense::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



50
51
52
53
54
55
56
57
58
59
60
# File 'lib/vatsense/resources/countries.rb', line 50

def list_provinces(params)
  parsed, options = Vatsense::CountryListProvincesParams.dump_request(params)
  query = Vatsense::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "countries/provinces",
    query: query,
    model: Vatsense::Models::CountryListProvincesResponse,
    options: options
  )
end