Class: Vatsense::Resources::Validate

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

Overview

VAT and EORI number validation

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Validate

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

Parameters:



51
52
53
# File 'lib/vatsense/resources/validate.rb', line 51

def initialize(client:)
  @client = client
end

Instance Method Details

#check(eori_number: nil, requester_vat_number: nil, vat_number: nil, request_options: {}) ⇒ Vatsense::Models::ValidateCheckResponse

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

Check whether a given VAT number or EORI number is valid against live government records.

**VAT validation** checks against UK (HMRC), EU (VIES), Australia, Norway, Switzerland, South Africa, and Brazil records.

**EORI validation** checks against UK and EU records only.

If the external validation service is temporarily unavailable, the API returns a ‘412` error and the request does not count against your usage quota.

Provide either ‘vat_number` or `eori_number`, but not both.

Parameters:

  • eori_number (String)

    The EORI number to validate. Must include the leading 2-character

  • requester_vat_number (String)

    Your own VAT number. If supplied, the response will include a unique

  • vat_number (String)

    The VAT number to validate. Must include the leading 2-character

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

Returns:

See Also:



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/vatsense/resources/validate.rb', line 36

def check(params = {})
  parsed, options = Vatsense::ValidateCheckParams.dump_request(params)
  query = Vatsense::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "validate",
    query: query,
    model: Vatsense::Models::ValidateCheckResponse,
    options: options
  )
end