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, Default, Serialize)]
pub(crate) struct SmartCamGetParams {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub device_info: Option<SectionNames>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub preset: Option<SectionNames>,
}

impl SmartCamGetParams {
    pub fn device_info() -> Self {
        Self {
            device_info: Some(SectionNames::new(&["basic_info"])),
            ..Default::default()
        }
    }

    pub fn preset() -> Self {
        Self {
            preset: Some(SectionNames::new(&["preset"])),
            ..Default::default()
        }
    }
}

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

impl SectionNames {
    pub fn new(names: &[&str]) -> Self {
        Self {
            name: names.iter().map(|s| (*s).to_string()).collect(),
        }
    }
}