Created
October 29, 2020 13:29
-
-
Save zupzup/7d1253b8d798a071ebca5f1f31f668b4 to your computer and use it in GitHub Desktop.
Timeular Public API sign_in 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(Serialize, Debug)] | |
#[serde(rename_all = "camelCase")] | |
struct SignInRequest { | |
api_key: String, | |
api_secret: String, | |
} | |
#[derive(Deserialize, Debug)] | |
struct SignInResponse { | |
token: String, | |
} | |
async fn sign_in(api_key: String, api_secret: String) -> Result<String, Error> { | |
let body = SignInRequest { | |
api_key, | |
api_secret, | |
}; | |
let resp = CLIENT | |
.post(&url("/developer/sign-in")) | |
.json(&body) | |
.send() | |
.await? | |
.json::<SignInResponse>() | |
.await?; | |
Ok(resp.token) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment