-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Recursive downloads (part of #49)
chore: Bump deps feat: Ability to set a path for downloads refactor: Use shared HTTP client instance refactor: Use references where applicable feat: Move play command under files
- Loading branch information
Showing
8 changed files
with
963 additions
and
594 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,27 @@ | ||
use std::collections::HashMap; | ||
|
||
use reqwest::{blocking::Client, Error}; | ||
|
||
/// Returns a new OOB code. | ||
pub fn get() -> Result<String, Box<dyn std::error::Error>> { | ||
let resp = reqwest::blocking::get("https://api.put.io/v2/oauth2/oob/code?app_id=4701")? | ||
pub fn get(client: &Client) -> Result<String, Error> { | ||
let resp = client | ||
.get("https://api.put.io/v2/oauth2/oob/code?app_id=4701") | ||
.send()? | ||
.json::<HashMap<String, String>>()?; | ||
let code = resp.get("code").expect("fetching OOB code"); | ||
Ok(code.to_string()) | ||
|
||
let code: &String = resp.get("code").expect("fetching OOB code"); | ||
|
||
Ok(code.clone()) | ||
} | ||
|
||
/// Returns new OAuth token if the OOB code is linked to the user's account. | ||
pub fn check(oob_code: String) -> Result<String, Box<dyn std::error::Error>> { | ||
let resp = reqwest::blocking::get(format!( | ||
"https://api.put.io/v2/oauth2/oob/code/{}", | ||
oob_code | ||
))? | ||
.json::<HashMap<String, String>>()?; | ||
let token = resp.get("oauth_token").expect("deserializing OAuth token"); | ||
Ok(token.to_string()) | ||
pub fn check(client: &Client, oob_code: &String) -> Result<String, Error> { | ||
let resp = client | ||
.get(format!("https://api.put.io/v2/oauth2/oob/code/{oob_code}")) | ||
.send()? | ||
.json::<HashMap<String, String>>()?; | ||
|
||
let token: &String = resp.get("oauth_token").expect("fetching OAuth token"); | ||
|
||
Ok(token.clone()) | ||
} |
Oops, something went wrong.