Created
October 29, 2020 13:36
-
-
Save zupzup/b8b1347e06f5e5e2e32e619e4fff98cd to your computer and use it in GitHub Desktop.
Timeular Public API activities 2
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)] | |
#[serde(rename_all = "camelCase")] | |
struct ActivitiesResponse { | |
activities: Vec<Activity>, | |
inactive_activities: Vec<Activity>, | |
archived_activities: Vec<Activity>, | |
} | |
#[derive(Deserialize, Debug)] | |
#[serde(rename_all = "camelCase")] | |
struct Activity { | |
id: String, | |
name: String, | |
color: String, | |
integration: String, | |
space_id: String, | |
device_side: Option<i64>, | |
} | |
async fn fetch_activities(token: &str) -> Result<Vec<Activity>, Error> { | |
let resp = CLIENT | |
.get(&url("/activities")) | |
.header("Authorization", auth(token)) | |
.send() | |
.await? | |
.json::<ActivitiesResponse>() | |
.await?; | |
Ok(resp.activities) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment