use reqwest::Method;
use serde::{Deserialize, Serialize};
use crate::{
core::{
api_req::ApiRequest,
api_resp::{ApiResponseTrait, BaseResponse, ResponseFormat},
config::Config,
constants::AccessTokenType,
http::Transport,
req_option::RequestOption,
trait_system::Service,
SDKResult,
},
service::bot::models::Bot,
};
pub struct InfoService {
pub config: Config,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct GetBotInfoResponse {
pub bot: Bot,
}
impl ApiResponseTrait for GetBotInfoResponse {
fn data_format() -> ResponseFormat {
ResponseFormat::Data
}
}
impl InfoService {
pub fn new(config: Config) -> Self {
Self { config }
}
pub async fn get(
&self,
option: Option<RequestOption>,
) -> SDKResult<BaseResponse<GetBotInfoResponse>> {
let api_req = ApiRequest {
http_method: Method::GET,
api_path: "/open-apis/bot/v3/info".to_string(),
supported_access_token_types: vec![AccessTokenType::Tenant],
..Default::default()
};
Transport::request(api_req, &self.config, option).await
}
}
impl Service for InfoService {
fn config(&self) -> &Config {
&self.config
}
fn service_name() -> &'static str {
"bot_info"
}
fn service_version() -> &'static str {
"v3"
}
}