Skip to content

Commit

Permalink
compatibilidad con efact
Browse files Browse the repository at this point in the history
  • Loading branch information
nvillarroya committed May 30, 2024
1 parent 92965ea commit 85392ab
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions face/face.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
)
Expand Down

0 comments on commit 85392ab

Please sign in to comment.