Skip to content

Commit

Permalink
Fix DPD after last refactore
Browse files Browse the repository at this point in the history
  • Loading branch information
florian-dacosta committed Mar 26, 2021
1 parent d37698f commit 760e09b
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions roulier/carriers/dpd_fr_soap/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from jinja2 import Environment, PackageLoader
from lxml import objectify, etree
import requests

from roulier.exception import CarrierError
from roulier.transport import RequestsTransport
Expand All @@ -16,25 +15,12 @@
class DpdTransport(RequestsTransport):
"""Implement Dpd WS communication."""

def send(self, payload):
"""Call this function.
Args:
payload.body: XML in a string
payload.header : auth
Return:
{
response: (Requests.response)
body: XML response (without soap)
}
"""
def before_ws_call_transform_payload(self, payload):
body = payload["body"]
headers = payload["headers"]
soap_message = self.soap_wrap(body, headers)
log.debug(soap_message)
response = self.send_request(soap_message)
log.info("WS response time %s" % response.elapsed.total_seconds())
return self.handle_response(response)
return soap_message

def soap_wrap(self, body, auth):
"""Wrap body in a soap:Enveloppe."""
Expand All @@ -50,7 +36,7 @@ def soap_wrap(self, body, auth):
data = template.render(body=body_stripped, header=header_xml)
return data.encode("utf8")

def _get_requests_headers(self):
def _get_requests_headers(self, payload=None):
"""Send body to dpd WS."""
return {"content-type": "text/xml"}

Expand Down

0 comments on commit 760e09b

Please sign in to comment.