Reorganazing files

This commit is contained in:
Marco De Araujo 2025-12-23 05:14:56 -04:00
parent 4ff103454e
commit 7270249ef6
10 changed files with 8 additions and 7 deletions

View file

@ -0,0 +1,3 @@
pub mod model;
pub mod parser;
pub use parser::parse_response;

View file

@ -0,0 +1,56 @@
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct StatusPageConfig {
pub slug: String,
pub title: String,
#[serde(default)]
pub description: Option<String>,
pub icon: String,
#[serde(rename = "autoRefreshInterval")]
pub auto_refresh_interval: u32,
pub theme: String,
pub published: bool,
#[serde(rename = "showTags")]
pub show_tags: bool,
#[serde(rename = "customCSS")]
pub custon_css: String,
#[serde(rename = "footerText", default)]
pub footer_text: Option<String>,
#[serde(rename = "showPoweredBy")]
pub show_powered_by: bool,
#[serde(rename = "googleAnalyticsId", default)]
pub google_analytics_id: Option<String>,
#[serde(rename = "showCertificateExpiry")]
pub show_certificate_expiry: bool,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct MonitorInfo {
pub id: u64,
pub name: String,
#[serde(rename = "sendUrl")]
pub send_url: u8,
#[serde(rename = "type")]
pub monitor_type: String,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct StatusPageGroup {
pub id: u64,
pub name: String,
pub weight: u32,
#[serde(rename = "monitorList")]
pub monitor_list: Vec<MonitorInfo>,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct StatusPageResponse {
pub config: StatusPageConfig,
#[serde(skip, default)]
pub incident: Option<String>,
#[serde(rename = "publicGroupList")]
pub public_group_list: Vec<StatusPageGroup>,
#[serde(rename = "maintenanceList", skip)]
pub maintenance_list: Vec<String>,
}

View file

@ -0,0 +1,9 @@
use super::model::StatusPageResponse;
use crate::i18n::t;
use anyhow::{Context, Ok, Result};
pub fn parse_response(json_text: &str) -> Result<StatusPageResponse> {
let response: StatusPageResponse =
serde_json::from_str(json_text).with_context(|| t("invalid-json-status-page"))?;
Ok(response)
}