#[derive(Clone, Debug)]
#[non_exhaustive]
pub struct SceneActionParam {
pub param_id: String,
pub value: String,
pub param_type: Option<String>,
pub param_unit: Option<String>,
}
impl SceneActionParam {
pub fn new(param_id: impl Into<String>, value: impl Into<String>) -> Self {
Self {
param_id: param_id.into(),
value: value.into(),
param_type: None,
param_unit: None,
}
}
pub fn with_param_type(mut self, param_type: impl Into<String>) -> Self {
self.param_type = Some(param_type.into());
self
}
pub fn with_param_unit(mut self, param_unit: impl Into<String>) -> Self {
self.param_unit = Some(param_unit.into());
self
}
}
#[derive(Clone, Debug)]
#[non_exhaustive]
pub struct SceneAction {
pub subject_id: String,
pub action_definition_id: String,
pub params: Vec<SceneActionParam>,
pub delay_time: Option<String>,
pub delay_time_unit: Option<String>,
}
impl SceneAction {
pub fn new(
subject_id: impl Into<String>,
action_definition_id: impl Into<String>,
params: impl Into<Vec<SceneActionParam>>,
) -> Self {
Self {
subject_id: subject_id.into(),
action_definition_id: action_definition_id.into(),
params: params.into(),
delay_time: None,
delay_time_unit: None,
}
}
pub fn with_delay_time(mut self, delay_time: impl Into<String>) -> Self {
self.delay_time = Some(delay_time.into());
self
}
pub fn with_delay_time_unit(mut self, delay_time_unit: impl Into<String>) -> Self {
self.delay_time_unit = Some(delay_time_unit.into());
self
}
}
#[derive(Clone, Debug)]
#[non_exhaustive]
pub struct CreateSceneParams {
pub name: String,
pub position_id: Option<String>,
pub action: Vec<SceneAction>,
}
impl CreateSceneParams {
pub fn new(name: impl Into<String>, action: impl Into<Vec<SceneAction>>) -> Self {
Self {
name: name.into(),
position_id: None,
action: action.into(),
}
}
pub fn with_position_id(mut self, position_id: impl Into<String>) -> Self {
self.position_id = Some(position_id.into());
self
}
}
#[derive(Clone, Debug)]
#[non_exhaustive]
pub struct UpdateSceneParams {
pub scene_id: String,
pub name: String,
pub position_id: Option<String>,
pub action: Vec<SceneAction>,
}
impl UpdateSceneParams {
pub fn new(
scene_id: impl Into<String>,
name: impl Into<String>,
action: impl Into<Vec<SceneAction>>,
) -> Self {
Self {
scene_id: scene_id.into(),
name: name.into(),
position_id: None,
action: action.into(),
}
}
pub fn with_position_id(mut self, position_id: impl Into<String>) -> Self {
self.position_id = Some(position_id.into());
self
}
}
#[derive(Clone, Debug)]
#[non_exhaustive]
pub struct DeleteSceneParams {
pub scene_id: String,
}
impl DeleteSceneParams {
pub fn new(scene_id: impl Into<String>) -> Self {
Self {
scene_id: scene_id.into(),
}
}
}
#[derive(Clone, Debug)]
#[non_exhaustive]
pub struct RunSceneParams {
pub scene_id: String,
}
impl RunSceneParams {
pub fn new(scene_id: impl Into<String>) -> Self {
Self {
scene_id: scene_id.into(),
}
}
}
#[derive(Clone, Debug)]
#[non_exhaustive]
pub struct QuerySceneDetailParams {
pub scene_id: String,
}
impl QuerySceneDetailParams {
pub fn new(scene_id: impl Into<String>) -> Self {
Self {
scene_id: scene_id.into(),
}
}
}
#[derive(Clone, Debug)]
#[non_exhaustive]
pub struct QueryScenesBySubjectIdParams {
pub subject_id: String,
}
impl QueryScenesBySubjectIdParams {
pub fn new(subject_id: impl Into<String>) -> Self {
Self {
subject_id: subject_id.into(),
}
}
}
#[derive(Clone, Debug)]
#[non_exhaustive]
pub struct QueryScenesByPositionIdParams {
pub position_id: Option<String>,
pub page_num: u32,
pub page_size: u32,
}
impl Default for QueryScenesByPositionIdParams {
fn default() -> Self {
Self {
position_id: None,
page_num: 1,
page_size: 50,
}
}
}
impl QueryScenesByPositionIdParams {
pub fn with_position_id(mut self, position_id: impl Into<String>) -> Self {
self.position_id = Some(position_id.into());
self
}
pub fn with_page_num(mut self, page_num: u32) -> Self {
self.page_num = page_num;
self
}
pub fn with_page_size(mut self, page_size: u32) -> Self {
self.page_size = page_size;
self
}
}