From 734532abd56a0668567b2d87de7788d865a89f8d Mon Sep 17 00:00:00 2001 From: Stefan Bossbaly Date: Sat, 20 Jul 2024 21:28:22 -0400 Subject: [PATCH] Added ingestion of Canada transit network (#6) The Via rail network was added to Amtrak's API. Therefore the schema changed slightly. The object_id is only provided when the new provider tag is marked "Amtrak". --- src/responses.rs | 11 ++++++++++- tests/train.rs | 3 ++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/responses.rs b/src/responses.rs index 822629a..6881c79 100644 --- a/src/responses.rs +++ b/src/responses.rs @@ -268,8 +268,17 @@ pub struct Train { pub last_value: DateTime, /// Unsure of what this field symbolizes. + /// + /// Note: Only provided if provider is "Amtrak" #[serde(rename = "objectID")] - pub object_id: u32, + pub object_id: Option, + + /// The provider network of this information + /// + /// # Examples: + /// * `Amtrak` + /// * `Via` + pub provider: String, } #[derive(Debug, Deserialize, Clone)] diff --git a/tests/train.rs b/tests/train.rs index 3cf2380..5a7918a 100644 --- a/tests/train.rs +++ b/tests/train.rs @@ -256,7 +256,8 @@ async fn test_single_train() -> Result<(), amtrak_api::Error> { "createdAt": "2023-08-29T23:39:50-04:00", "updatedAt": "2023-08-29T23:39:50-04:00", "lastValTS": "2023-08-29T23:39:34-04:00", - "objectID": 847 + "objectID": 847, + "provider": "Amtrak" } ] }"#,