AEAT-WEB-SERVICES
Master |
|
|
Spanish Tax Agency Electronic Office (AEAT) Integration.
Make requests AEAT Web Services and sign your connection and xml using your certificate.
Integración con la Agencia Estatal de Administración Tributaria Española
Realiza peticiones a los Servicios Web de AEAT y firma tu conexión y mensajes XML utilizando tu certificado.
Usage (English)
Example for requesting a list of ENS’s.
Initialize a Config object with the desired preconfigured service and if you want to request AEAT test or production endpoints (test_mode). Finally initialize controller with the config and the desired certificate and make the request with your payload.
If you need more control just build the controller by hand, see build_from_config method for inspiration.
import aeat
config = aeat.Config('ens_presentation', test_mode=True)
ctrl = aeat.Controller.build_from_config(config, 'cert.pem', 'key.pem')
result = ctrl.request(payload) # See factories for examples
assert result.valid, f'Error requesting aeat: {result.error}'
assert result.data is not None
Usage (Spanish)
Ejemplo de consulta de ENSs.
Inicializa el objecto Config con el servicio preconfigurado y si quieres usar los endpoints de AEAT de test o de producción (test_mode). Por último inicializa el controlador con la config y el certificado que gustes y realiza la petición pasándole los datos que necesites.
Si necesitas un mayor control simplemente construye el controlador a mano, puedes inspirarte en el método build_from_config.
import aeat
config = aeat.Config('ens_presentation', test_mode=True)
ctrl = aeat.Controller.build_from_config(config, 'cert.pem', 'key.pem')
result = ctrl.request(payload) # Ver factories para ejemplos
assert result.valid, f'Error requesting aeat: {result.error}'
assert result.data is not None
Django Rest Framework
Several AEAT Validators and Serializers are provided.
Validators: Validate input data to send to AEAT
Serializers: Serialize AEAT request
from aeat.rest_framework import validators
validator = validators.ENSPresentationValidator(data=payload)
assert validator.is_valid(raise_exception=True)
# Send the request to AEAT
import aeat
config = aeat.Config(service_name, test_mode=settings.AEAT_TEST_MODE)
ctrl = aeat.Controller.build_from_config(config, cert_path, key_path)
result = ctrl.request(validator.data)
assert result.valid
# Parse the response
from aeat.rest_framework import serializers
serializer = serializers.get_class_for_aeat_response(data=result.data)
assert serializer.is_valid(raise_exception=False)
assert {'mrn': 'XXXX'} == serializer.data
assert not serializer.is_error
Prerequisites
Install xmlsec prerequisites. Check https://github.com/mehcode/python-xmlsec
Install
$ pip install aeat-web-services
Develop
$ python setup.py develop
$ pip install -r requirements_test.txt
Test
$ pip install tox
$ tox
Releases
Usefull Links
Metadata
Release files for aeat-web-services 2.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| aeat-web-services-2.0.2.tar.gz | 62.6 kB | Without provenance | Details for aeat-web-services-2.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| aeat_web_services-2.0.2-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for aeat_web_services-2.0.2-py2.py3-none-any.whl |
Total release size: 80.2 kB
Release files / aeat-web-services-2.0.2.tar.gz
| Download URL | aeat-web-services-2.0.2.tar.gz |
|---|---|
| Size | 62.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d3ba04026ea2b95caa5f5692e788e1618f190d4468f6d0ff868c169025ea552a
|
|
BLAKE2b-256 checksum How to use checksums |
15627d3decb075126332d9931cfbc504b7a548cddb1c56bcdde782b14c4ec286
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / aeat_web_services-2.0.2-py2.py3-none-any.whl
| Download URL | aeat_web_services-2.0.2-py2.py3-none-any.whl |
|---|---|
| Size | 17.6 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
a0b8c90f47c1bef4d12bda9dd19b639131611d68e0c33739e2f6a368cdfbc7c6
|
|
BLAKE2b-256 checksum How to use checksums |
97dc19b8db428f9fdc63acccbf0498de2333ee22d066546027802fbdd0b7d537
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for aeat-web-services 2.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.