Created
October 29, 2020 13:35
-
-
Save zupzup/bbc75c79ee6f05a13d8ad849e2aeae19 to your computer and use it in GitHub Desktop.
Timeular Public API me2
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
#[derive(Deserialize, Debug)] | |
struct MeResponse { | |
data: Me, | |
} | |
#[derive(Deserialize, Debug)] | |
#[serde(rename_all = "camelCase")] | |
struct Me { | |
user_id: String, | |
name: String, | |
email: String, | |
default_space_id: String, | |
} | |
async fn fetch_me(token: &str) -> Result<Me, Error> { | |
let resp = CLIENT | |
.get(&url("/me")) | |
.header("Authorization", auth(token)) | |
.send() | |
.await? | |
.json::<MeResponse>() | |
.await?; | |
Ok(resp.data) | |
} | |
fn auth(token: &str) -> String { format!("Bearer {}", token) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment