line_module 1.0.0

This document describes LINE Messaging API.
Documentation
/*
* Copyright (C) 2016 LINE Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
 * LINE Messaging API
 *
 * This document describes LINE Messaging API.
 *
 * The version of the OpenAPI document: 0.0.2
 *
 * Generated by: https://openapi-generator.tech
 */

use std::borrow::Borrow;
#[allow(unused_imports)]
use std::option::Option;
use std::pin::Pin;
use std::sync::Arc;

use futures::Future;
use hyper;
use hyper_util::client::legacy::connect::Connect;

use super::request as __internal_request;
use super::{configuration, Error};
use crate::models;

#[derive(Clone)]
pub struct LineModuleApiClient<C: Connect>
where
    C: Clone + std::marker::Send + Sync + 'static,
{
    configuration: Arc<configuration::Configuration<C>>,
}

impl<C: Connect> LineModuleApiClient<C>
where
    C: Clone + std::marker::Send + Sync,
{
    pub fn new(configuration: Arc<configuration::Configuration<C>>) -> LineModuleApiClient<C> {
        LineModuleApiClient { configuration }
    }
}

pub trait LineModuleApi: Send + Sync {
    fn acquire_chat_control(
        &self,
        chat_id: &str,
        acquire_chat_control_request: Option<models::AcquireChatControlRequest>,
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>>;
    fn detach_module(
        &self,
        detach_module_request: Option<models::DetachModuleRequest>,
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>>;
    fn get_modules(
        &self,
        start: Option<&str>,
        limit: Option<i32>,
    ) -> Pin<Box<dyn Future<Output = Result<models::GetModulesResponse, Error>> + Send>>;
    fn release_chat_control(
        &self,
        chat_id: &str,
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>>;
}

impl<C: Connect> LineModuleApi for LineModuleApiClient<C>
where
    C: Clone + std::marker::Send + Sync,
{
    #[allow(unused_mut)]
    fn acquire_chat_control(
        &self,
        chat_id: &str,
        acquire_chat_control_request: Option<models::AcquireChatControlRequest>,
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>> {
        let mut req = __internal_request::Request::new(
            hyper::Method::POST,
            "/v2/bot/chat/{chatId}/control/acquire".to_string(),
        );
        req = req.with_path_param("chatId".to_string(), chat_id.to_string());
        req = req.with_body_param(acquire_chat_control_request);
        req = req.returns_nothing();

        req.execute(self.configuration.borrow())
    }

    #[allow(unused_mut)]
    fn detach_module(
        &self,
        detach_module_request: Option<models::DetachModuleRequest>,
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>> {
        let mut req = __internal_request::Request::new(
            hyper::Method::POST,
            "/v2/bot/channel/detach".to_string(),
        );
        req = req.with_body_param(detach_module_request);
        req = req.returns_nothing();

        req.execute(self.configuration.borrow())
    }

    #[allow(unused_mut)]
    fn get_modules(
        &self,
        start: Option<&str>,
        limit: Option<i32>,
    ) -> Pin<Box<dyn Future<Output = Result<models::GetModulesResponse, Error>> + Send>> {
        let mut req =
            __internal_request::Request::new(hyper::Method::GET, "/v2/bot/list".to_string());
        if let Some(ref s) = start {
            let query_value = s.to_string();
            req = req.with_query_param("start".to_string(), query_value);
        }
        if let Some(ref s) = limit {
            let query_value = s.to_string();
            req = req.with_query_param("limit".to_string(), query_value);
        }

        req.execute(self.configuration.borrow())
    }

    #[allow(unused_mut)]
    fn release_chat_control(
        &self,
        chat_id: &str,
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>> {
        let mut req = __internal_request::Request::new(
            hyper::Method::POST,
            "/v2/bot/chat/{chatId}/control/release".to_string(),
        );
        req = req.with_path_param("chatId".to_string(), chat_id.to_string());
        req = req.returns_nothing();

        req.execute(self.configuration.borrow())
    }
}