sailrish / shipit

shipit node module
MIT License
87 stars 65 forks source link

DHL ETA #43

Closed danieldemeter closed 5 years ago

danieldemeter commented 5 years ago

As far as I can tell, ETAs are not being reported for DHL shipments. "destination", "activities/0/details", "activities/0/location", and "activities/0/timestamp" all report back the appropriate data, but for "eta" I receive the error of "Node Not Available". When I look at the raw data (example: http://shipit-api.herokuapp.com/api/carriers/dhl/2628987793), "eta" does not appear — yet when going to the DHL tracking page for the same shipment, an ETA is reported.

sailrish commented 5 years ago

@danieldemeter Thanks for bringing this up. It appears the XML response returned by DHL does indeed include an estimated delivery date, and the shipit node module currently doesn't parse it. Below is a snippet of the XML (see EstDlvyDateUTC and EstDlvyDate). I'll open a PR to fix this.

<req:TrackingResponse xmlns:req="http://www.dhl.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.dhl.com TrackingResponse.xsd">
    <Response>
        <ServiceHeader>
            <MessageTime>2019-01-31T04:16:16.622+01:00</MessageTime>
            <SiteID>shiprack</SiteID>
        </ServiceHeader>
    </Response>
    <AWBInfo>
        <AWBNumber>2628987793</AWBNumber>
        <Status>
            <ActionStatus>success</ActionStatus>
        </Status>
        <ShipmentInfo>
            <OriginServiceArea>
                <ServiceAreaCode>HKG</ServiceAreaCode>
                <Description>HONG KONG-HKG</Description>
            </OriginServiceArea>
            <DestinationServiceArea>                                                                                                 [111/2677]
                <ServiceAreaCode>VNY</ServiceAreaCode>
                <Description>VAN NUYS,CA-USA</Description>
            </DestinationServiceArea>
            <ShipperName>WIKIRIG TRADE LIMITED</ShipperName>
            <ShipperAccountNumber>631156765</ShipperAccountNumber>
            <ConsigneeName>IFIXIT</ConsigneeName>
            <ShipmentDate>2019-01-30T15:12:58</ShipmentDate>
            <Pieces>1</Pieces>
            <Weight>7.56</Weight>
            <WeightUnit>K</WeightUnit>
            <EstDlvyDate>2019-02-04 23:59:00 GMT-08:00</EstDlvyDate>
            <EstDlvyDateUTC>2019-02-05 07:59:00</EstDlvyDateUTC>
            <GlobalProductCode>P</GlobalProductCode>
            <ShipmentDesc>MP3 LCD</ShipmentDesc>
            <DlvyNotificationFlag>Y</DlvyNotificationFlag>
            <Shipper>
sailrish commented 5 years ago

Here ya go: https://github.com/sailrish/shipit/pull/44

sailrish commented 5 years ago

And released as shipit 1.2.0. http://shipit-api.herokuapp.com/api/carriers/dhl/2628987793

{  
   "eta":"2019-02-05T07:59:00.000Z",
   "weight":"7.56 LB",
   "destination":"Van Nuys, CA, USA",
   "activities":[  
      {  
         "timestamp":"2019-01-31T02:24:58.000Z",
         "location":"Hong Kong, HKG",
         "details":"Departed Facility"
      },
      {  
         "timestamp":"2019-01-31T01:51:03.000Z",
         "location":"Hong Kong, HKG",
         "details":"Processed"
      },
      {  
         "timestamp":"2019-01-30T20:42:43.000Z",
         "location":"Hong Kong, HKG",
         "details":"Arrived at Sort Facility"
      },
      {  
         "timestamp":"2019-01-30T18:39:00.000Z",
         "location":"Los Angeles, CA, USA",
         "details":"Customs status updated"
      },
      {  
         "timestamp":"2019-01-30T15:12:43.000Z",
         "location":"Hong Kong, HKG",
         "details":"Shipment picked up"
      }
   ],
   "status":2,
   "request":{  
      "trackingNumber":"2628987793"
   }
}