(
query: &AdminApiBehaviorEventsQuery,
)
| 3677 | } |
| 3678 | |
| 3679 | pub async fn fetch_admin_api_behavior_events( |
| 3680 | query: &AdminApiBehaviorEventsQuery, |
| 3681 | ) -> Result<AdminApiBehaviorEventsResponse, String> { |
| 3682 | #[cfg(feature = "mock")] |
| 3683 | { |
| 3684 | Ok(AdminApiBehaviorEventsResponse { |
| 3685 | total: 0, |
| 3686 | offset: query.offset.unwrap_or(0), |
| 3687 | limit: query.limit.unwrap_or(100), |
| 3688 | has_more: false, |
| 3689 | events: vec![], |
| 3690 | }) |
| 3691 | } |
| 3692 | |
| 3693 | #[cfg(not(feature = "mock"))] |
| 3694 | { |
| 3695 | let mut url = format!("{}/admin/api-behavior/events", admin_base()); |
| 3696 | let mut params = Vec::new(); |
| 3697 | if let Some(days) = query.days { |
| 3698 | params.push(format!("days={days}")); |
| 3699 | } |
| 3700 | if let Some(value) = query |
| 3701 | .date |
| 3702 | .as_deref() |
| 3703 | .map(str::trim) |
| 3704 | .filter(|v| !v.is_empty()) |
| 3705 | { |
| 3706 | params.push(format!("date={}", urlencoding::encode(value))); |
| 3707 | } |
| 3708 | if let Some(limit) = query.limit { |
| 3709 | params.push(format!("limit={limit}")); |
| 3710 | } |
| 3711 | if let Some(offset) = query.offset { |
| 3712 | params.push(format!("offset={offset}")); |
| 3713 | } |
| 3714 | if let Some(value) = query |
| 3715 | .path_contains |
| 3716 | .as_deref() |
| 3717 | .map(str::trim) |
| 3718 | .filter(|v| !v.is_empty()) |
| 3719 | { |
| 3720 | params.push(format!("path_contains={}", urlencoding::encode(value))); |
| 3721 | } |
| 3722 | if let Some(value) = query |
| 3723 | .page_contains |
| 3724 | .as_deref() |
| 3725 | .map(str::trim) |
| 3726 | .filter(|v| !v.is_empty()) |
| 3727 | { |
| 3728 | params.push(format!("page_contains={}", urlencoding::encode(value))); |
| 3729 | } |
| 3730 | if let Some(value) = query |
| 3731 | .device_type |
| 3732 | .as_deref() |
| 3733 | .map(str::trim) |
| 3734 | .filter(|v| !v.is_empty()) |
| 3735 | { |
| 3736 | params.push(format!("device_type={}", urlencoding::encode(value))); |
no test coverage detected