Sha256: 8a5a142b60ddf5158fd8dea518621af0f7cd3f8d4c9efd16580454e0af596813

Contents?: true

Size: 721 Bytes

Versions: 2

Compression:

Stored size: 721 Bytes

Contents

# frozen_string_literal: true

class Quaderno::TaxId < Quaderno::Base
  api_model Quaderno::TaxId
  api_path 'tax_ids'
  is_a_document? false

  def self.validate(country, tax_id, options = {})
    authentication = get_authentication(options.merge(api_model: api_model))

    response = get("#{authentication[:url]}#{api_path}/validate.json",
      query: { country: country, tax_id: tax_id },
      basic_auth: authentication[:basic_auth],
      headers: default_headers.merge(authentication[:headers])
    )

    check_exception_for(response, { rate_limit: true, subdomain_or_token: true, id: true })

    data = new({ valid: response.parsed_response['valid'] })
    data.rate_limit_info = response

    data
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
quaderno-3.0.1 lib/quaderno-ruby/tax_id.rb
quaderno-3.0.0 lib/quaderno-ruby/tax_id.rb