/*
 * 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};

/// Webhook : Serializer for webhook creation/update requests
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct Webhook {
    /// Descriptive name for this webhook
    #[serde(rename = "name")]
    pub name: String,
    /// HTTPS URL where webhook events will be sent
    #[serde(rename = "url")]
    pub url: String,
    /// List of events to subscribe to. Valid events: check.status_changed, screening.status_changed, screening.archived, package.created, package.updated, profile.created, profile.updated, division.created, division.updated
    #[serde(rename = "events")]
    pub events: Vec<Events>,
    /// Whether the webhook is active
    #[serde(rename = "active", skip_serializing_if = "Option::is_none")]
    pub active: Option<bool>,
    /// Division ID to create webhook for (optional)
    #[serde(rename = "division_id", skip_serializing_if = "Option::is_none")]
    pub division_id: Option<uuid::Uuid>,
}

impl Webhook {
    /// Serializer for webhook creation/update requests
    pub fn new(name: String, url: String, events: Vec<Events>) -> Webhook {
        Webhook {
            name,
            url,
            events,
            active: None,
            division_id: None,
        }
    }
}
/// List of events to subscribe to. Valid events: check.status_changed, screening.status_changed, screening.archived, package.created, package.updated, profile.created, profile.updated, division.created, division.updated
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Events {
    #[serde(rename = "check.status_changed")]
    CheckStatusChanged,
    #[serde(rename = "screening.status_changed")]
    ScreeningStatusChanged,
    #[serde(rename = "screening.archived")]
    ScreeningArchived,
    #[serde(rename = "package.created")]
    PackageCreated,
    #[serde(rename = "package.updated")]
    PackageUpdated,
    #[serde(rename = "profile.created")]
    ProfileCreated,
    #[serde(rename = "profile.updated")]
    ProfileUpdated,
    #[serde(rename = "division.created")]
    DivisionCreated,
    #[serde(rename = "division.updated")]
    DivisionUpdated,
}

impl Default for Events {
    fn default() -> Events {
        Self::CheckStatusChanged
    }
}

