#![doc = include_str!("../README.md")]
mod batch_run_pivot_reports;
mod batch_run_reports;
mod check_compatibility;
mod error;
mod get_metadata;
mod http;
mod run_pivot_reports;
mod run_realtime_report;
mod run_report;
pub mod types;
pub use batch_run_pivot_reports::BatchRunPivotReportsResponse;
pub use batch_run_reports::BatchRunReportsResponse;
pub use check_compatibility::*;
pub use error::*;
pub use get_metadata::*;
pub use run_pivot_reports::*;
pub use run_realtime_report::*;
pub use run_report::*;
use crate::batch_run_pivot_reports::BatchRunPivotReportsRequestBody;
use crate::batch_run_reports::BatchRunReportsRequestBody;
use crate::http::HttpClient;
use crate::types::{RunPivotReportResponse, RunReportResponse};
const ENDPOINT: &str = "https://analyticsdata.googleapis.com/v1beta";
pub struct AnalyticsDataApi {}
impl AnalyticsDataApi {
pub async fn batch_run_pivot_reports(
token: &str,
property: &str,
requests: Vec<RunPivotReportRequest>,
) -> Result<BatchRunPivotReportsResponse, GoogleApiError> {
HttpClient::post(
token,
format!("{}/properties/{}:batchRunPivotReports", ENDPOINT, property).as_str(),
BatchRunPivotReportsRequestBody { requests },
)
.await
}
pub async fn batch_run_reports(
token: &str,
property: &str,
requests: Vec<RunReportRequest>,
) -> Result<BatchRunReportsResponse, GoogleApiError> {
HttpClient::post(
token,
format!("{}/properties/{}:batchRunReports", ENDPOINT, property).as_str(),
BatchRunReportsRequestBody { requests },
)
.await
}
pub async fn check_compatibility(
token: &str,
property: &str,
request: CheckCompatibilityRequest,
) -> Result<CheckCompatibilityResponse, GoogleApiError> {
HttpClient::post(
token,
format!("{}/properties/{}:checkCompatibility", ENDPOINT, property).as_str(),
request,
)
.await
}
pub async fn get_metadata(
token: &str,
property: &str,
) -> Result<GetMetadataResponse, GoogleApiError> {
HttpClient::get(
token,
format!("{}/properties/{}/metadata", ENDPOINT, property).as_str(),
)
.await
}
pub async fn run_pivot_report(
token: &str,
property: &str,
request: RunPivotReportRequest,
) -> Result<RunPivotReportResponse, GoogleApiError> {
HttpClient::post(
token,
format!("{}/properties/{}:runPivotReport", ENDPOINT, property).as_str(),
request,
)
.await
}
pub async fn run_realtime_report(
token: &str,
property: &str,
request: RunRealtimeReportRequest,
) -> Result<RunReportResponse, GoogleApiError> {
HttpClient::post(
token,
format!("{}/properties/{}:runRealtimeReport", ENDPOINT, property).as_str(),
request,
)
.await
}
pub async fn run_report(
token: &str,
property: &str,
request: RunReportRequest,
) -> Result<RunReportResponse, GoogleApiError> {
HttpClient::post(
token,
format!("{}/properties/{}:runReport", ENDPOINT, property).as_str(),
request,
)
.await
}
}