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_channel_access_token::models;
#[derive(Clone)]
pub struct ChannelAccessTokenApiClient<C: Connect>
where
C: Clone + std::marker::Send + Sync + 'static,
{
configuration: Arc<configuration::Configuration<C>>,
}
impl<C: Connect> ChannelAccessTokenApiClient<C>
where
C: Clone + std::marker::Send + Sync,
{
pub fn new(
configuration: Arc<configuration::Configuration<C>>,
) -> ChannelAccessTokenApiClient<C> {
ChannelAccessTokenApiClient { configuration }
}
}
pub trait ChannelAccessTokenApi: Send + Sync {
fn gets_all_valid_channel_access_token_key_ids(
&self,
client_assertion_type: &str,
client_assertion: &str,
) -> impl std::future::Future<Output = Result<models::ChannelAccessTokenKeyIdsResponse, Error>> + Send;
fn issue_channel_token(
&self,
grant_type: &str,
client_id: &str,
client_secret: &str,
) -> impl std::future::Future<
Output = Result<models::IssueShortLivedChannelAccessTokenResponse, Error>,
> + Send;
fn issue_channel_token_by_jwt(
&self,
grant_type: &str,
client_assertion_type: &str,
client_assertion: &str,
) -> impl std::future::Future<Output = Result<models::IssueChannelAccessTokenResponse, Error>> + Send;
fn issue_stateless_channel_token(
&self,
grant_type: Option<&str>,
client_assertion_type: Option<&str>,
client_assertion: Option<&str>,
client_id: Option<&str>,
client_secret: Option<&str>,
) -> impl std::future::Future<
Output = Result<models::IssueStatelessChannelAccessTokenResponse, Error>,
> + Send;
fn revoke_channel_token(
&self,
access_token: &str,
) -> impl std::future::Future<Output = Result<(), Error>> + Send;
fn revoke_channel_token_by_jwt(
&self,
client_id: &str,
client_secret: &str,
access_token: &str,
) -> impl std::future::Future<Output = Result<(), Error>> + Send;
fn verify_channel_token(
&self,
access_token: &str,
) -> impl std::future::Future<Output = Result<models::VerifyChannelAccessTokenResponse, Error>> + Send;
fn verify_channel_token_by_jwt(
&self,
access_token: &str,
) -> impl std::future::Future<Output = Result<models::VerifyChannelAccessTokenResponse, Error>> + Send;
}
impl<C: Connect> ChannelAccessTokenApi for ChannelAccessTokenApiClient<C>
where
C: Clone + std::marker::Send + Sync,
{
#[allow(unused_mut)]
async fn gets_all_valid_channel_access_token_key_ids(
&self,
client_assertion_type: &str,
client_assertion: &str,
) -> Result<models::ChannelAccessTokenKeyIdsResponse, Error> {
let mut req = __internal_request::Request::new(
hyper::Method::GET,
"/oauth2/v2.1/tokens/kid".to_string(),
);
req = req.with_query_param(
"client_assertion_type".to_string(),
client_assertion_type.to_string(),
);
req = req.with_query_param("client_assertion".to_string(), client_assertion.to_string());
req.execute(self.configuration.borrow()).await
}
#[allow(unused_mut)]
async fn issue_channel_token(
&self,
grant_type: &str,
client_id: &str,
client_secret: &str,
) -> Result<models::IssueShortLivedChannelAccessTokenResponse, Error> {
let mut req = __internal_request::Request::new(
hyper::Method::POST,
"/v2/oauth/accessToken".to_string(),
);
req = req.with_form_param("grant_type".to_string(), grant_type.to_string());
req = req.with_form_param("client_id".to_string(), client_id.to_string());
req = req.with_form_param("client_secret".to_string(), client_secret.to_string());
req.execute(self.configuration.borrow()).await
}
#[allow(unused_mut)]
async fn issue_channel_token_by_jwt(
&self,
grant_type: &str,
client_assertion_type: &str,
client_assertion: &str,
) -> Result<models::IssueChannelAccessTokenResponse, Error> {
let mut req =
__internal_request::Request::new(hyper::Method::POST, "/oauth2/v2.1/token".to_string());
req = req.with_form_param("grant_type".to_string(), grant_type.to_string());
req = req.with_form_param(
"client_assertion_type".to_string(),
client_assertion_type.to_string(),
);
req = req.with_form_param("client_assertion".to_string(), client_assertion.to_string());
req.execute(self.configuration.borrow()).await
}
#[allow(unused_mut)]
async fn issue_stateless_channel_token(
&self,
grant_type: Option<&str>,
client_assertion_type: Option<&str>,
client_assertion: Option<&str>,
client_id: Option<&str>,
client_secret: Option<&str>,
) -> Result<models::IssueStatelessChannelAccessTokenResponse, Error> {
let mut req =
__internal_request::Request::new(hyper::Method::POST, "/oauth2/v3/token".to_string());
if let Some(param_value) = grant_type {
req = req.with_form_param("grant_type".to_string(), param_value.to_string());
}
if let Some(param_value) = client_assertion_type {
req = req.with_form_param("client_assertion_type".to_string(), param_value.to_string());
}
if let Some(param_value) = client_assertion {
req = req.with_form_param("client_assertion".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());
}
req.execute(self.configuration.borrow()).await
}
#[allow(unused_mut)]
async fn revoke_channel_token(&self, access_token: &str) -> Result<(), Error> {
let mut req =
__internal_request::Request::new(hyper::Method::POST, "/v2/oauth/revoke".to_string());
req = req.with_form_param("access_token".to_string(), access_token.to_string());
req = req.returns_nothing();
req.execute(self.configuration.borrow()).await
}
#[allow(unused_mut)]
async fn revoke_channel_token_by_jwt(
&self,
client_id: &str,
client_secret: &str,
access_token: &str,
) -> Result<(), Error> {
let mut req = __internal_request::Request::new(
hyper::Method::POST,
"/oauth2/v2.1/revoke".to_string(),
);
req = req.with_form_param("client_id".to_string(), client_id.to_string());
req = req.with_form_param("client_secret".to_string(), client_secret.to_string());
req = req.with_form_param("access_token".to_string(), access_token.to_string());
req = req.returns_nothing();
req.execute(self.configuration.borrow()).await
}
#[allow(unused_mut)]
async fn verify_channel_token(
&self,
access_token: &str,
) -> Result<models::VerifyChannelAccessTokenResponse, Error> {
let mut req =
__internal_request::Request::new(hyper::Method::POST, "/v2/oauth/verify".to_string());
req = req.with_form_param("access_token".to_string(), access_token.to_string());
req.execute(self.configuration.borrow()).await
}
#[allow(unused_mut)]
async fn verify_channel_token_by_jwt(
&self,
access_token: &str,
) -> Result<models::VerifyChannelAccessTokenResponse, Error> {
let mut req =
__internal_request::Request::new(hyper::Method::GET, "/oauth2/v2.1/verify".to_string());
req = req.with_query_param("access_token".to_string(), access_token.to_string());
req.execute(self.configuration.borrow()).await
}
}