Class: Vapi::CreateWebChatDto
- Inherits:
-
Object
- Object
- Vapi::CreateWebChatDto
- Defined in:
- lib/vapi_server_sdk/types/create_web_chat_dto.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#assistant_id ⇒ String
readonly
The assistant ID to use for this chat.
-
#assistant_overrides ⇒ Vapi::ChatAssistantOverrides
readonly
These are the variable values that will be used to replace template variables in the assistant messages.
-
#customer ⇒ Vapi::CreateWebCustomerDto
readonly
This is the customer information for the chat.
-
#input ⇒ Vapi::CreateWebChatDtoInput
readonly
This is the input text for the chat.
-
#session_id ⇒ String
readonly
This is the ID of the session that will be used for the chat.
-
#stream ⇒ Boolean
readonly
This is a flag that determines whether the response should be streamed.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Vapi::CreateWebChatDto
Deserialize a JSON object to an instance of CreateWebChatDto.
-
.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(assistant_id:, input:, session_id: OMIT, assistant_overrides: OMIT, customer: OMIT, stream: OMIT, additional_properties: nil) ⇒ Vapi::CreateWebChatDto constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of CreateWebChatDto to a JSON object.
Constructor Details
#initialize(assistant_id:, input:, session_id: OMIT, assistant_overrides: OMIT, customer: OMIT, stream: OMIT, additional_properties: nil) ⇒ Vapi::CreateWebChatDto
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/vapi_server_sdk/types/create_web_chat_dto.rb', line 55 def initialize(assistant_id:, input:, session_id: OMIT, assistant_overrides: OMIT, customer: OMIT, stream: OMIT, additional_properties: nil) @assistant_id = assistant_id @session_id = session_id if session_id != OMIT @assistant_overrides = assistant_overrides if assistant_overrides != OMIT @customer = customer if customer != OMIT @input = input @stream = stream if stream != OMIT @additional_properties = additional_properties @_field_set = { "assistantId": assistant_id, "sessionId": session_id, "assistantOverrides": assistant_overrides, "customer": customer, "input": input, "stream": stream }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
32 33 34 |
# File 'lib/vapi_server_sdk/types/create_web_chat_dto.rb', line 32 def additional_properties @additional_properties end |
#assistant_id ⇒ String (readonly)
Returns The assistant ID to use for this chat.
12 13 14 |
# File 'lib/vapi_server_sdk/types/create_web_chat_dto.rb', line 12 def assistant_id @assistant_id end |
#assistant_overrides ⇒ Vapi::ChatAssistantOverrides (readonly)
Returns These are the variable values that will be used to replace template variables in the assistant messages. Only variable substitution is supported in web chat - other assistant properties cannot be overridden.
21 22 23 |
# File 'lib/vapi_server_sdk/types/create_web_chat_dto.rb', line 21 def assistant_overrides @assistant_overrides end |
#customer ⇒ Vapi::CreateWebCustomerDto (readonly)
Returns This is the customer information for the chat. Used to automatically manage sessions for repeat customers.
24 25 26 |
# File 'lib/vapi_server_sdk/types/create_web_chat_dto.rb', line 24 def customer @customer end |
#input ⇒ Vapi::CreateWebChatDtoInput (readonly)
Returns This is the input text for the chat. Can be a string or an array of chat messages.
27 28 29 |
# File 'lib/vapi_server_sdk/types/create_web_chat_dto.rb', line 27 def input @input end |
#session_id ⇒ String (readonly)
Returns This is the ID of the session that will be used for the chat. If provided, the conversation will continue from the previous state. If not provided or expired, a new session will be created.
16 17 18 |
# File 'lib/vapi_server_sdk/types/create_web_chat_dto.rb', line 16 def session_id @session_id end |
#stream ⇒ Boolean (readonly)
Returns This is a flag that determines whether the response should be streamed. When true, the response will be sent as chunks of text.
30 31 32 |
# File 'lib/vapi_server_sdk/types/create_web_chat_dto.rb', line 30 def stream @stream end |
Class Method Details
.from_json(json_object:) ⇒ Vapi::CreateWebChatDto
Deserialize a JSON object to an instance of CreateWebChatDto
80 81 82 83 84 85 86 87 88 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 |
# File 'lib/vapi_server_sdk/types/create_web_chat_dto.rb', line 80 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) assistant_id = parsed_json["assistantId"] session_id = parsed_json["sessionId"] if parsed_json["assistantOverrides"].nil? assistant_overrides = nil else assistant_overrides = parsed_json["assistantOverrides"].to_json assistant_overrides = Vapi::ChatAssistantOverrides.from_json(json_object: assistant_overrides) end if parsed_json["customer"].nil? customer = nil else customer = parsed_json["customer"].to_json customer = Vapi::CreateWebCustomerDto.from_json(json_object: customer) end if parsed_json["input"].nil? input = nil else input = parsed_json["input"].to_json input = Vapi::CreateWebChatDtoInput.from_json(json_object: input) end stream = parsed_json["stream"] new( assistant_id: assistant_id, session_id: session_id, assistant_overrides: assistant_overrides, customer: customer, input: input, stream: stream, 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.
128 129 130 131 132 133 134 135 |
# File 'lib/vapi_server_sdk/types/create_web_chat_dto.rb', line 128 def self.validate_raw(obj:) obj.assistant_id.is_a?(String) != false || raise("Passed value for field obj.assistant_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.assistant_overrides.nil? || Vapi::ChatAssistantOverrides.validate_raw(obj: obj.assistant_overrides) obj.customer.nil? || Vapi::CreateWebCustomerDto.validate_raw(obj: obj.customer) Vapi::CreateWebChatDtoInput.validate_raw(obj: obj.input) obj.stream&.is_a?(Boolean) != false || raise("Passed value for field obj.stream is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of CreateWebChatDto to a JSON object
118 119 120 |
# File 'lib/vapi_server_sdk/types/create_web_chat_dto.rb', line 118 def to_json(*_args) @_field_set&.to_json end |