#![cfg(feature = "cloudflare_reports")]
#![allow(clippy::too_many_arguments, clippy::type_complexity)]
#![allow(
clippy::missing_errors_doc,
clippy::doc_markdown,
clippy::useless_format
)]
#![allow(unused_imports)]
use foundation_macros::JsonHash;
use foundation_netio::shared::client::http_client::HttpClient;
use foundation_netio::{DynNetClient, PreparedRequestBuilder};
use serde::{Deserialize, Serialize};
use super::shared::ApiResponse;
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonHash)]
pub struct AbuseReportsEmailListItem {
pub body: String,
pub id: String,
pub recipient: String,
pub sent_at: String,
pub subject: String,
}
pub type AbuseReportsMessage = super::shared::MessageObject;
pub type AbuseReportsMitigatedEntityType = String;
pub type AbuseReportsMitigationListItem = super::shared::AbuseReportsMitigationListItemShape;
pub type AbuseReportsMitigationStatus = String;
pub type AbuseReportsMitigationType = String;
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonHash)]
pub struct ListEmailsResponse {
pub errors: Option<Vec<AbuseReportsMessage>>,
pub messages: Option<Vec<AbuseReportsMessage>>,
pub result: Option<ListEmailsResponseResult>,
pub result_info: Option<ListEmailsResponseResultInfo>,
pub success: bool,
}
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonHash)]
pub struct ListEmailsResponseResult {
pub emails: Vec<AbuseReportsEmailListItem>,
}
pub type ListEmailsResponseResultInfo = super::shared::ListAbuseReportsResponseResultInfoShape;
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonHash)]
pub struct ListMitigationsResponse {
pub errors: Option<Vec<AbuseReportsMessage>>,
pub messages: Option<Vec<AbuseReportsMessage>>,
pub result: Option<ListMitigationsResponseResult>,
pub result_info: Option<ListMitigationsResponseResultInfo>,
pub success: bool,
}
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonHash)]
pub struct ListMitigationsResponseResult {
pub mitigations: Vec<AbuseReportsMitigationListItem>,
}
pub type ListMitigationsResponseResultInfo = super::shared::ListAbuseReportsResponseResultInfoShape;
#[derive(Debug, Clone, Default, Serialize, JsonHash)]
pub struct ListEmailsArgs {
pub account_id: String,
pub report_id: String,
pub page: Option<String>,
pub per_page: Option<String>,
}
#[derive(Debug, Clone, Default, Serialize, JsonHash)]
pub struct ListMitigationsArgs {
pub account_id: String,
pub report_id: String,
pub page: Option<String>,
pub per_page: Option<String>,
pub sort: Option<String>,
pub r#type: Option<String>,
pub effective_before: Option<String>,
pub effective_after: Option<String>,
pub status: Option<String>,
pub entity_type: Option<String>,
}
pub async fn list_emails_request<F>(
client: impl Into<super::shared::ApiClient>,
args: &ListEmailsArgs,
base_url: &str,
builder_mod: Option<F>,
) -> Result<ApiResponse<ListEmailsResponse>, super::shared::ApiError>
where
F: FnOnce(&mut PreparedRequestBuilder),
{
let path = format!(
"/accounts/{}/abuse-reports/{}/emails",
args.account_id, args.report_id,
);
let endpoint_url = format!("{}{}", base_url, path);
let mut builder = PreparedRequestBuilder::get(&endpoint_url)
.map_err(|e| super::shared::ApiError::RequestBuildFailed(e.to_string()))?;
builder = builder.query("page", args.page.as_deref());
builder = builder.query("per_page", args.per_page.as_deref());
if let Some(f) = builder_mod {
f(&mut builder);
}
super::shared::send_json(client.into(), builder.build()).await
}
pub async fn list_mitigations_request<F>(
client: impl Into<super::shared::ApiClient>,
args: &ListMitigationsArgs,
base_url: &str,
builder_mod: Option<F>,
) -> Result<ApiResponse<ListMitigationsResponse>, super::shared::ApiError>
where
F: FnOnce(&mut PreparedRequestBuilder),
{
let path = format!(
"/accounts/{}/abuse-reports/{}/mitigations",
args.account_id, args.report_id,
);
let endpoint_url = format!("{}{}", base_url, path);
let mut builder = PreparedRequestBuilder::get(&endpoint_url)
.map_err(|e| super::shared::ApiError::RequestBuildFailed(e.to_string()))?;
builder = builder.query("page", args.page.as_deref());
builder = builder.query("per_page", args.per_page.as_deref());
builder = builder.query("sort", args.sort.as_deref());
builder = builder.query("type", args.r#type.as_deref());
builder = builder.query("effective_before", args.effective_before.as_deref());
builder = builder.query("effective_after", args.effective_after.as_deref());
builder = builder.query("status", args.status.as_deref());
builder = builder.query("entity_type", args.entity_type.as_deref());
if let Some(f) = builder_mod {
f(&mut builder);
}
super::shared::send_json(client.into(), builder.build()).await
}