use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct FunctionShellCallItemParam {
#[serde(
rename = "id",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub id: Option<Option<String>>,
#[serde(rename = "call_id")]
pub call_id: String,
#[serde(rename = "type")]
pub r#type: Type,
#[serde(rename = "action")]
pub action: Box<models::FunctionShellActionParam>,
#[serde(
rename = "status",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub status: Option<Option<models::FunctionShellCallItemStatus>>,
#[serde(
rename = "environment",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub environment: Option<Option<Box<models::FunctionShellCallItemParamEnvironment>>>,
}
impl FunctionShellCallItemParam {
pub fn new(
call_id: String,
r#type: Type,
action: models::FunctionShellActionParam,
) -> FunctionShellCallItemParam {
FunctionShellCallItemParam {
id: None,
call_id,
r#type,
action: Box::new(action),
status: None,
environment: None,
}
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
#[serde(rename = "shell_call")]
ShellCall,
}
impl Default for Type {
fn default() -> Type {
Self::ShellCall
}
}
impl std::fmt::Display for FunctionShellCallItemParam {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match serde_json::to_string(self) {
Ok(s) => write!(f, "{}", s),
Err(_) => Err(std::fmt::Error),
}
}
}