This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| println!("listing subscriptions..."); | |
| let subscriptions = list_subscriptions(&token).await?; | |
| println!("subscriptions: {:?}", subscriptions); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #[derive(Deserialize, Debug)] | |
| struct SubscriptionsResponse { | |
| subscriptions: Vec<Subscription>, | |
| } | |
| #[derive(Deserialize, Debug)] | |
| struct Subscription { | |
| id: String, | |
| event: String, | |
| target_url: String, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| time entry was created with data: TrackingStoppedPayload { user_id: "1234", event_type: "trackingStopped", data: TrackingStoppedData { new_time_entry: Some(TimeEntry { id: "1234", activity: Activity { id: "1234", name: "Misc", color: "#17bbd2", integration: "zei", space_id: "1234", device_side: None }, duration: Duration { started_at: "2020-11-30T07:08:52.203", stopped_at: "2020-11-30T08:08:59.789" }, note: Note { text: None, tags: [], mentions: [] } }) } } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| tracking was started with data: TrackingStartedPayload { user_id: "1234", event_type: "trackingStarted", data: TrackingStartedData { current_tracking: Tracking { id: 1234, activity: Activity { id: "1234", name: "Misc", color: "#17bbd2", integration: "zei", space_id: "1234", device_side: None }, started_at: "2020-11-30T07:08:52.203", note: Note { text: None, tags: [], mentions: [] } } } } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| PUBLIC_URL=the-url-from-localtunnel TMLR_API_KEY=secret TMLR_API_SECRET=secret cargo run |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let health_route = warp::path!("health").and_then(health_handler); | |
| warp::serve( | |
| started_tracking_route | |
| .or(stopped_tracking_route) | |
| .or(health_route), | |
| ) | |
| .run(([0, 0, 0, 0], 8000)) | |
| .await; | |
| Ok(()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #[derive(Debug, Deserialize)] | |
| #[serde(rename_all = "camelCase")] | |
| struct TrackingStartedPayload { | |
| user_id: String, | |
| event_type: String, | |
| data: TrackingStartedData, | |
| } | |
| #[derive(Debug, Deserialize)] | |
| #[serde(rename_all = "camelCase")] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| async fn started_tracking_handler(body: TrackingStartedPayload) -> WebResult<impl Reply> { | |
| println!("tracking was started with data: {:?}", body); | |
| Ok("OK") | |
| } | |
| async fn stopped_tracking_handler(body: TrackingStoppedPayload) -> WebResult<impl Reply> { | |
| println!("time entry was created with data: {:?}", body); | |
| Ok("OK") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let started_tracking_route = warp::path!("started-tracking") | |
| .and(warp::post()) | |
| .and(warp::body::json()) | |
| .and_then(started_tracking_handler); | |
| let stopped_tracking_route = warp::path!("stopped-tracking") | |
| .and(warp::post()) | |
| .and(warp::body::json()) | |
| .and_then(stopped_tracking_handler); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| println!("subscribing to started tracking..."); | |
| subscribe_to_started_tracking(&token, &public_url).await?; | |
| println!("subscribing to stopped tracking..."); | |
| subscribe_to_stopped_tracking(&token, &public_url).await?; |
NewerOlder