use openlark_core::{
SDKResult, api::ApiRequest, config::Config, http::Transport, req_option::RequestOption,
};
use crate::common::api_utils::{extract_response_data, serialize_params};
pub const TENANT_APP_METRICS_QUERY: &str = "/open-apis/apaas/v1/tenant_app_metrics/query";
#[derive(Debug, Clone)]
pub struct TenantAppMetricsQueryRequest {
config: Config,
}
impl TenantAppMetricsQueryRequest {
pub fn new(config: Config) -> Self {
Self { config }
}
pub async fn execute(self, body: serde_json::Value) -> SDKResult<serde_json::Value> {
self.execute_with_options(body, RequestOption::default())
.await
}
pub async fn execute_with_options(
self,
body: serde_json::Value,
option: RequestOption,
) -> SDKResult<serde_json::Value> {
if body.is_null() {
return Err(openlark_core::error::validation_error(
"body",
"请求体不能为空",
));
}
let req: ApiRequest<serde_json::Value> = ApiRequest::post(TENANT_APP_METRICS_QUERY)
.body(serialize_params(&body, "获取应用运营数据")?);
let resp = Transport::request(req, &self.config, Some(option)).await?;
extract_response_data(resp, "获取应用运营数据")
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_tenant_app_metrics_query_endpoint() {
assert_eq!(
TENANT_APP_METRICS_QUERY,
"/open-apis/apaas/v1/tenant_app_metrics/query"
);
}
}