svix_webhook_with_clone/api/
statistics.rs1use super::PostOptions;
2use crate::{apis::statistics_api, error::Result, models::*, Configuration};
3
4pub struct Statistics<'a> {
5 cfg: &'a Configuration,
6}
7
8pub struct AggregateAppStatsOptions {
9 pub app_ids: Option<Vec<String>>,
10 pub since: String,
11 pub until: String,
12}
13
14impl<'a> Statistics<'a> {
15 pub(super) fn new(cfg: &'a Configuration) -> Self {
16 Self { cfg }
17 }
18
19 pub async fn aggregate_app_stats(
25 &self,
26 AggregateAppStatsOptions {
27 app_ids,
28 since,
29 until,
30 }: AggregateAppStatsOptions,
31 options: Option<PostOptions>,
32 ) -> Result<AppUsageStatsOut> {
33 let options = options.unwrap_or_default();
34 let params = statistics_api::V1PeriodStatisticsPeriodAggregateAppStatsParams {
35 app_usage_stats_in: AppUsageStatsIn {
36 app_ids,
37 since,
38 until,
39 },
40 idempotency_key: options.idempotency_key,
41 };
42 statistics_api::v1_period_statistics_period_aggregate_app_stats(self.cfg, params).await
43 }
44
45 pub async fn aggregate_event_types(&self) -> Result<AggregateEventTypesOut> {
51 statistics_api::v1_period_statistics_period_aggregate_event_types(self.cfg).await
52 }
53}