use chrono::{DateTime, Utc};
use dialtone_common::rest::{
ap_objects::{
ap_object_model::ApObjectPage, ap_object_pages_exchanges::GetApObjectPagesByHost,
},
api_paths::full_path::AP_OBJECT_PAGES__BY_HOST,
};
use crate::{dt_reqwest_error::DtReqwestError, site_connection::SiteConnection};
pub async fn page_ap_objects_by_host(
sc: &SiteConnection,
prev_date: Option<&DateTime<Utc>>,
next_date: Option<&DateTime<Utc>>,
limit: u32,
host_name: &str,
) -> Result<ApObjectPage, DtReqwestError> {
let request = GetApObjectPagesByHost {
prev_date: prev_date.cloned(),
next_date: next_date.cloned(),
limit,
host_name: host_name.to_owned(),
};
let response = sc
.get(AP_OBJECT_PAGES__BY_HOST, &[])
.query(&request)
.send()
.await?
.error_for_status()?
.json()
.await?;
Ok(response)
}