line-bot-sdk-rust 3.0.0

LINE Messaging API SDK for Rust
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.1
 *
 * Generated by: https://openapi-generator.tech
 */

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_manage_audience::models;

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

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

pub trait ManageAudienceApi: Send + Sync {
    fn add_audience_to_audience_group(
        &self,
        add_audience_to_audience_group_request: models::AddAudienceToAudienceGroupRequest,
    ) -> impl std::future::Future<Output = Result<(), Error>> + Send;
    fn create_audience_group(
        &self,
        create_audience_group_request: models::CreateAudienceGroupRequest,
    ) -> impl std::future::Future<Output = Result<models::CreateAudienceGroupResponse, Error>> + Send;
    fn create_click_based_audience_group(
        &self,
        create_click_based_audience_group_request: models::CreateClickBasedAudienceGroupRequest,
    ) -> impl std::future::Future<
        Output = Result<models::CreateClickBasedAudienceGroupResponse, Error>,
    > + Send;
    fn create_imp_based_audience_group(
        &self,
        create_imp_based_audience_group_request: models::CreateImpBasedAudienceGroupRequest,
    ) -> impl std::future::Future<Output = Result<models::CreateImpBasedAudienceGroupResponse, Error>>
           + Send;
    fn delete_audience_group(
        &self,
        audience_group_id: i64,
    ) -> impl std::future::Future<Output = Result<(), Error>> + Send;
    fn get_audience_data(
        &self,
        audience_group_id: i64,
    ) -> impl std::future::Future<Output = Result<models::GetAudienceDataResponse, Error>> + Send;
    fn get_audience_groups(
        &self,
        page: i64,
        description: Option<&str>,
        status: Option<models::AudienceGroupStatus>,
        size: Option<i64>,
        includes_external_public_groups: Option<bool>,
        create_route: Option<models::AudienceGroupCreateRoute>,
    ) -> impl std::future::Future<Output = Result<models::GetAudienceGroupsResponse, Error>> + Send;
    fn get_shared_audience_data(
        &self,
        audience_group_id: i64,
    ) -> impl std::future::Future<Output = Result<models::GetSharedAudienceDataResponse, Error>> + Send;
    fn get_shared_audience_groups(
        &self,
        page: i64,
        description: Option<&str>,
        status: Option<models::AudienceGroupStatus>,
        size: Option<i64>,
        create_route: Option<models::AudienceGroupCreateRoute>,
        includes_owned_audience_groups: Option<bool>,
    ) -> impl std::future::Future<Output = Result<models::GetSharedAudienceGroupsResponse, Error>> + Send;
    fn update_audience_group_description(
        &self,
        audience_group_id: i64,
        update_audience_group_description_request: models::UpdateAudienceGroupDescriptionRequest,
    ) -> impl std::future::Future<Output = Result<(), Error>> + Send;
}

impl<C: Connect> ManageAudienceApi for ManageAudienceApiClient<C>
where
    C: Clone + std::marker::Send + Sync,
{
    #[allow(unused_mut)]
    async fn add_audience_to_audience_group(
        &self,
        add_audience_to_audience_group_request: models::AddAudienceToAudienceGroupRequest,
    ) -> Result<(), Error> {
        let mut req = __internal_request::Request::new(
            hyper::Method::PUT,
            "/v2/bot/audienceGroup/upload".to_string(),
        );
        req = req.with_body_param(add_audience_to_audience_group_request);
        req = req.returns_nothing();

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

    #[allow(unused_mut)]
    async fn create_audience_group(
        &self,
        create_audience_group_request: models::CreateAudienceGroupRequest,
    ) -> Result<models::CreateAudienceGroupResponse, Error> {
        let mut req = __internal_request::Request::new(
            hyper::Method::POST,
            "/v2/bot/audienceGroup/upload".to_string(),
        );
        req = req.with_body_param(create_audience_group_request);

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

    #[allow(unused_mut)]
    async fn create_click_based_audience_group(
        &self,
        create_click_based_audience_group_request: models::CreateClickBasedAudienceGroupRequest,
    ) -> Result<models::CreateClickBasedAudienceGroupResponse, Error> {
        let mut req = __internal_request::Request::new(
            hyper::Method::POST,
            "/v2/bot/audienceGroup/click".to_string(),
        );
        req = req.with_body_param(create_click_based_audience_group_request);

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

    #[allow(unused_mut)]
    async fn create_imp_based_audience_group(
        &self,
        create_imp_based_audience_group_request: models::CreateImpBasedAudienceGroupRequest,
    ) -> Result<models::CreateImpBasedAudienceGroupResponse, Error> {
        let mut req = __internal_request::Request::new(
            hyper::Method::POST,
            "/v2/bot/audienceGroup/imp".to_string(),
        );
        req = req.with_body_param(create_imp_based_audience_group_request);

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

    #[allow(unused_mut)]
    async fn delete_audience_group(&self, audience_group_id: i64) -> Result<(), Error> {
        let mut req = __internal_request::Request::new(
            hyper::Method::DELETE,
            "/v2/bot/audienceGroup/{audienceGroupId}".to_string(),
        );
        req = req.with_path_param("audienceGroupId".to_string(), audience_group_id.to_string());
        req = req.returns_nothing();

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

    #[allow(unused_mut)]
    async fn get_audience_data(
        &self,
        audience_group_id: i64,
    ) -> Result<models::GetAudienceDataResponse, Error> {
        let mut req = __internal_request::Request::new(
            hyper::Method::GET,
            "/v2/bot/audienceGroup/{audienceGroupId}".to_string(),
        );
        req = req.with_path_param("audienceGroupId".to_string(), audience_group_id.to_string());

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

    #[allow(unused_mut)]
    async fn get_audience_groups(
        &self,
        page: i64,
        description: Option<&str>,
        status: Option<models::AudienceGroupStatus>,
        size: Option<i64>,
        includes_external_public_groups: Option<bool>,
        create_route: Option<models::AudienceGroupCreateRoute>,
    ) -> Result<models::GetAudienceGroupsResponse, Error> {
        let mut req = __internal_request::Request::new(
            hyper::Method::GET,
            "/v2/bot/audienceGroup/list".to_string(),
        );
        req = req.with_query_param("page".to_string(), page.to_string());
        if let Some(ref s) = description {
            req = req.with_query_param("description".to_string(), s.to_string());
        }
        if let Some(ref s) = status {
            req = req.with_query_param("status".to_string(), s.to_string());
        }
        if let Some(ref s) = size {
            req = req.with_query_param("size".to_string(), s.to_string());
        }
        if let Some(ref s) = includes_external_public_groups {
            req = req.with_query_param("includesExternalPublicGroups".to_string(), s.to_string());
        }
        if let Some(ref s) = create_route {
            req = req.with_query_param("createRoute".to_string(), s.to_string());
        }

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

    #[allow(unused_mut)]
    async fn get_shared_audience_data(
        &self,
        audience_group_id: i64,
    ) -> Result<models::GetSharedAudienceDataResponse, Error> {
        let mut req = __internal_request::Request::new(
            hyper::Method::GET,
            "/v2/bot/audienceGroup/shared/{audienceGroupId}".to_string(),
        );
        req = req.with_path_param("audienceGroupId".to_string(), audience_group_id.to_string());

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

    #[allow(unused_mut)]
    async fn get_shared_audience_groups(
        &self,
        page: i64,
        description: Option<&str>,
        status: Option<models::AudienceGroupStatus>,
        size: Option<i64>,
        create_route: Option<models::AudienceGroupCreateRoute>,
        includes_owned_audience_groups: Option<bool>,
    ) -> Result<models::GetSharedAudienceGroupsResponse, Error> {
        let mut req = __internal_request::Request::new(
            hyper::Method::GET,
            "/v2/bot/audienceGroup/shared/list".to_string(),
        );
        req = req.with_query_param("page".to_string(), page.to_string());
        if let Some(ref s) = description {
            req = req.with_query_param("description".to_string(), s.to_string());
        }
        if let Some(ref s) = status {
            req = req.with_query_param("status".to_string(), s.to_string());
        }
        if let Some(ref s) = size {
            req = req.with_query_param("size".to_string(), s.to_string());
        }
        if let Some(ref s) = create_route {
            req = req.with_query_param("createRoute".to_string(), s.to_string());
        }
        if let Some(ref s) = includes_owned_audience_groups {
            req = req.with_query_param("includesOwnedAudienceGroups".to_string(), s.to_string());
        }

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

    #[allow(unused_mut)]
    async fn update_audience_group_description(
        &self,
        audience_group_id: i64,
        update_audience_group_description_request: models::UpdateAudienceGroupDescriptionRequest,
    ) -> Result<(), Error> {
        let mut req = __internal_request::Request::new(
            hyper::Method::PUT,
            "/v2/bot/audienceGroup/{audienceGroupId}/updateDescription".to_string(),
        );
        req = req.with_path_param("audienceGroupId".to_string(), audience_group_id.to_string());
        req = req.with_body_param(update_audience_group_description_request);
        req = req.returns_nothing();

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