logistics_api/dhl/tracking/
models.rs

1use serde::{Deserialize, Serialize};
2
3/// Tracking response from DHL
4#[derive(Debug, Serialize, Deserialize)]
5pub struct Tracking {
6    pub shipments: Vec<Shipment>,
7}
8
9/// Single Shipment details
10#[derive(Debug, Serialize, Deserialize)]
11pub struct Shipment {
12    pub id: String,
13    pub service: String,
14    pub origin: PointLocation,
15    pub destination: PointLocation,
16    pub status: ShipmentStatus,
17    pub details: ShipmentDetails,
18    pub events: Vec<ShipmentEvent>,
19}
20
21/// Point location
22#[derive(Debug, Serialize, Deserialize)]
23pub struct PointLocation {
24    pub address: Address,
25    #[serde(rename = "servicePoint")]
26    pub service_point: Option<ServicePoint>,
27}
28
29/// Address
30#[derive(Debug, Serialize, Deserialize)]
31pub struct Address {
32    #[serde(rename = "addressLocality")]
33    pub address_locality: String,
34}
35
36/// Service point
37#[derive(Debug, Serialize, Deserialize)]
38pub struct ServicePoint {
39    pub url: String,
40    pub label: String,
41}
42
43/// Status of a shipment
44#[derive(Debug, Serialize, Deserialize)]
45pub struct ShipmentStatus {
46    pub timestamp: String,
47    pub location: PointLocation,
48    pub description: String,
49}
50
51/// Shipment details, contains proof of delivery, number of pieces and piece ids
52#[derive(Debug, Serialize, Deserialize)]
53pub struct ShipmentDetails {
54    #[serde(rename = "proofOfDelivery")]
55    pub proof_of_delivery: Option<ProofOfDelivery>,
56
57    #[serde(rename = "proofOfDeliverySignedAvailable")]
58    pub proof_of_delivery_signed_available: bool,
59
60    #[serde(rename = "totalNumberOfPieces")]
61    pub total_number_of_pieces: i32,
62
63    #[serde(rename = "pieceIds")]
64    pub piece_ids: Vec<String>,
65}
66
67/// Proof of delivery
68#[derive(Debug, Serialize, Deserialize)]
69pub struct ProofOfDelivery {
70    #[serde(rename = "signatureUrl")]
71    pub signature_url: String,
72
73    #[serde(rename = "documentUrl")]
74    pub document_url: String,
75}
76
77/// Single shipment event
78#[derive(Debug, Serialize, Deserialize)]
79pub struct ShipmentEvent {
80    pub timestamp: String,
81    pub location: PointLocation,
82    pub description: String,
83}