payfip_ws: initialize PayFiP SOAP client lazily and encapsulate internal exceptions (#53590)
This commit is contained in:
parent
0c13ae109d
commit
c9174c008f
|
@ -87,9 +87,20 @@ class PayFiP(object):
|
|||
'''Encapsulate SOAP web-services of PayFiP'''
|
||||
|
||||
def __init__(self, wsdl_url=None, service_url=None, zeep_client_kwargs=None):
|
||||
self.client = zeep.Client(wsdl_url or WSDL_URL, **(zeep_client_kwargs or {}))
|
||||
# distribued WSDL is wrong :/
|
||||
self.client.service._binding_options['address'] = service_url or SERVICE_URL
|
||||
self.wsdl_url = wsdl_url
|
||||
self.service_url = service_url
|
||||
self.zeep_client_kwargs = zeep_client_kwargs
|
||||
|
||||
@property
|
||||
def client(self):
|
||||
if not hasattr(self, '_client'):
|
||||
try:
|
||||
self._client = zeep.Client(self.wsdl_url or WSDL_URL, **(self.zeep_client_kwargs or {}))
|
||||
# distribued WSDL is wrong :/
|
||||
self._client.service._binding_options['address'] = self.service_url or SERVICE_URL
|
||||
except Exception as e:
|
||||
raise PayFiPError('Cound not initialize the SOAP client', e)
|
||||
return self._client
|
||||
|
||||
def fault_to_exception(self, fault):
|
||||
if fault.message != 'fr.gouv.finances.cp.tpa.webservice.exceptions.FonctionnelleErreur' or fault.detail is None:
|
||||
|
|
Loading…
Reference in New Issue