Created
December 2, 2020 12:00
-
-
Save zupzup/c8bebf76f71dd9298d4d4b7bd58ed6c7 to your computer and use it in GitHub Desktop.
Timeular Webhooks Subscribe
This file contains 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 subscribe_to_started_tracking(token: &str, public_url: &str) -> Result<(), Error> { | |
let body = EventRequest { | |
event: "trackingStarted", | |
target_url: format!("{}/started-tracking", public_url), | |
}; | |
let resp = CLIENT | |
.post(&url("/webhooks/subscription")) | |
.header("Authorization", auth(token)) | |
.json(&body) | |
.send() | |
.await?; | |
Ok(()) | |
} | |
async fn subscribe_to_stopped_tracking(token: &str, public_url: &str) -> Result<(), Error> { | |
let body = EventRequest { | |
event: "trackingStopped", | |
target_url: format!("{}/stopped-tracking", public_url), | |
}; | |
let resp = CLIENT | |
.post(&url("/webhooks/subscription")) | |
.header("Authorization", auth(token)) | |
.json(&body) | |
.send() | |
.await?; | |
Ok(()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment