/*
 * Pescheck API
 *
 * Official client library for the Pescheck API (v2), generated from the OpenAPI specification. Authenticate with OAuth2 client credentials and use the checks, profiles, screenings, webhooks and divisions endpoints. See https://github.com/pescheckit/pescheck-clients for installation and usage.
 *
 * The version of the OpenAPI document: 2.0.0
 * 
 * Generated by: https://openapi-generator.tech
 */

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

/// WebhookResponse : Serializer for webhook responses
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct WebhookResponse {
    #[serde(rename = "id")]
    pub id: uuid::Uuid,
    #[serde(rename = "name")]
    pub name: String,
    #[serde(rename = "url")]
    pub url: String,
    #[serde(rename = "events", deserialize_with = "Option::deserialize")]
    pub events: Option<serde_json::Value>,
    #[serde(rename = "active", skip_serializing_if = "Option::is_none")]
    pub active: Option<bool>,
    #[serde(rename = "verified")]
    pub verified: bool,
    #[serde(rename = "token", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub token: Option<Option<String>>,
    #[serde(rename = "organisation_name", skip_serializing_if = "Option::is_none")]
    pub organisation_name: Option<String>,
    #[serde(rename = "created_at")]
    pub created_at: chrono::DateTime<chrono::FixedOffset>,
    #[serde(rename = "updated_at")]
    pub updated_at: chrono::DateTime<chrono::FixedOffset>,
}

impl WebhookResponse {
    /// Serializer for webhook responses
    pub fn new(id: uuid::Uuid, name: String, url: String, events: Option<serde_json::Value>, verified: bool, created_at: chrono::DateTime<chrono::FixedOffset>, updated_at: chrono::DateTime<chrono::FixedOffset>) -> WebhookResponse {
        WebhookResponse {
            id,
            name,
            url,
            events,
            active: None,
            verified,
            token: None,
            organisation_name: None,
            created_at,
            updated_at,
        }
    }
}

