twapi_reqwest/
lib.rs

1pub mod oauth;
2pub(crate) mod raw;
3pub mod v1;
4pub mod v2;
5
6pub use reqwest;
7use reqwest::Client;
8pub use serde_json;
9use std::time::Duration;
10
11pub(crate) fn make_body(form_options: &Vec<(&str, &str)>) -> String {
12    match serde_urlencoded::to_string(form_options) {
13        Ok(body) => body
14            .replace('+', "%20")
15            .replace('*', "%2A")
16            .replace("%7E", "~")
17            .into(),
18        Err(_) => String::from(""),
19    }
20}
21
22pub(crate) fn build_client(timeout_sec: Option<Duration>) -> Client {
23    match timeout_sec {
24        Some(value) => Client::builder().timeout(value),
25        None => Client::builder(),
26    }
27    .build()
28    .unwrap()
29}