/*
 * Artifact Keeper API
 *
 * Enterprise artifact registry supporting 45+ package formats.
 *
 * The version of the OpenAPI document: 1.0.0-rc.3
 * 
 * Generated by: https://openapi-generator.tech
 */

use crate::models;
use serde::{Deserialize, Serialize};

/// CrashReport : A stored crash report.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct CrashReport {
    #[serde(rename = "app_version")]
    pub app_version: String,
    #[serde(rename = "component")]
    pub component: String,
    #[serde(rename = "context")]
    pub context: serde_json::Value,
    #[serde(rename = "created_at")]
    pub created_at: String,
    #[serde(rename = "error_message")]
    pub error_message: String,
    #[serde(rename = "error_signature")]
    pub error_signature: String,
    #[serde(rename = "error_type")]
    pub error_type: String,
    #[serde(rename = "first_seen_at")]
    pub first_seen_at: String,
    #[serde(rename = "id")]
    pub id: uuid::Uuid,
    #[serde(rename = "last_seen_at")]
    pub last_seen_at: String,
    #[serde(rename = "occurrence_count")]
    pub occurrence_count: i32,
    #[serde(rename = "os_info", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub os_info: Option<Option<String>>,
    #[serde(rename = "severity")]
    pub severity: String,
    #[serde(rename = "stack_trace", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub stack_trace: Option<Option<String>>,
    #[serde(rename = "submission_error", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub submission_error: Option<Option<String>>,
    #[serde(rename = "submitted")]
    pub submitted: bool,
    #[serde(rename = "submitted_at", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub submitted_at: Option<Option<String>>,
    #[serde(rename = "uptime_seconds", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub uptime_seconds: Option<Option<i64>>,
}

impl CrashReport {
    /// A stored crash report.
    pub fn new(app_version: String, component: String, context: serde_json::Value, created_at: String, error_message: String, error_signature: String, error_type: String, first_seen_at: String, id: uuid::Uuid, last_seen_at: String, occurrence_count: i32, severity: String, submitted: bool) -> CrashReport {
        CrashReport {
            app_version,
            component,
            context,
            created_at,
            error_message,
            error_signature,
            error_type,
            first_seen_at,
            id,
            last_seen_at,
            occurrence_count,
            os_info: None,
            severity,
            stack_trace: None,
            submission_error: None,
            submitted,
            submitted_at: None,
            uptime_seconds: None,
        }
    }
}

