1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
use crate::internal::GraphClientConfiguration;
use reqwest::header::HeaderMap;
use std::env::VarError;
use std::ffi::OsStr;
use std::fmt::{Debug, Formatter};
#[derive(Clone)]
pub struct BlockingClient {
pub(crate) access_token: String,
pub(crate) inner: reqwest::blocking::Client,
pub(crate) headers: HeaderMap,
}
impl BlockingClient {
pub fn new<AT: ToString>(access_token: AT) -> BlockingClient {
GraphClientConfiguration::new()
.access_token(access_token)
.build_blocking()
}
pub fn new_env<K: AsRef<OsStr>>(env_var: K) -> Result<BlockingClient, VarError> {
Ok(GraphClientConfiguration::new()
.access_token(std::env::var(env_var)?)
.build_blocking())
}
pub fn builder() -> GraphClientConfiguration {
GraphClientConfiguration::new()
}
pub fn headers(&self) -> &HeaderMap {
&self.headers
}
}
impl Default for BlockingClient {
fn default() -> Self {
GraphClientConfiguration::new().build_blocking()
}
}
impl Debug for BlockingClient {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
f.debug_struct("BlockingClient")
.field("inner", &self.inner)
.field("headers", &self.headers)
.finish()
}
}