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