use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Debug)]
pub struct Relay {
    // Allowed Values: relay
    pub dev: String,
    // Allowed Values: digital, physical
    pub relay_type: Option<String>,
    pub circuit: String,
    pub value: i32,
    pub pending: bool,
    pub mode: Option<String>,
    pub modes: Option<Vec<String>>,
    // minimum: 0
    pub glob_dev_id: u32,
    // minimum: 0.1 maximum: 48000000
    pub pwm_freq: Option<f32>,
    // minimum: 0 maximum: 100
    pub pwm_duty: Option<i32>,
    pub alias: Option<String>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct RelayPostData {
    pub circuit: String,
    pub data: RelayInput,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct RelayInput {
    // minimum: 0 maximum: 1
    #[serde(skip_serializing_if = "Option::is_none")]
    pub value: Option<i32>,
    // minimum: 0
    #[serde(skip_serializing_if = "Option::is_none")]
    pub timeout: Option<i32>,
    // Allowed Values: Simple, PWM
    #[serde(skip_serializing_if = "Option::is_none")]
    pub mode: Option<String>,
    // minimum: 0.1 maximum: 48000000
    #[serde(skip_serializing_if = "Option::is_none")]
    pub pwm_freq: Option<i32>,
    // minimum: 0 maximum: 100
    #[serde(skip_serializing_if = "Option::is_none")]
    pub pwm_duty: Option<i32>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub alias: Option<String>,
}
