Class: Vapi::AssignmentMutation

Inherits:
Object
  • Object
show all
Defined in:
lib/vapi_server_sdk/types/assignment_mutation.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, variable:, value:, conditions: OMIT, additional_properties: nil) ⇒ Vapi::AssignmentMutation

Parameters:

  • conditions (Array<Vapi::AssignmentMutationConditionsItem>) (defaults to: OMIT)

    This is an optional array of conditions that must be met for this mutation to be triggered.

  • type (String)

    This mutation assigns a new value to an existing or new variable.

  • variable (String)

    This is the variable to assign a new value to. You can reference any variable in the context of the current block execution (step):

    • “output.your-property-name” for current step’s output

    • “your-step-name.output.your-property-name” for another step’s output (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)

    • “global.your-property-name” for the global context

    This needs to be the key path of the variable. If you use {}, it’ll dereference that to the value of the variable before assignment. This can be useful if the path is dynamic. Example:

    • “global.Vapi::AssignmentMutation.{my-tool-call-step{my-tool-call-step.output{my-tool-call-step.output.my-key-name}”

    You can also string interpolate multiple variables to get the key name: - -call-step.output.my-key-name-suffix}}-Vapi::AssignmentMutation.{my-tool-call-step{my-tool-call-step.output{my-tool-call-step.output.my-key-name}“ The path to the new variable is created if it doesn’t exist. Example:

    • “global.this-does-not-exist.neither-does-this” will create

    ‘this-does-not-exist` object with `neither-does-this` as a key Caveats:

    1. a workflow can execute a step multiple times. example, if a loop is used in

    the graph. Vapi::AssignmentMutation.{stepName{stepName.output{stepName.output.propertyName} will reference the latest usage of the step.

    1. 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. Vapi::AssignmentMutation.{blockName{blockName.output{blockName.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.

  • value (String)

    The value to assign to the variable. You can reference any variable in the context of the current block execution (step):

    • “Vapi::AssignmentMutation.{output{output.your-property-name}” for current step’s output

    • “Vapi::AssignmentMutation.{your-step-name{your-step-name.output{your-step-name.output.your-property-name}” for another step’s output (in

    the same workflow; read caveat #1)

    • “Vapi::AssignmentMutation.{your-block-name{your-block-name.output{your-block-name.output.your-property-name}” for another block’s output (in

    the same workflow; read caveat #2)

    • “Vapi::AssignmentMutation.{global{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}-Vapi::AssignmentMutation.{input{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. Vapi::AssignmentMutation.{stepName{stepName.output{stepName.output.propertyName} will reference the latest usage of the step.

    1. 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. Vapi::AssignmentMutation.{blockName{blockName.output{blockName.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.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



135
136
137
138
139
140
141
142
143
144
# File 'lib/vapi_server_sdk/types/assignment_mutation.rb', line 135

def initialize(type:, variable:, value:, conditions: OMIT, additional_properties: nil)
  @conditions = conditions if conditions != OMIT
  @type = type
  @variable = variable
  @value = value
  @additional_properties = additional_properties
  @_field_set = { "conditions": conditions, "type": type, "variable": variable, "value": value }.reject do |_k, v|
    v == OMIT
  end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



70
71
72
# File 'lib/vapi_server_sdk/types/assignment_mutation.rb', line 70

def additional_properties
  @additional_properties
end

#conditionsArray<Vapi::AssignmentMutationConditionsItem> (readonly)

Returns This is an optional array of conditions that must be met for this mutation to be triggered.

Returns:



11
12
13
# File 'lib/vapi_server_sdk/types/assignment_mutation.rb', line 11

def conditions
  @conditions
end

#typeString (readonly)

Returns This mutation assigns a new value to an existing or new variable.

Returns:

  • (String)

    This mutation assigns a new value to an existing or new variable.



13
14
15
# File 'lib/vapi_server_sdk/types/assignment_mutation.rb', line 13

def type
  @type
end

#valueString (readonly)

Returns The value to assign to the variable. You can reference any variable in the context of the current block execution (step):

  • “Vapi::AssignmentMutation.{output{output.your-property-name}” for current step’s output

  • “Vapi::AssignmentMutation.{your-step-name{your-step-name.output{your-step-name.output.your-property-name}” for another step’s output (in

the same workflow; read caveat #1)

  • “Vapi::AssignmentMutation.{your-block-name{your-block-name.output{your-block-name.output.your-property-name}” for another block’s output (in

the same workflow; read caveat #2)

  • “Vapi::AssignmentMutation.{global{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}-Vapi::AssignmentMutation.{input{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. Vapi::AssignmentMutation.{stepName{stepName.output{stepName.output.propertyName} will reference the latest usage of the step.

  1. 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. Vapi::AssignmentMutation.{blockName{blockName.output{blockName.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.

Returns:

  • (String)

    The value to assign to the variable. You can reference any variable in the context of the current block execution (step):

    • “Vapi::AssignmentMutation.{output{output.your-property-name}” for current step’s output

    • “Vapi::AssignmentMutation.{your-step-name{your-step-name.output{your-step-name.output.your-property-name}” for another step’s output (in

    the same workflow; read caveat #1)

    • “Vapi::AssignmentMutation.{your-block-name{your-block-name.output{your-block-name.output.your-property-name}” for another block’s output (in

    the same workflow; read caveat #2)

    • “Vapi::AssignmentMutation.{global{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}-Vapi::AssignmentMutation.{input{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. Vapi::AssignmentMutation.{stepName{stepName.output{stepName.output.propertyName} will reference the latest usage of the step.

    1. 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. Vapi::AssignmentMutation.{blockName{blockName.output{blockName.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.



68
69
70
# File 'lib/vapi_server_sdk/types/assignment_mutation.rb', line 68

def value
  @value
end

#variableString (readonly)

Returns This is the variable to assign a new value to. You can reference any variable in the context of the current block execution (step):

  • “output.your-property-name” for current step’s output

  • “your-step-name.output.your-property-name” for another step’s output (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)

  • “global.your-property-name” for the global context

This needs to be the key path of the variable. If you use {}, it’ll dereference that to the value of the variable before assignment. This can be useful if the path is dynamic. Example:

  • “global.Vapi::AssignmentMutation.{my-tool-call-step{my-tool-call-step.output{my-tool-call-step.output.my-key-name}”

You can also string interpolate multiple variables to get the key name: - -call-step.output.my-key-name-suffix}}-Vapi::AssignmentMutation.{my-tool-call-step{my-tool-call-step.output{my-tool-call-step.output.my-key-name}“ The path to the new variable is created if it doesn’t exist. Example:

  • “global.this-does-not-exist.neither-does-this” will create

‘this-does-not-exist` object with `neither-does-this` as a key Caveats:

  1. a workflow can execute a step multiple times. example, if a loop is used in

the graph. Vapi::AssignmentMutation.{stepName{stepName.output{stepName.output.propertyName} will reference the latest usage of the step.

  1. 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. Vapi::AssignmentMutation.{blockName{blockName.output{blockName.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.

Returns:

  • (String)

    This is the variable to assign a new value to. You can reference any variable in the context of the current block execution (step):

    • “output.your-property-name” for current step’s output

    • “your-step-name.output.your-property-name” for another step’s output (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)

    • “global.your-property-name” for the global context

    This needs to be the key path of the variable. If you use {}, it’ll dereference that to the value of the variable before assignment. This can be useful if the path is dynamic. Example:

    • “global.Vapi::AssignmentMutation.{my-tool-call-step{my-tool-call-step.output{my-tool-call-step.output.my-key-name}”

    You can also string interpolate multiple variables to get the key name: - -call-step.output.my-key-name-suffix}}-Vapi::AssignmentMutation.{my-tool-call-step{my-tool-call-step.output{my-tool-call-step.output.my-key-name}“ The path to the new variable is created if it doesn’t exist. Example:

    • “global.this-does-not-exist.neither-does-this” will create

    ‘this-does-not-exist` object with `neither-does-this` as a key Caveats:

    1. a workflow can execute a step multiple times. example, if a loop is used in

    the graph. Vapi::AssignmentMutation.{stepName{stepName.output{stepName.output.propertyName} will reference the latest usage of the step.

    1. 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. Vapi::AssignmentMutation.{blockName{blockName.output{blockName.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.



42
43
44
# File 'lib/vapi_server_sdk/types/assignment_mutation.rb', line 42

def variable
  @variable
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::AssignmentMutation

Deserialize a JSON object to an instance of AssignmentMutation

Parameters:

  • json_object (String)

Returns:



150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# File 'lib/vapi_server_sdk/types/assignment_mutation.rb', line 150

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  conditions = parsed_json["conditions"]&.map do |item|
    item = item.to_json
    Vapi::AssignmentMutationConditionsItem.from_json(json_object: item)
  end
  type = parsed_json["type"]
  variable = parsed_json["variable"]
  value = parsed_json["value"]
  new(
    conditions: conditions,
    type: type,
    variable: variable,
    value: value,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Leveraged for Union-type generation, validate_raw attempts to parse the given

hash and check each fields type against the current object's property
definitions.

Parameters:

  • obj (Object)

Returns:

  • (Void)


182
183
184
185
186
187
# File 'lib/vapi_server_sdk/types/assignment_mutation.rb', line 182

def self.validate_raw(obj:)
  obj.conditions&.is_a?(Array) != false || raise("Passed value for field obj.conditions is not the expected type, validation failed.")
  obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.")
  obj.variable.is_a?(String) != false || raise("Passed value for field obj.variable is not the expected type, validation failed.")
  obj.value.is_a?(String) != false || raise("Passed value for field obj.value is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of AssignmentMutation to a JSON object

Returns:

  • (String)


172
173
174
# File 'lib/vapi_server_sdk/types/assignment_mutation.rb', line 172

def to_json(*_args)
  @_field_set&.to_json
end