Class: Vapi::WebChat
- Inherits:
-
Object
- Object
- Vapi::WebChat
- Defined in:
- lib/vapi_server_sdk/types/web_chat.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#id ⇒ String
readonly
This is the unique identifier for the chat.
-
#output ⇒ Array<Vapi::WebChatOutputItem>
readonly
This is the output messages generated by the system in response to the input.
-
#session_id ⇒ String
readonly
This is the ID of the session for the chat.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Vapi::WebChat
Deserialize a JSON object to an instance of WebChat.
-
.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:, output:, session_id: OMIT, additional_properties: nil) ⇒ Vapi::WebChat constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of WebChat to a JSON object.
Constructor Details
#initialize(id:, output:, session_id: OMIT, additional_properties: nil) ⇒ Vapi::WebChat
30 31 32 33 34 35 36 37 38 |
# File 'lib/vapi_server_sdk/types/web_chat.rb', line 30 def initialize(id:, output:, session_id: OMIT, additional_properties: nil) @id = id @session_id = session_id if session_id != OMIT @output = output @additional_properties = additional_properties @_field_set = { "id": id, "sessionId": session_id, "output": output }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
17 18 19 |
# File 'lib/vapi_server_sdk/types/web_chat.rb', line 17 def additional_properties @additional_properties end |
#id ⇒ String (readonly)
Returns This is the unique identifier for the chat.
10 11 12 |
# File 'lib/vapi_server_sdk/types/web_chat.rb', line 10 def id @id end |
#output ⇒ Array<Vapi::WebChatOutputItem> (readonly)
Returns This is the output messages generated by the system in response to the input.
15 16 17 |
# File 'lib/vapi_server_sdk/types/web_chat.rb', line 15 def output @output end |
#session_id ⇒ String (readonly)
Returns This is the ID of the session for the chat. Send it in the next chat request to continue the conversation.
13 14 15 |
# File 'lib/vapi_server_sdk/types/web_chat.rb', line 13 def session_id @session_id end |
Class Method Details
.from_json(json_object:) ⇒ Vapi::WebChat
Deserialize a JSON object to an instance of WebChat
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/vapi_server_sdk/types/web_chat.rb', line 44 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) id = parsed_json["id"] session_id = parsed_json["sessionId"] output = parsed_json["output"]&.map do |item| item = item.to_json Vapi::WebChatOutputItem.from_json(json_object: item) end new( id: id, session_id: session_id, output: output, 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.
74 75 76 77 78 |
# File 'lib/vapi_server_sdk/types/web_chat.rb', line 74 def self.validate_raw(obj:) obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") obj.session_id&.is_a?(String) != false || raise("Passed value for field obj.session_id is not the expected type, validation failed.") obj.output.is_a?(Array) != false || raise("Passed value for field obj.output is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of WebChat to a JSON object
64 65 66 |
# File 'lib/vapi_server_sdk/types/web_chat.rb', line 64 def to_json(*_args) @_field_set&.to_json end |