Class: Vapi::WorkflowBlock
- Inherits:
-
Object
- Object
- Vapi::WorkflowBlock
- Defined in:
- lib/vapi_server_sdk/types/workflow_block.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#created_at ⇒ DateTime
readonly
This is the ISO 8601 date-time string of when the block was created.
-
#id ⇒ String
readonly
This is the unique identifier for the block.
-
#input_schema ⇒ Vapi::JsonSchema
readonly
This is the input schema for the block.
-
#messages ⇒ Array<Vapi::WorkflowBlockMessagesItem>
readonly
These are the pre-configured messages that will be spoken to the user while the block is running.
-
#name ⇒ String
readonly
This is the name of the block.
-
#org_id ⇒ String
readonly
This is the unique identifier for the organization that this block belongs to.
-
#output_schema ⇒ Vapi::JsonSchema
readonly
This is the output schema for the block.
-
#steps ⇒ Array<Vapi::WorkflowBlockStepsItem>
readonly
These are the steps in the workflow.
-
#updated_at ⇒ DateTime
readonly
This is the ISO 8601 date-time string of when the block was last updated.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Vapi::WorkflowBlock
Deserialize a JSON object to an instance of WorkflowBlock.
-
.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.
Instance Method Summary collapse
- #initialize(id:, org_id:, created_at:, updated_at:, messages: OMIT, input_schema: OMIT, output_schema: OMIT, steps: OMIT, name: OMIT, additional_properties: nil) ⇒ Vapi::WorkflowBlock constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of WorkflowBlock to a JSON object.
Constructor Details
#initialize(id:, org_id:, created_at:, updated_at:, messages: OMIT, input_schema: OMIT, output_schema: OMIT, steps: OMIT, name: OMIT, additional_properties: nil) ⇒ Vapi::WorkflowBlock
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/vapi_server_sdk/types/workflow_block.rb', line 89 def initialize(id:, org_id:, created_at:, updated_at:, messages: OMIT, input_schema: OMIT, output_schema: OMIT, steps: OMIT, name: OMIT, additional_properties: nil) @messages = if != OMIT @input_schema = input_schema if input_schema != OMIT @output_schema = output_schema if output_schema != OMIT @steps = steps if steps != OMIT @id = id @org_id = org_id @created_at = created_at @updated_at = updated_at @name = name if name != OMIT @additional_properties = additional_properties @_field_set = { "messages": , "inputSchema": input_schema, "outputSchema": output_schema, "steps": steps, "id": id, "orgId": org_id, "createdAt": created_at, "updatedAt": updated_at, "name": name }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
51 52 53 |
# File 'lib/vapi_server_sdk/types/workflow_block.rb', line 51 def additional_properties @additional_properties end |
#created_at ⇒ DateTime (readonly)
Returns This is the ISO 8601 date-time string of when the block was created.
45 46 47 |
# File 'lib/vapi_server_sdk/types/workflow_block.rb', line 45 def created_at @created_at end |
#id ⇒ String (readonly)
Returns This is the unique identifier for the block.
41 42 43 |
# File 'lib/vapi_server_sdk/types/workflow_block.rb', line 41 def id @id end |
#input_schema ⇒ Vapi::JsonSchema (readonly)
Returns This is the input schema for the block. This is the input the block needs to run. It’s given to the block as ‘steps.input` These are accessible as variables:
-
(Vapi::WorkflowBlock.{input{input.propertyName}) in context of the block execution (step)
-
(Vapi::WorkflowBlock.{stepName{stepName.input{stepName.input.propertyName}) in context of the workflow.
20 21 22 |
# File 'lib/vapi_server_sdk/types/workflow_block.rb', line 20 def input_schema @input_schema end |
#messages ⇒ Array<Vapi::WorkflowBlockMessagesItem> (readonly)
Returns These are the pre-configured messages that will be spoken to the user while the block is running.
14 15 16 |
# File 'lib/vapi_server_sdk/types/workflow_block.rb', line 14 def @messages end |
#name ⇒ String (readonly)
Returns This is the name of the block. This is just for your reference.
49 50 51 |
# File 'lib/vapi_server_sdk/types/workflow_block.rb', line 49 def name @name end |
#org_id ⇒ String (readonly)
Returns This is the unique identifier for the organization that this block belongs to.
43 44 45 |
# File 'lib/vapi_server_sdk/types/workflow_block.rb', line 43 def org_id @org_id end |
#output_schema ⇒ Vapi::JsonSchema (readonly)
This is the output schema for the block. This is the output the block will return to the workflow (‘Vapi::WorkflowBlock.{stepName{stepName.output}`). These are accessible as variables:
-
(Vapi::WorkflowBlock.{output{output.propertyName}) in context of the block execution (step)
-
(Vapi::WorkflowBlock.{stepName{stepName.output{stepName.output.propertyName}) in context of the workflow (read caveat #1)
-
(Vapi::WorkflowBlock.{blockName{blockName.output{blockName.output.propertyName}) in context of the workflow (read caveat
#2) Caveats:
-
a workflow can execute a step multiple times. example, if a loop is used in
the graph. Vapi::WorkflowBlock.{stepName{stepName.output{stepName.output.propertyName} will reference the latest usage of the step.
-
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::WorkflowBlock.{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 with steps.
37 38 39 |
# File 'lib/vapi_server_sdk/types/workflow_block.rb', line 37 def output_schema @output_schema end |
#steps ⇒ Array<Vapi::WorkflowBlockStepsItem> (readonly)
Returns These are the steps in the workflow.
39 40 41 |
# File 'lib/vapi_server_sdk/types/workflow_block.rb', line 39 def steps @steps end |
#updated_at ⇒ DateTime (readonly)
Returns This is the ISO 8601 date-time string of when the block was last updated.
47 48 49 |
# File 'lib/vapi_server_sdk/types/workflow_block.rb', line 47 def updated_at @updated_at end |
Class Method Details
.from_json(json_object:) ⇒ Vapi::WorkflowBlock
Deserialize a JSON object to an instance of WorkflowBlock
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/vapi_server_sdk/types/workflow_block.rb', line 120 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) = parsed_json["messages"]&.map do |item| item = item.to_json Vapi::WorkflowBlockMessagesItem.from_json(json_object: item) end if parsed_json["inputSchema"].nil? input_schema = nil else input_schema = parsed_json["inputSchema"].to_json input_schema = Vapi::JsonSchema.from_json(json_object: input_schema) end if parsed_json["outputSchema"].nil? output_schema = nil else output_schema = parsed_json["outputSchema"].to_json output_schema = Vapi::JsonSchema.from_json(json_object: output_schema) end steps = parsed_json["steps"]&.map do |item| item = item.to_json Vapi::WorkflowBlockStepsItem.from_json(json_object: item) end id = parsed_json["id"] org_id = parsed_json["orgId"] created_at = (DateTime.parse(parsed_json["createdAt"]) unless parsed_json["createdAt"].nil?) updated_at = (DateTime.parse(parsed_json["updatedAt"]) unless parsed_json["updatedAt"].nil?) name = parsed_json["name"] new( messages: , input_schema: input_schema, output_schema: output_schema, steps: steps, id: id, org_id: org_id, created_at: created_at, updated_at: updated_at, name: name, 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.
175 176 177 178 179 180 181 182 183 184 185 |
# File 'lib/vapi_server_sdk/types/workflow_block.rb', line 175 def self.validate_raw(obj:) obj.&.is_a?(Array) != false || raise("Passed value for field obj.messages is not the expected type, validation failed.") obj.input_schema.nil? || Vapi::JsonSchema.validate_raw(obj: obj.input_schema) obj.output_schema.nil? || Vapi::JsonSchema.validate_raw(obj: obj.output_schema) obj.steps&.is_a?(Array) != false || raise("Passed value for field obj.steps is not the expected type, validation failed.") obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") obj.org_id.is_a?(String) != false || raise("Passed value for field obj.org_id is not the expected type, validation failed.") obj.created_at.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") obj.updated_at.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.") obj.name&.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of WorkflowBlock to a JSON object
165 166 167 |
# File 'lib/vapi_server_sdk/types/workflow_block.rb', line 165 def to_json(*_args) @_field_set&.to_json end |