vapi_client/models/rule_based_condition.rs
1/*
2 * Vapi API
3 *
4 * API for building voice assistants
5 *
6 * The version of the OpenAPI document: 1.0
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use serde::{Deserialize, Serialize};
12
13use crate::models;
14
15#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
16pub struct RuleBasedCondition {
17 /// This condition is based on a strict rule.
18 #[serde(rename = "type")]
19 pub r#type: Type,
20 /// This is the operator you want to use to compare the left side and right side. The operation becomes `(leftSide) operator (rightSide)`.
21 #[serde(rename = "operator")]
22 pub operator: Operator,
23 /// This is the left side of the operation. You can reference any variable in the context of the current block execution (step): - \"{{output.your-property-name}}\" for current step's output - \"{{input.your-property-name}}\" for current step's input - \"{{your-step-name.output.your-property-name}}\" for another step's output (in the same workflow; read caveat #1) - \"{{your-step-name.input.your-property-name}}\" for another step's input (in the same workflow; read caveat #1) - \"{{your-block-name.output.your-property-name}}\" for another block's output (in the same workflow; read caveat #2) - \"{{your-block-name.input.your-property-name}}\" for another block's input (in the same workflow; read caveat #2) - \"{{workflow.input.your-property-name}}\" for the current workflow's input - \"{{global.your-property-name}}\" for the global context Or, you can use a constant: - \"1\" - \"text\" - \"true\" - \"false\" Or, you can mix and match with string interpolation: - \"{{your-property-name}}-{{input.your-property-name-2}}-1\" Caveats: 1. a workflow can execute a step multiple times. example, if a loop is used in the graph. {{stepName.input/output.propertyName}} will reference the latest usage of the step. 2. a workflow can execute a block multiple times. example, if a step is called multiple times or if a block is used in multiple steps. {{blockName.input/output.propertyName}} will reference the latest usage of the block. this liquid variable is just provided for convenience when creating blocks outside of a workflow with steps.
24 #[serde(rename = "leftSide")]
25 pub left_side: String,
26 /// This is the right side of the operation. You can reference any variable in the context of the current block execution (step): - \"{{output.your-property-name}}\" for current step's output - \"{{input.your-property-name}}\" for current step's input - \"{{your-step-name.output.your-property-name}}\" for another step's output (in the same workflow; read caveat #1) - \"{{your-step-name.input.your-property-name}}\" for another step's input (in the same workflow; read caveat #1) - \"{{your-block-name.output.your-property-name}}\" for another block's output (in the same workflow; read caveat #2) - \"{{your-block-name.input.your-property-name}}\" for another block's input (in the same workflow; read caveat #2) - \"{{workflow.input.your-property-name}}\" for the current workflow's input - \"{{global.your-property-name}}\" for the global context Or, you can use a constant: - \"1\" - \"text\" - \"true\" - \"false\" Or, you can mix and match with string interpolation: - \"{{your-property-name}}-{{input.your-property-name-2}}-1\" Caveats: 1. a workflow can execute a step multiple times. example, if a loop is used in the graph. {{stepName.input/output.propertyName}} will reference the latest usage of the step. 2. a workflow can execute a block multiple times. example, if a step is called multiple times or if a block is used in multiple steps. {{blockName.input/output.propertyName}} will reference the latest usage of the block. this liquid variable is just provided for convenience when creating blocks outside of a workflow with steps.
27 #[serde(rename = "rightSide")]
28 pub right_side: String,
29}
30
31impl RuleBasedCondition {
32 pub fn new(
33 r#type: Type,
34 operator: Operator,
35 left_side: String,
36 right_side: String,
37 ) -> RuleBasedCondition {
38 RuleBasedCondition {
39 r#type,
40 operator,
41 left_side,
42 right_side,
43 }
44 }
45}
46/// This condition is based on a strict rule.
47#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
48pub enum Type {
49 #[serde(rename = "rule-based")]
50 RuleBased,
51}
52
53impl Default for Type {
54 fn default() -> Type {
55 Self::RuleBased
56 }
57}
58/// This is the operator you want to use to compare the left side and right side. The operation becomes `(leftSide) operator (rightSide)`.
59#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
60pub enum Operator {
61 #[serde(rename = "eq")]
62 Eq,
63 #[serde(rename = "neq")]
64 Neq,
65 #[serde(rename = "gt")]
66 Gt,
67 #[serde(rename = "gte")]
68 Gte,
69 #[serde(rename = "lt")]
70 Lt,
71 #[serde(rename = "lte")]
72 Lte,
73}
74
75impl Default for Operator {
76 fn default() -> Operator {
77 Self::Eq
78 }
79}