Skip to content

Commit

Permalink
Tidy up URLs
Browse files Browse the repository at this point in the history
This is a lot easier to read.
  • Loading branch information
WhyNotHugo committed Apr 8, 2024
1 parent a162df2 commit 6fe2498
Showing 1 changed file with 14 additions and 21 deletions.
35 changes: 14 additions & 21 deletions django_afip/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,18 @@

# Each boolean field is True if the URL is a sandbox/testing URL.
WSDLS = {
("wsaa", False): "https://wsaa.afip.gov.ar/ws/services/LoginCms?wsdl",
("wsfe", False): "https://servicios1.afip.gov.ar/wsfev1/service.asmx?WSDL",
(
"ws_sr_constancia_inscripcion",
False,
): "https://aws.afip.gov.ar/sr-padron/webservices/personaServiceA5?WSDL",
(
"ws_sr_padron_a13",
False,
): "https://aws.afip.gov.ar/sr-padron/webservices/personaServiceA13?WSDL",
("wsaa", True): "https://wsaahomo.afip.gov.ar/ws/services/LoginCms?wsdl",
("wsfe", True): "https://wswhomo.afip.gov.ar/wsfev1/service.asmx?WSDL",
(
"ws_sr_constancia_inscripcion",
True,
): "https://awshomo.afip.gov.ar/sr-padron/webservices/personaServiceA5?WSDL",
(
"ws_sr_padron_a13",
True,
): "https://awshomo.afip.gov.ar/sr-padron/webservices/personaServiceA13?WSDL",
"production": {
"wsaa": "https://wsaa.afip.gov.ar/ws/services/LoginCms?wsdl",
"wsfe": "https://servicios1.afip.gov.ar/wsfev1/service.asmx?WSDL",
"ws_sr_constancia_inscripcion": "https://aws.afip.gov.ar/sr-padron/webservices/personaServiceA5?WSDL",
"ws_sr_padron_a13": "https://aws.afip.gov.ar/sr-padron/webservices/personaServiceA13?WSDL",
},
"sandbox": {
"wsaa": "https://wsaahomo.afip.gov.ar/ws/services/LoginCms?wsdl",
"wsfe": "https://wswhomo.afip.gov.ar/wsfev1/service.asmx?WSDL",
"ws_sr_constancia_inscripcion": "https://awshomo.afip.gov.ar/sr-padron/webservices/personaServiceA5?WSDL",
"ws_sr_padron_a13": "https://awshomo.afip.gov.ar/sr-padron/webservices/personaServiceA13?WSDL",
},
}


Expand Down Expand Up @@ -117,9 +109,10 @@ def get_client(service_name: str, sandbox: bool = False) -> Client:
be used by the returned client.
:returns: A zeep client to communicate with an AFIP web service.
"""
environment = "sandbox" if sandbox else "production"
key = (service_name.lower(), sandbox)

try:
return Client(WSDLS[key], transport=get_or_create_transport())
return Client(WSDLS[environment][key], transport=get_or_create_transport())
except KeyError:
raise ValueError(f"Unknown service name, {service_name}") from None

0 comments on commit 6fe2498

Please sign in to comment.