Class: Vapi::BotMessage
- Inherits:
-
Object
- Object
- Vapi::BotMessage
- Defined in:
- lib/vapi_server_sdk/types/bot_message.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#duration ⇒ Float
readonly
The duration of the message in seconds.
-
#end_time ⇒ Float
readonly
The timestamp when the message ended.
-
#message ⇒ String
readonly
The message content from the bot.
-
#role ⇒ String
readonly
The role of the bot in the conversation.
-
#seconds_from_start ⇒ Float
readonly
The number of seconds from the start of the conversation.
-
#source ⇒ String
readonly
The source of the message.
-
#time ⇒ Float
readonly
The timestamp when the message was sent.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Vapi::BotMessage
Deserialize a JSON object to an instance of BotMessage.
-
.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(role:, message:, time:, end_time:, seconds_from_start:, source: OMIT, duration: OMIT, additional_properties: nil) ⇒ Vapi::BotMessage constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of BotMessage to a JSON object.
Constructor Details
#initialize(role:, message:, time:, end_time:, seconds_from_start:, source: OMIT, duration: OMIT, additional_properties: nil) ⇒ Vapi::BotMessage
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/vapi_server_sdk/types/bot_message.rb', line 39 def initialize(role:, message:, time:, end_time:, seconds_from_start:, source: OMIT, duration: OMIT, additional_properties: nil) @role = role @message = @time = time @end_time = end_time @seconds_from_start = seconds_from_start @source = source if source != OMIT @duration = duration if duration != OMIT @additional_properties = additional_properties @_field_set = { "role": role, "message": , "time": time, "endTime": end_time, "secondsFromStart": seconds_from_start, "source": source, "duration": duration }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
23 24 25 |
# File 'lib/vapi_server_sdk/types/bot_message.rb', line 23 def additional_properties @additional_properties end |
#duration ⇒ Float (readonly)
Returns The duration of the message in seconds.
21 22 23 |
# File 'lib/vapi_server_sdk/types/bot_message.rb', line 21 def duration @duration end |
#end_time ⇒ Float (readonly)
Returns The timestamp when the message ended.
15 16 17 |
# File 'lib/vapi_server_sdk/types/bot_message.rb', line 15 def end_time @end_time end |
#message ⇒ String (readonly)
Returns The message content from the bot.
11 12 13 |
# File 'lib/vapi_server_sdk/types/bot_message.rb', line 11 def @message end |
#role ⇒ String (readonly)
Returns The role of the bot in the conversation.
9 10 11 |
# File 'lib/vapi_server_sdk/types/bot_message.rb', line 9 def role @role end |
#seconds_from_start ⇒ Float (readonly)
Returns The number of seconds from the start of the conversation.
17 18 19 |
# File 'lib/vapi_server_sdk/types/bot_message.rb', line 17 def seconds_from_start @seconds_from_start end |
#source ⇒ String (readonly)
Returns The source of the message.
19 20 21 |
# File 'lib/vapi_server_sdk/types/bot_message.rb', line 19 def source @source end |
#time ⇒ Float (readonly)
Returns The timestamp when the message was sent.
13 14 15 |
# File 'lib/vapi_server_sdk/types/bot_message.rb', line 13 def time @time end |
Class Method Details
.from_json(json_object:) ⇒ Vapi::BotMessage
Deserialize a JSON object to an instance of BotMessage
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/vapi_server_sdk/types/bot_message.rb', line 66 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) role = parsed_json["role"] = parsed_json["message"] time = parsed_json["time"] end_time = parsed_json["endTime"] seconds_from_start = parsed_json["secondsFromStart"] source = parsed_json["source"] duration = parsed_json["duration"] new( role: role, message: , time: time, end_time: end_time, seconds_from_start: seconds_from_start, source: source, duration: duration, 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.
101 102 103 104 105 106 107 108 109 |
# File 'lib/vapi_server_sdk/types/bot_message.rb', line 101 def self.validate_raw(obj:) obj.role.is_a?(String) != false || raise("Passed value for field obj.role is not the expected type, validation failed.") obj..is_a?(String) != false || raise("Passed value for field obj.message is not the expected type, validation failed.") obj.time.is_a?(Float) != false || raise("Passed value for field obj.time is not the expected type, validation failed.") obj.end_time.is_a?(Float) != false || raise("Passed value for field obj.end_time is not the expected type, validation failed.") obj.seconds_from_start.is_a?(Float) != false || raise("Passed value for field obj.seconds_from_start is not the expected type, validation failed.") obj.source&.is_a?(String) != false || raise("Passed value for field obj.source is not the expected type, validation failed.") obj.duration&.is_a?(Float) != false || raise("Passed value for field obj.duration is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of BotMessage to a JSON object
91 92 93 |
# File 'lib/vapi_server_sdk/types/bot_message.rb', line 91 def to_json(*_args) @_field_set&.to_json end |