|  | 
|  | 1 | +import dhl from "../../dhl.app.mjs"; | 
|  | 2 | +import constants from "../../common/constants.mjs"; | 
|  | 3 | + | 
|  | 4 | +export default { | 
|  | 5 | +  key: "dhl-get-tracking", | 
|  | 6 | +  name: "Get Tracking Information", | 
|  | 7 | +  description: "Get tracking information for shipments. [See the documentation](https://developer.dhl.com/api-reference/shipment-tracking#operations-default-getTrackingShipment)", | 
|  | 8 | +  version: "0.0.1", | 
|  | 9 | +  type: "action", | 
|  | 10 | +  props: { | 
|  | 11 | +    dhl, | 
|  | 12 | +    trackingNumber: { | 
|  | 13 | +      type: "string", | 
|  | 14 | +      label: "Tracking Number", | 
|  | 15 | +      description: "The tracking number of the shipment to get tracking information for", | 
|  | 16 | +    }, | 
|  | 17 | +    service: { | 
|  | 18 | +      type: "string", | 
|  | 19 | +      label: "Service", | 
|  | 20 | +      description: "The service of the shipment to get tracking information for", | 
|  | 21 | +      options: constants.SHIPPING_SERVICES, | 
|  | 22 | +      optional: true, | 
|  | 23 | +    }, | 
|  | 24 | +    requesterCountryCode: { | 
|  | 25 | +      type: "string", | 
|  | 26 | +      label: "Requester Country Code", | 
|  | 27 | +      description: "Optional ISO 3166-1 alpha-2 country code represents country of the consumer of the API response.", | 
|  | 28 | +      optional: true, | 
|  | 29 | +    }, | 
|  | 30 | +    originCountryCode: { | 
|  | 31 | +      type: "string", | 
|  | 32 | +      label: "Origin Country Code", | 
|  | 33 | +      description: "Optional ISO 3166-1 alpha-2 country code of the shipment origin to further qualify the shipment tracking number (trackingNumber) parameter of the request.", | 
|  | 34 | +      optional: true, | 
|  | 35 | +    }, | 
|  | 36 | +    recipientPostalCode: { | 
|  | 37 | +      type: "string", | 
|  | 38 | +      label: "Requester Postal Code", | 
|  | 39 | +      description: "Postal code of the destination address", | 
|  | 40 | +      optional: true, | 
|  | 41 | +    }, | 
|  | 42 | +    language: { | 
|  | 43 | +      type: "string", | 
|  | 44 | +      label: "Language", | 
|  | 45 | +      description: "ISO 639-1 2-character language code for the response. This parameter serves as an indication of the client preferences ONLY. Language availability depends on the service used.", | 
|  | 46 | +      optional: true, | 
|  | 47 | +    }, | 
|  | 48 | +    limit: { | 
|  | 49 | +      type: "integer", | 
|  | 50 | +      label: "Limit", | 
|  | 51 | +      description: "Maximum number of events to be returned in the response. Default: 5", | 
|  | 52 | +      optional: true, | 
|  | 53 | +    }, | 
|  | 54 | +    offset: { | 
|  | 55 | +      type: "integer", | 
|  | 56 | +      label: "Offset", | 
|  | 57 | +      description: "Offset of the first event to be returned in the response. Default: 0", | 
|  | 58 | +      optional: true, | 
|  | 59 | +    }, | 
|  | 60 | +  }, | 
|  | 61 | +  async run({ $ }) { | 
|  | 62 | +    const response = await this.dhl.getTracking({ | 
|  | 63 | +      $, | 
|  | 64 | +      params: { | 
|  | 65 | +        trackingNumber: this.trackingNumber, | 
|  | 66 | +        service: this.service, | 
|  | 67 | +        requesterCountryCode: this.requesterCountryCode, | 
|  | 68 | +        originCountryCode: this.originCountryCode, | 
|  | 69 | +        recipientPostalCode: this.recipientPostalCode, | 
|  | 70 | +        language: this.language, | 
|  | 71 | +        limit: this.limit, | 
|  | 72 | +        offset: this.offset, | 
|  | 73 | +      }, | 
|  | 74 | +    }); | 
|  | 75 | +    $.export("$summary", `Successfully fetched tracking information for ${this.trackingNumber}`); | 
|  | 76 | +    return response; | 
|  | 77 | +  }, | 
|  | 78 | +}; | 
0 commit comments