messaging_api_line/apis/configuration.rs
1/*
2 * LINE Messaging API
3 *
4 * This document describes LINE Messaging API.
5 *
6 * The version of the OpenAPI document: 0.0.1
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use hyper;
12use hyper::body::Bytes;
13use hyper_tls::HttpsConnector;
14use hyper_util::client::legacy::connect::Connect;
15use hyper_util::client::legacy::connect::HttpConnector;
16use hyper_util::client::legacy::Client;
17use hyper_util::rt::TokioExecutor;
18use http_body_util::Full;
19
20type Connector = HttpsConnector<HttpConnector>;
21
22pub struct Configuration<C: Connect = Connector>
23where
24 C: Clone + std::marker::Send + Sync + 'static,
25{
26 pub base_path: String,
27 pub user_agent: Option<String>,
28 pub client: Client<C, Full<Bytes>>,
29 pub basic_auth: Option<BasicAuth>,
30 pub oauth_access_token: Option<String>,
31 pub api_key: Option<ApiKey>,
32 // TODO: take an oauth2 token source, similar to the go one
33}
34
35pub type BasicAuth = (String, Option<String>);
36
37pub struct ApiKey {
38 pub prefix: Option<String>,
39 pub key: String,
40}
41
42impl<C: Connect> Configuration<C>
43where
44 C: Clone + std::marker::Send + Sync,
45{
46 /// Construct a default [`Configuration`](Self) with a hyper client using a default
47 /// [`HttpConnector`](hyper_util::client::legacy::connect::HttpConnector).
48 ///
49 /// Use [`with_client`](Configuration<T>::with_client) to construct a Configuration with a
50 /// custom hyper client.
51 ///
52 /// # Example
53 ///
54 /// ```
55 /// # use line_channel_access_token::apis::configuration::Configuration;
56 /// let api_config = Configuration {
57 /// basic_auth: Some(("user".into(), None)),
58 /// ..Configuration::new()
59 /// };
60 /// ```
61 pub fn new(client: Client<Connector, Full<Bytes>>) -> Configuration<Connector> {
62 Configuration::with_client(client)
63 }
64}
65
66impl<C: Connect> Configuration<C>
67where
68 C: Clone + std::marker::Send + Sync,
69{
70 /// Construct a new Configuration with a custom hyper client.
71 ///
72 /// # Example
73 ///
74 /// ```
75 /// # use core::time::Duration;
76 /// # use line_messaging_api::apis::configuration::Configuration;
77 /// use hyper_util::client::legacy::Client;
78 /// use hyper_util::rt::TokioExecutor;
79 ///
80 /// let client = Client::builder(TokioExecutor::new())
81 /// .pool_idle_timeout(Duration::from_secs(30))
82 /// .build_http();
83 ///
84 /// let api_config = Configuration::with_client(client);
85 /// ```
86 pub fn with_client(client: Client<C, Full<Bytes>>) -> Configuration<C> {
87 Configuration {
88 base_path: "https://api.line.me".to_owned(),
89 user_agent: Some("OpenAPI-Generator/0.0.1/rust".to_owned()),
90 client,
91 basic_auth: None,
92 oauth_access_token: None,
93 api_key: None,
94 }
95 }
96}