From 85392abefffcdad8e0039916c5a962999d900862 Mon Sep 17 00:00:00 2001 From: Nil Villarroya Date: Thu, 30 May 2024 13:53:48 +0200 Subject: [PATCH] compatibilidad con efact --- face/face.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/face/face.py b/face/face.py index 7439336..b972a85 100644 --- a/face/face.py +++ b/face/face.py @@ -13,6 +13,12 @@ 'staging': "https://se-face-webservice.redsara.es/facturasspp2?wsdl", } +EFACT_ENVS = { + 'prod': "https://efact.aoc.cat/bustia/services/EFactWebServiceProxyService.wsdl", + 'staging': "https://efact-pre.aoc.cat/bustia/services/EFactWebServiceProxyService.wsdl", +} + + class FACe(object): """ FACe object @@ -46,9 +52,16 @@ def __init__(self, **kwargs): # Handle environment, df "prod" self.environment = "prod" + self.destination = kwargs.get('destination', 'FACE') + if self.destination == 'FACE': + destination = FACE_ENVS + elif self.destination == 'EFACT': + destination = EFACT_ENVS + else: + raise Exception("Environment isn't correct. It must be FACE or EFACT") if 'environment' in kwargs: assert type(kwargs['environment']) == str, "environment argument must be an string" - assert kwargs['environment'] in FACE_ENVS.keys(), "Provided environment '{}' not recognized in defined FACE_ENVS {}".format(kwargs['environment'], str(FACE_ENVS.keys())) + assert kwargs['environment'] in destination.keys(), "Provided environment '{}' not recognized in defined destination {}".format(kwargs['environment'], str(destination.keys())) self.environment = kwargs['environment'] self.result_obj = kwargs.get('result_obj', False) @@ -59,7 +72,7 @@ def __init__(self, **kwargs): transport = zeep.transports.Transport(session=updated_session) # initialize a ZEEP client with the desired FACe envs self.client = zeep.Client( - FACE_ENVS[self.environment], + destination[self.environment], plugins=[FACe_signer(self.certificate, debug=self.debug)], transport=transport )