Class: Vapi::BlockStartMessage
- Inherits:
-
Object
- Object
- Vapi::BlockStartMessage
- Defined in:
- lib/vapi_server_sdk/types/block_start_message.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#conditions ⇒ Array<Vapi::BlockStartMessageConditionsItem>
readonly
This is an optional array of conditions that must be met for this message to be triggered.
-
#content ⇒ String
readonly
This is the content that the assistant will say when this message is triggered.
-
#contents ⇒ Array<Vapi::TextContent>
readonly
This is an alternative to the
contentproperty.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Vapi::BlockStartMessage
Deserialize a JSON object to an instance of BlockStartMessage.
-
.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(contents: OMIT, conditions: OMIT, content: OMIT, additional_properties: nil) ⇒ Vapi::BlockStartMessage constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of BlockStartMessage to a JSON object.
Constructor Details
#initialize(contents: OMIT, conditions: OMIT, content: OMIT, additional_properties: nil) ⇒ Vapi::BlockStartMessage
45 46 47 48 49 50 51 52 53 |
# File 'lib/vapi_server_sdk/types/block_start_message.rb', line 45 def initialize(contents: OMIT, conditions: OMIT, content: OMIT, additional_properties: nil) @contents = contents if contents != OMIT @conditions = conditions if conditions != OMIT @content = content if content != OMIT @additional_properties = additional_properties @_field_set = { "contents": contents, "conditions": conditions, "content": content }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
25 26 27 |
# File 'lib/vapi_server_sdk/types/block_start_message.rb', line 25 def additional_properties @additional_properties end |
#conditions ⇒ Array<Vapi::BlockStartMessageConditionsItem> (readonly)
Returns This is an optional array of conditions that must be met for this message to be triggered.
21 22 23 |
# File 'lib/vapi_server_sdk/types/block_start_message.rb', line 21 def conditions @conditions end |
#content ⇒ String (readonly)
Returns This is the content that the assistant will say when this message is triggered.
23 24 25 |
# File 'lib/vapi_server_sdk/types/block_start_message.rb', line 23 def content @content end |
#contents ⇒ Array<Vapi::TextContent> (readonly)
Returns This is an alternative to the content property. It allows to specify variants of the same content, one per language. Usage:
-
If your assistants are multilingual, you can provide content for each
language.
-
If you don’t provide content for a language, the first item in the array will
be automatically translated to the active language at that moment. This will override the content property.
18 19 20 |
# File 'lib/vapi_server_sdk/types/block_start_message.rb', line 18 def contents @contents end |
Class Method Details
.from_json(json_object:) ⇒ Vapi::BlockStartMessage
Deserialize a JSON object to an instance of BlockStartMessage
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/vapi_server_sdk/types/block_start_message.rb', line 59 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) contents = parsed_json["contents"]&.map do |item| item = item.to_json Vapi::TextContent.from_json(json_object: item) end conditions = parsed_json["conditions"]&.map do |item| item = item.to_json Vapi::BlockStartMessageConditionsItem.from_json(json_object: item) end content = parsed_json["content"] new( contents: contents, conditions: conditions, content: content, 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.
92 93 94 95 96 |
# File 'lib/vapi_server_sdk/types/block_start_message.rb', line 92 def self.validate_raw(obj:) obj.contents&.is_a?(Array) != false || raise("Passed value for field obj.contents is not the expected type, validation failed.") obj.conditions&.is_a?(Array) != false || raise("Passed value for field obj.conditions is not the expected type, validation failed.") obj.content&.is_a?(String) != false || raise("Passed value for field obj.content is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of BlockStartMessage to a JSON object
82 83 84 |
# File 'lib/vapi_server_sdk/types/block_start_message.rb', line 82 def to_json(*_args) @_field_set&.to_json end |