Files
tryton/modules/stock_package_shipping_dpd/configuration.py
T
Cédric Krier 2848f27e83 Add trailing / to URLs of DPD shipping services
Closes #12098
(grafted from a6b41e6401ec070f5cdf97115bfd2c22c3dccdac)

--HG--
branch : 6.0
2023-03-07 18:10:25 +01:00

28 lines
990 B
Python

# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from urllib.parse import urljoin
from zeep import Client
from zeep.transports import Transport
from trytond.config import config
SERVER_URLS = {
'testing': 'https://public-ws-stage.dpd.com/services/',
'production': 'https://public-ws.dpd.com/services/',
}
LOGIN_SERVICE = 'LoginService/V2_0/?wsdl'
SHIPMENT_SERVICE = 'ShipmentService/V3_2/?wsdl'
def get_client(server, service):
api_base_url = config.get('stock_package_shipping_dpd',
server, default=SERVER_URLS[server])
url = urljoin(api_base_url, service)
# Disable the cache for testing because zeep's bug
# https://github.com/mvantellingen/python-zeep/issues/48
# which makes testing environments fail
transport = (Transport(cache=None)
if url.startswith(SERVER_URLS['testing']) else None)
return Client(url, transport=transport)