tapo 0.9.0

Unofficial Tapo API Client. Works with TP-Link Tapo smart devices. Tested with light bulbs (L510, L520, L530, L535, L610, L630), light strips (L900, L920, L930), plugs (P100, P105, P110, P110M, P115), power strips (P300, P304M, P306, P316M), hubs (H100), switches (S200B, S200D, S210) and sensors (KE100, T100, T110, T300, T310, T315).
Documentation
use serde::Serialize;

#[derive(Debug, Serialize)]
pub(crate) struct SmartCamDoParams {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub motor: Option<MotorAction>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub preset: Option<PresetAction>,
}

impl SmartCamDoParams {
    pub fn motor_move(x: i32, y: i32) -> Self {
        Self {
            motor: Some(MotorAction {
                move_action: MotorMoveParams {
                    x_coord: x.to_string(),
                    y_coord: y.to_string(),
                },
            }),
            preset: None,
        }
    }

    pub fn set_preset(name: &str) -> Self {
        Self {
            motor: None,
            preset: Some(PresetAction {
                set_preset: Some(SetPresetParams {
                    name: name.to_string(),
                }),
                goto_preset: None,
                remove_preset: None,
            }),
        }
    }

    pub fn goto_preset(id: &str) -> Self {
        Self {
            motor: None,
            preset: Some(PresetAction {
                set_preset: None,
                goto_preset: Some(GotoPresetParams { id: id.to_string() }),
                remove_preset: None,
            }),
        }
    }

    pub fn remove_preset(id: &str) -> Self {
        Self {
            motor: None,
            preset: Some(PresetAction {
                set_preset: None,
                goto_preset: None,
                remove_preset: Some(RemovePresetParams {
                    id: vec![id.to_string()],
                }),
            }),
        }
    }
}

#[derive(Debug, Serialize)]
pub(crate) struct MotorAction {
    #[serde(rename = "move")]
    pub move_action: MotorMoveParams,
}

#[derive(Debug, Serialize)]
pub(crate) struct MotorMoveParams {
    pub x_coord: String,
    pub y_coord: String,
}

#[derive(Debug, Serialize)]
pub(crate) struct PresetAction {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub set_preset: Option<SetPresetParams>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub goto_preset: Option<GotoPresetParams>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub remove_preset: Option<RemovePresetParams>,
}

#[derive(Debug, Serialize)]
pub(crate) struct SetPresetParams {
    pub name: String,
}

#[derive(Debug, Serialize)]
pub(crate) struct GotoPresetParams {
    pub id: String,
}

#[derive(Debug, Serialize)]
pub(crate) struct RemovePresetParams {
    pub id: Vec<String>,
}