Class: Valvat::Lookup::Base

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

Direct Known Subclasses

HMRC, VIES

Instance Method Summary collapse

Constructor Details

#initialize(vat, options = {}) ⇒ Base

Returns a new instance of Base.



9
10
11
12
13
14
# File 'lib/valvat/lookup/base.rb', line 9

def initialize(vat, options = {})
  @vat = Valvat(vat)
  @options = Valvat::Options(options)
  @requester = @options[:requester] && Valvat(@options[:requester])
  @rate_limit = @options[:rate_limit]
end

Instance Method Details

#performObject



16
17
18
19
20
21
22
23
24
25
# File 'lib/valvat/lookup/base.rb', line 16

def perform
  response = fetch(endpoint_uri)

  case response
  when Net::HTTPSuccess
    parse(response.body)
  else
    { error: Valvat::HTTPError.new(response.code, self.class) }
  end
end