#![cfg(feature = "cloudflare_resources")]
#![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;
pub type AlexandriaApiResponseCommon = super::shared::ErrorsMessagesSuccessObject;
pub type AlexandriaCategories = Vec<AlexandriaCategory>;
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonHash)]
pub struct AlexandriaCategory {
pub created_at: String,
pub description: String,
pub id: String,
pub name: String,
}
pub type AlexandriaCategoryCreatedAt = String;
pub type AlexandriaCategoryDescription = String;
pub type AlexandriaCategoryId = String;
pub type AlexandriaCategoryName = String;
pub type AlexandriaGetCategoriesResponse =
super::shared::ApiEnvelope<Option<Vec<AlexandriaCategory>>>;
pub type AlexandriaGetCategoryResponse = super::shared::ApiEnvelope<Option<AlexandriaCategory>>;
pub type AlexandriaMessages = Vec<std::collections::HashMap<String, serde_json::Value>>;
pub type GetCategoriesArgs = super::shared::AccountIdArgs;
pub type GetCategoryByIdArgs = super::shared::AccountIdIdArgs;
pub async fn get_categories_request<F>(
client: impl Into<super::shared::ApiClient>,
args: &GetCategoriesArgs,
base_url: &str,
builder_mod: Option<F>,
) -> Result<ApiResponse<AlexandriaGetCategoriesResponse>, super::shared::ApiError>
where
F: FnOnce(&mut PreparedRequestBuilder),
{
let path = format!("/accounts/{}/resource-library/categories", args.account_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()))?;
if let Some(f) = builder_mod {
f(&mut builder);
}
super::shared::send_json(client.into(), builder.build()).await
}
pub async fn get_category_by_id_request<F>(
client: impl Into<super::shared::ApiClient>,
args: &GetCategoryByIdArgs,
base_url: &str,
builder_mod: Option<F>,
) -> Result<ApiResponse<AlexandriaGetCategoryResponse>, super::shared::ApiError>
where
F: FnOnce(&mut PreparedRequestBuilder),
{
let path = format!(
"/accounts/{}/resource-library/categories/{}",
args.account_id, args.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()))?;
if let Some(f) = builder_mod {
f(&mut builder);
}
super::shared::send_json(client.into(), builder.build()).await
}