~martijnbraam/shipments

c8b73061924992d6dde860fb4732a77e50ae4039 — Martijn Braam 2 years ago 67de438
carrier: dhl: fix status attribute in events
1 files changed, 9 insertions(+), 1 deletions(-)

M shipments/carrier.py
M shipments/carrier.py => shipments/carrier.py +9 -1
@@ 432,6 432,8 @@ class DHL(Carrier):
            result.status_category = StatusCategory.LABEL_CREATED
        elif payload['status']['statusCode'] == 'transit':
            result.status_category = StatusCategory.IN_TRANSIT
        elif payload['status']['statusCode'] == 'delivered':
            result.status_category = StatusCategory.DELIVERED

        if 'weight' in payload['details'] and payload['details']['weight'] is not None:
            w = payload['details']['weight']


@@ 446,7 448,13 @@ class DHL(Carrier):
            if 'location' in event:
                if len(event['location']['address']) == 1 and 'addressLocality' in event['location']['address']:
                    location = event['location']['address']['addressLocality']
            e = PackageEvent(stamp, location, event['status'])
            if 'status' in event:
                status = event['status']
            elif 'description' in event:
                status = event['description']
            else:
                raise ValueError("Event without status or description")
            e = PackageEvent(stamp, location, status)
            result.events.append(e)

        if 'origin' in payload and 'address' in payload['origin']: