Browse Source

added extended info checking and attributes

Radu Boncea 6 years ago
parent
commit
6cf8276f67
3 changed files with 25 additions and 4 deletions
  1. 4 2
      README.md
  2. 6 2
      pyVies/api.py
  3. 15 0
      requirements.txt

+ 4 - 2
README.md

@@ -17,7 +17,7 @@ from pyVies import api
 
 try:
     vies = api.Vies()
-    result = vies.request('2785503', 'RO')
+    result = vies.request('RO2785503', 'RO', extended_info=True)
 
     # works as well
     # result = vies.request('RO2785503')
@@ -31,9 +31,11 @@ except api.ViesError as e:
     print (e)
 else:
     print (result)
+    print (result.vatNumber)
+    print(result.valid)
 
 
-# You may also use "clean" to extract vat number and country code
+# You may also use clean to extract vat number and country code
 # The line bellow would print ('2785503', 'RO')
 
 print (vies.clean('RO2785503'))

+ 6 - 2
pyVies/api.py

@@ -111,7 +111,7 @@ class Vies(object):
 
         return vat_number,vat_country_code
 
-    def request(self, vat_number, vat_country_code=None):
+    def request(self, vat_number, vat_country_code=None, extended_info=False):
         result = None
 
         vat_number,vat_country_code = self.clean(vat_number,vat_country_code)
@@ -123,10 +123,14 @@ class Vies(object):
             raise ViesHTTPError('VIES service unreachable. %s' % str(e))
 
         try:
-            result = client.service.checkVat(vat_country_code, vat_number)
+            if extended_info is True:
+                result = client.service.checkVatApprox(vat_country_code, vat_number)
+            else:
+                result = client.service.checkVat(vat_country_code, vat_number)
         except Exception as e:
             raise ViesError('Got error from vies: %s' % str(e))
 
+
         return result
 
 

+ 15 - 0
requirements.txt

@@ -0,0 +1,15 @@
+appdirs==1.4.3
+attrs==18.2.0
+cached-property==1.5.1
+certifi==2018.11.29
+chardet==3.0.4
+defusedxml==0.5.0
+idna==2.8
+isodate==0.6.0
+lxml==4.2.5
+pytz==2018.7
+requests==2.21.0
+requests-toolbelt==0.8.0
+six==1.12.0
+urllib3==1.24.1
+zeep==3.1.0