use std::borrow::Borrow;
#[allow(unused_imports)]
use std::option::Option;
use std::sync::Arc;
use hyper;
use hyper_util::client::legacy::connect::Connect;
use super::request as __internal_request;
use super::{configuration, Error};
use crate::line_module_attach::models;
#[derive(Clone)]
pub struct LineModuleAttachApiClient<C: Connect>
where
C: Clone + std::marker::Send + Sync + 'static,
{
configuration: Arc<configuration::Configuration<C>>,
}
impl<C: Connect> LineModuleAttachApiClient<C>
where
C: Clone + std::marker::Send + Sync,
{
pub fn new(
configuration: Arc<configuration::Configuration<C>>,
) -> LineModuleAttachApiClient<C> {
LineModuleAttachApiClient { configuration }
}
}
pub trait LineModuleAttachApi: Send + Sync {
fn attach_module(
&self,
grant_type: &str,
code: &str,
redirect_uri: &str,
code_verifier: Option<&str>,
client_id: Option<&str>,
client_secret: Option<&str>,
region: Option<&str>,
basic_search_id: Option<&str>,
scope: Option<&str>,
brand_type: Option<&str>,
) -> impl std::future::Future<Output = Result<models::AttachModuleResponse, Error>> + Send;
}
impl<C: Connect> LineModuleAttachApi for LineModuleAttachApiClient<C>
where
C: Clone + std::marker::Send + Sync,
{
#[allow(unused_mut)]
async fn attach_module(
&self,
grant_type: &str,
code: &str,
redirect_uri: &str,
code_verifier: Option<&str>,
client_id: Option<&str>,
client_secret: Option<&str>,
region: Option<&str>,
basic_search_id: Option<&str>,
scope: Option<&str>,
brand_type: Option<&str>,
) -> Result<models::AttachModuleResponse, Error> {
let mut req = __internal_request::Request::new(
hyper::Method::POST,
"/module/auth/v1/token".to_string(),
)
.with_auth(__internal_request::Auth::Basic);
req = req.with_form_param("grant_type".to_string(), grant_type.to_string());
req = req.with_form_param("code".to_string(), code.to_string());
req = req.with_form_param("redirect_uri".to_string(), redirect_uri.to_string());
if let Some(param_value) = code_verifier {
req = req.with_form_param("code_verifier".to_string(), param_value.to_string());
}
if let Some(param_value) = client_id {
req = req.with_form_param("client_id".to_string(), param_value.to_string());
}
if let Some(param_value) = client_secret {
req = req.with_form_param("client_secret".to_string(), param_value.to_string());
}
if let Some(param_value) = region {
req = req.with_form_param("region".to_string(), param_value.to_string());
}
if let Some(param_value) = basic_search_id {
req = req.with_form_param("basic_search_id".to_string(), param_value.to_string());
}
if let Some(param_value) = scope {
req = req.with_form_param("scope".to_string(), param_value.to_string());
}
if let Some(param_value) = brand_type {
req = req.with_form_param("brand_type".to_string(), param_value.to_string());
}
req.execute(self.configuration.borrow()).await
}
}