Class: Vapi::ServerMessageConversationUpdate
- Inherits:
-
Object
- Object
- Vapi::ServerMessageConversationUpdate
- Defined in:
- lib/vapi_server_sdk/types/server_message_conversation_update.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#artifact ⇒ Vapi::Artifact
readonly
This is a live version of the ‘call.artifact`.
-
#assistant ⇒ Vapi::CreateAssistantDto
readonly
This is the assistant that is currently active.
-
#call ⇒ Vapi::Call
readonly
This is the call object.
-
#customer ⇒ Vapi::CreateCustomerDto
readonly
This is the customer associated with the call.
-
#messages ⇒ Array<Vapi::ServerMessageConversationUpdateMessagesItem>
readonly
This is the most up-to-date conversation history at the time the message is sent.
-
#messages_open_ai_formatted ⇒ Array<Vapi::OpenAiMessage>
readonly
This is the most up-to-date conversation history at the time the message is sent, formatted for OpenAI.
-
#phone_number ⇒ Vapi::ServerMessageConversationUpdatePhoneNumber
readonly
This is the phone number associated with the call.
-
#timestamp ⇒ String
readonly
This is the ISO-8601 formatted timestamp of when the message was sent.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Vapi::ServerMessageConversationUpdate
Deserialize a JSON object to an instance of ServerMessageConversationUpdate.
-
.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(messages_open_ai_formatted:, phone_number: OMIT, messages: OMIT, timestamp: OMIT, artifact: OMIT, assistant: OMIT, customer: OMIT, call: OMIT, additional_properties: nil) ⇒ Vapi::ServerMessageConversationUpdate constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of ServerMessageConversationUpdate to a JSON object.
Constructor Details
#initialize(messages_open_ai_formatted:, phone_number: OMIT, messages: OMIT, timestamp: OMIT, artifact: OMIT, assistant: OMIT, customer: OMIT, call: OMIT, additional_properties: nil) ⇒ Vapi::ServerMessageConversationUpdate
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/vapi_server_sdk/types/server_message_conversation_update.rb', line 89 def initialize(messages_open_ai_formatted:, phone_number: OMIT, messages: OMIT, timestamp: OMIT, artifact: OMIT, assistant: OMIT, customer: OMIT, call: OMIT, additional_properties: nil) @phone_number = phone_number if phone_number != OMIT @messages = if != OMIT @messages_open_ai_formatted = @timestamp = if != OMIT @artifact = artifact if artifact != OMIT @assistant = assistant if assistant != OMIT @customer = customer if customer != OMIT @call = call if call != OMIT @additional_properties = additional_properties @_field_set = { "phoneNumber": phone_number, "messages": , "messagesOpenAIFormatted": , "timestamp": , "artifact": artifact, "assistant": assistant, "customer": customer, "call": call }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
52 53 54 |
# File 'lib/vapi_server_sdk/types/server_message_conversation_update.rb', line 52 def additional_properties @additional_properties end |
#artifact ⇒ Vapi::Artifact (readonly)
Returns This is a live version of the ‘call.artifact`. This matches what is stored on `call.artifact` after the call.
30 31 32 |
# File 'lib/vapi_server_sdk/types/server_message_conversation_update.rb', line 30 def artifact @artifact end |
#assistant ⇒ Vapi::CreateAssistantDto (readonly)
Returns This is the assistant that is currently active. This is provided for convenience. This matches one of the following:
-
‘call.assistant`,
-
‘call.assistantId`,
-
‘call.squad.assistant`,
-
‘call.squad.assistantId`,
-
‘call.squadId->.assistant`,
-
‘call.squadId->.assistantId`.
40 41 42 |
# File 'lib/vapi_server_sdk/types/server_message_conversation_update.rb', line 40 def assistant @assistant end |
#call ⇒ Vapi::Call (readonly)
Returns This is the call object. This matches what was returned in POST /call. Note: This might get stale during the call. To get the latest call object, especially after the call is ended, use GET /call/:id.
50 51 52 |
# File 'lib/vapi_server_sdk/types/server_message_conversation_update.rb', line 50 def call @call end |
#customer ⇒ Vapi::CreateCustomerDto (readonly)
Returns This is the customer associated with the call. This matches one of the following:
-
‘call.customer`,
-
‘call.customerId`.
45 46 47 |
# File 'lib/vapi_server_sdk/types/server_message_conversation_update.rb', line 45 def customer @customer end |
#messages ⇒ Array<Vapi::ServerMessageConversationUpdateMessagesItem> (readonly)
Returns This is the most up-to-date conversation history at the time the message is sent.
22 23 24 |
# File 'lib/vapi_server_sdk/types/server_message_conversation_update.rb', line 22 def @messages end |
#messages_open_ai_formatted ⇒ Array<Vapi::OpenAiMessage> (readonly)
Returns This is the most up-to-date conversation history at the time the message is sent, formatted for OpenAI.
25 26 27 |
# File 'lib/vapi_server_sdk/types/server_message_conversation_update.rb', line 25 def @messages_open_ai_formatted end |
#phone_number ⇒ Vapi::ServerMessageConversationUpdatePhoneNumber (readonly)
Returns This is the phone number associated with the call. This matches one of the following:
-
‘call.phoneNumber`,
-
‘call.phoneNumberId`.
19 20 21 |
# File 'lib/vapi_server_sdk/types/server_message_conversation_update.rb', line 19 def phone_number @phone_number end |
#timestamp ⇒ String (readonly)
Returns This is the ISO-8601 formatted timestamp of when the message was sent.
27 28 29 |
# File 'lib/vapi_server_sdk/types/server_message_conversation_update.rb', line 27 def @timestamp end |
Class Method Details
.from_json(json_object:) ⇒ Vapi::ServerMessageConversationUpdate
Deserialize a JSON object to an instance of ServerMessageConversationUpdate
118 119 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 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/vapi_server_sdk/types/server_message_conversation_update.rb', line 118 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) if parsed_json["phoneNumber"].nil? phone_number = nil else phone_number = parsed_json["phoneNumber"].to_json phone_number = Vapi::ServerMessageConversationUpdatePhoneNumber.from_json(json_object: phone_number) end = parsed_json["messages"]&.map do |item| item = item.to_json Vapi::ServerMessageConversationUpdateMessagesItem.from_json(json_object: item) end = parsed_json["messagesOpenAIFormatted"]&.map do |item| item = item.to_json Vapi::OpenAiMessage.from_json(json_object: item) end = parsed_json["timestamp"] if parsed_json["artifact"].nil? artifact = nil else artifact = parsed_json["artifact"].to_json artifact = Vapi::Artifact.from_json(json_object: artifact) end if parsed_json["assistant"].nil? assistant = nil else assistant = parsed_json["assistant"].to_json assistant = Vapi::CreateAssistantDto.from_json(json_object: assistant) end if parsed_json["customer"].nil? customer = nil else customer = parsed_json["customer"].to_json customer = Vapi::CreateCustomerDto.from_json(json_object: customer) end if parsed_json["call"].nil? call = nil else call = parsed_json["call"].to_json call = Vapi::Call.from_json(json_object: call) end new( phone_number: phone_number, messages: , messages_open_ai_formatted: , timestamp: , artifact: artifact, assistant: assistant, customer: customer, call: call, 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.
186 187 188 189 190 191 192 193 194 195 |
# File 'lib/vapi_server_sdk/types/server_message_conversation_update.rb', line 186 def self.validate_raw(obj:) obj.phone_number.nil? || Vapi::ServerMessageConversationUpdatePhoneNumber.validate_raw(obj: obj.phone_number) obj.&.is_a?(Array) != false || raise("Passed value for field obj.messages is not the expected type, validation failed.") obj..is_a?(Array) != false || raise("Passed value for field obj.messages_open_ai_formatted is not the expected type, validation failed.") obj.&.is_a?(String) != false || raise("Passed value for field obj.timestamp is not the expected type, validation failed.") obj.artifact.nil? || Vapi::Artifact.validate_raw(obj: obj.artifact) obj.assistant.nil? || Vapi::CreateAssistantDto.validate_raw(obj: obj.assistant) obj.customer.nil? || Vapi::CreateCustomerDto.validate_raw(obj: obj.customer) obj.call.nil? || Vapi::Call.validate_raw(obj: obj.call) end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of ServerMessageConversationUpdate to a JSON object
176 177 178 |
# File 'lib/vapi_server_sdk/types/server_message_conversation_update.rb', line 176 def to_json(*_args) @_field_set&.to_json end |