diff --git a/roulier/carriers/dpd_fr_soap/decoder.py b/roulier/carriers/dpd_fr_soap/decoder.py index f90a1bf..155f135 100755 --- a/roulier/carriers/dpd_fr_soap/decoder.py +++ b/roulier/carriers/dpd_fr_soap/decoder.py @@ -19,8 +19,6 @@ def decode(self, response, input_payload): xml, "CreateShipmentWithLabels%sResult" % ("" if is_legacy else "Bc") ).getchildren() - label_file, summary_file = files.getchildren() - if is_legacy: shipment = shipments.getchildren()[0] parcel_field = "parcelnumber" @@ -31,23 +29,32 @@ def decode(self, response, input_payload): parcel_field = "BarcodeId" barcode_field = "BarCode" - parcel = { - "id": 1, - "reference": self._get_parcel_number(input_payload) - or getattr(shipment, parcel_field).text, - "tracking": { - "number": getattr(shipment, barcode_field).text, - "url": "", - "partner": "", - }, - "label": { # same as main label - "data": label_file.label.text, - "name": "label 1", - "type": output_format, - }, - } - annexes = [ - {"data": summary_file.label.text, "name": "Summary", "type": output_format} - ] - self.result["parcels"].append(parcel) - self.result["annexes"] += annexes + annexes = [] + for dpdfile in files.getchildren(): + # label file : EPRINT legacy type, BIC3 geolabel type + if dpdfile.type.text in ("EPRINT", "BIC3"): + parcel = { + "id": 1, + "reference": self._get_parcel_number(input_payload) + or getattr(shipment, parcel_field).text, + "tracking": { + "number": getattr(shipment, barcode_field).text, + "url": "", + "partner": "", + }, + "label": { # same as main label + "data": dpdfile.label.text, + "name": "label 1", + "type": output_format, + }, + } + self.result["parcels"].append(parcel) + # summary file (EPRINTATTACHMENT) or any other file but not supported yet. + else: + self.result["annexes"].append( + { + "data": dpdfile.label.text, + "name": "Summary", + "type": output_format, + } + )