Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handeling different response data #133

Open
whysthatso opened this issue Apr 9, 2024 · 1 comment
Open

Handeling different response data #133

whysthatso opened this issue Apr 9, 2024 · 1 comment

Comments

@whysthatso
Copy link

First of, thank you for the work put into this.

I usually verify only German and Estonian VAT-IDs, but now i came across a Spanish one and my integration blew up.

Turns out the "Spanish response" includes a bunch of abstract test result fields:

(VAT ID anonymized)

pry> Valvat.new("ESZ1234567R").exists?(requester:  "IE6388047V")  
=> {
:country_code=>"ES", 
:vat_number=>"Z1234567R", 
:request_date=>Tue, 09 Apr 2024, 
:valid=>true, 
:name=>nil, 
:company_type=>nil, 
:name_match=>"3", 
:company_type_match=>"3", 
:street_match=>"3",
:postcode_match=>"3",
:city_match=>"3", 
:request_identifier=>"3bf3997c-9113-45ca-a0d8-f46211377caa"
}

pry> Valvat.new("EE123456789").exists?(requester:  "IE6388047V")
=> {:country_code=>"EE", 
:vat_number=>"123456789", 
:request_date=>Tue, 09 Apr 2024, 
:valid=>true, 
:name=>"Whyservices OÜ", 
:company_type=>nil, 
:address=>"Tänav tn 1 4 10142 Kesklinna linnaosa Tallinn", 
:request_identifier=>"WAPIAAAAY7BwlWoW"}

I'm using this in rails and what i currently do is

  1. take the hash and mutate some keys into different ones that go along my Vat Model's attribute names
  2. assign_attributes that hash to a Vat Model

This worked until it suddenly had these unexpected keys in the "Spanish response".

I understand that the Gem just pushes all the response field pairs into a hash and that's it. Also, there is no way to add country specific validation data to the request (i.e. company name, address, etc), right?

So my questions are:

  1. Is there a set of response key/value pairs that are reliable for every country?
  2. What does one usually do with the rest of the hash?

I could imagine i strip out the expectable key/values and then shove the rest into a jsonb column, never to be seen again? Maybe do something later with it or show it in a view for manual verification, etc. The Estonians send down everything, Germans nothing, and Spaniards comparison values. Not sure what other countries do.

@whysthatso
Copy link
Author

and additional a kind of legal question: if one verifies the VAT ID and has the option to verify the address/name/etc, is one obliged to do that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant