Class: Valvat::Lookup::HMRC

Inherits:
Base
  • Object
show all
Defined in:
lib/valvat/lookup/hmrc.rb

Constant Summary collapse

PRODUCTION_ENDPOINT_URL =
'https://api.service.hmrc.gov.uk/organisations/vat/check-vat-number/lookup'
SANDBOX_ENDPOINT_URL =
'https://test-api.service.hmrc.gov.uk/organisations/vat/check-vat-number/lookup'
HEADERS =
{
  # https://developer.service.hmrc.gov.uk/api-documentation/docs/reference-guide#versioning
  'Accept' => 'application/vnd.hmrc.2.0+json'
}.freeze

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Valvat::Lookup::Base

Instance Method Details

#performObject



19
20
21
22
23
24
25
# File 'lib/valvat/lookup/hmrc.rb', line 19

def perform
  return { valid: false } unless @options[:uk].is_a?(Hash)

  parse(fetch(endpoint_uri).body)
rescue Valvat::HMRC::AccessToken::Error => e
  { error: e }
end