Class: Vapi::ServerMessageMessage
- Inherits:
-
Object
- Object
- Vapi::ServerMessageMessage
- Defined in:
- lib/vapi_server_sdk/types/server_message_message.rb
Overview
These are all the messages that can be sent to your server before, after and
during the call. Configure the messages you'd like to receive in
`assistant.serverMessages`.
The server where the message is sent is determined by the following precedence
order:
1. `tool.server.url` (if configured, and only for "tool-calls" message)
2. `assistant.serverUrl` (if configure)
3. `phoneNumber.serverUrl` (if configured)
4. `org.serverUrl` (if configured)
Instance Attribute Summary collapse
- #discriminant ⇒ String readonly
- #member ⇒ Object readonly
Class Method Summary collapse
- .assistant_request(member:) ⇒ Vapi::ServerMessageMessage
- .conversation_update(member:) ⇒ Vapi::ServerMessageMessage
- .end_of_call_report(member:) ⇒ Vapi::ServerMessageMessage
-
.from_json(json_object:) ⇒ Vapi::ServerMessageMessage
Deserialize a JSON object to an instance of ServerMessageMessage.
- .hang(member:) ⇒ Vapi::ServerMessageMessage
- .language_changed(member:) ⇒ Vapi::ServerMessageMessage
- .model_output(member:) ⇒ Vapi::ServerMessageMessage
- .phone_call_control(member:) ⇒ Vapi::ServerMessageMessage
- .speech_update(member:) ⇒ Vapi::ServerMessageMessage
- .status_update(member:) ⇒ Vapi::ServerMessageMessage
- .tool_calls(member:) ⇒ Vapi::ServerMessageMessage
- .transcript(member:) ⇒ Vapi::ServerMessageMessage
- .transfer_destination_request(member:) ⇒ Vapi::ServerMessageMessage
- .transfer_update(member:) ⇒ Vapi::ServerMessageMessage
- .user_interrupted(member:) ⇒ Vapi::ServerMessageMessage
-
.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.
- .voice_input(member:) ⇒ Vapi::ServerMessageMessage
- .voice_request(member:) ⇒ Vapi::ServerMessageMessage
Instance Method Summary collapse
- #initialize(member:, discriminant:) ⇒ Vapi::ServerMessageMessage constructor
-
#is_a?(obj) ⇒ Boolean
For Union Types, is_a? functionality is delegated to the wrapped member.
- #kind_of? ⇒ Object
-
#to_json(*_args) ⇒ String
For Union Types, to_json functionality is delegated to the wrapped member.
Constructor Details
#initialize(member:, discriminant:) ⇒ Vapi::ServerMessageMessage
43 44 45 46 |
# File 'lib/vapi_server_sdk/types/server_message_message.rb', line 43 def initialize(member:, discriminant:) @member = member @discriminant = discriminant end |
Instance Attribute Details
#discriminant ⇒ String (readonly)
35 36 37 |
# File 'lib/vapi_server_sdk/types/server_message_message.rb', line 35 def discriminant @discriminant end |
#member ⇒ Object (readonly)
33 34 35 |
# File 'lib/vapi_server_sdk/types/server_message_message.rb', line 33 def member @member end |
Class Method Details
.assistant_request(member:) ⇒ Vapi::ServerMessageMessage
191 192 193 |
# File 'lib/vapi_server_sdk/types/server_message_message.rb', line 191 def self.assistant_request(member:) new(member: member, discriminant: "assistant-request") end |
.conversation_update(member:) ⇒ Vapi::ServerMessageMessage
197 198 199 |
# File 'lib/vapi_server_sdk/types/server_message_message.rb', line 197 def self.conversation_update(member:) new(member: member, discriminant: "conversation-update") end |
.end_of_call_report(member:) ⇒ Vapi::ServerMessageMessage
203 204 205 |
# File 'lib/vapi_server_sdk/types/server_message_message.rb', line 203 def self.end_of_call_report(member:) new(member: member, discriminant: "end-of-call-report") end |
.from_json(json_object:) ⇒ Vapi::ServerMessageMessage
Deserialize a JSON object to an instance of ServerMessageMessage
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/vapi_server_sdk/types/server_message_message.rb', line 52 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) member = case struct.type when "assistant-request" Vapi::ServerMessageAssistantRequest.from_json(json_object: json_object) when "conversation-update" Vapi::ServerMessageConversationUpdate.from_json(json_object: json_object) when "end-of-call-report" Vapi::ServerMessageEndOfCallReport.from_json(json_object: json_object) when "hang" Vapi::ServerMessageHang.from_json(json_object: json_object) when "model-output" Vapi::ServerMessageModelOutput.from_json(json_object: json_object) when "phone-call-control" Vapi::ServerMessagePhoneCallControl.from_json(json_object: json_object) when "speech-update" Vapi::ServerMessageSpeechUpdate.from_json(json_object: json_object) when "status-update" Vapi::ServerMessageStatusUpdate.from_json(json_object: json_object) when "tool-calls" Vapi::ServerMessageToolCalls.from_json(json_object: json_object) when "transfer-destination-request" Vapi::ServerMessageTransferDestinationRequest.from_json(json_object: json_object) when "transfer-update" Vapi::ServerMessageTransferUpdate.from_json(json_object: json_object) when "transcript" Vapi::ServerMessageTranscript.from_json(json_object: json_object) when "user-interrupted" Vapi::ServerMessageUserInterrupted.from_json(json_object: json_object) when "language-changed" Vapi::ServerMessageLanguageChanged.from_json(json_object: json_object) when "voice-input" Vapi::ServerMessageVoiceInput.from_json(json_object: json_object) when "voice-request" Vapi::ServerMessageVoiceRequest.from_json(json_object: json_object) else Vapi::ServerMessageAssistantRequest.from_json(json_object: json_object) end new(member: member, discriminant: struct.type) end |
.hang(member:) ⇒ Vapi::ServerMessageMessage
209 210 211 |
# File 'lib/vapi_server_sdk/types/server_message_message.rb', line 209 def self.hang(member:) new(member: member, discriminant: "hang") end |
.language_changed(member:) ⇒ Vapi::ServerMessageMessage
269 270 271 |
# File 'lib/vapi_server_sdk/types/server_message_message.rb', line 269 def self.language_changed(member:) new(member: member, discriminant: "language-changed") end |
.model_output(member:) ⇒ Vapi::ServerMessageMessage
215 216 217 |
# File 'lib/vapi_server_sdk/types/server_message_message.rb', line 215 def self.model_output(member:) new(member: member, discriminant: "model-output") end |
.phone_call_control(member:) ⇒ Vapi::ServerMessageMessage
221 222 223 |
# File 'lib/vapi_server_sdk/types/server_message_message.rb', line 221 def self.phone_call_control(member:) new(member: member, discriminant: "phone-call-control") end |
.speech_update(member:) ⇒ Vapi::ServerMessageMessage
227 228 229 |
# File 'lib/vapi_server_sdk/types/server_message_message.rb', line 227 def self.speech_update(member:) new(member: member, discriminant: "speech-update") end |
.status_update(member:) ⇒ Vapi::ServerMessageMessage
233 234 235 |
# File 'lib/vapi_server_sdk/types/server_message_message.rb', line 233 def self.status_update(member:) new(member: member, discriminant: "status-update") end |
.tool_calls(member:) ⇒ Vapi::ServerMessageMessage
239 240 241 |
# File 'lib/vapi_server_sdk/types/server_message_message.rb', line 239 def self.tool_calls(member:) new(member: member, discriminant: "tool-calls") end |
.transcript(member:) ⇒ Vapi::ServerMessageMessage
257 258 259 |
# File 'lib/vapi_server_sdk/types/server_message_message.rb', line 257 def self.transcript(member:) new(member: member, discriminant: "transcript") end |
.transfer_destination_request(member:) ⇒ Vapi::ServerMessageMessage
245 246 247 |
# File 'lib/vapi_server_sdk/types/server_message_message.rb', line 245 def self.transfer_destination_request(member:) new(member: member, discriminant: "transfer-destination-request") end |
.transfer_update(member:) ⇒ Vapi::ServerMessageMessage
251 252 253 |
# File 'lib/vapi_server_sdk/types/server_message_message.rb', line 251 def self.transfer_update(member:) new(member: member, discriminant: "transfer-update") end |
.user_interrupted(member:) ⇒ Vapi::ServerMessageMessage
263 264 265 |
# File 'lib/vapi_server_sdk/types/server_message_message.rb', line 263 def self.user_interrupted(member:) new(member: member, discriminant: "user-interrupted") 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.
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 172 173 174 175 176 177 178 179 |
# File 'lib/vapi_server_sdk/types/server_message_message.rb', line 142 def self.validate_raw(obj:) case obj.type when "assistant-request" Vapi::ServerMessageAssistantRequest.validate_raw(obj: obj) when "conversation-update" Vapi::ServerMessageConversationUpdate.validate_raw(obj: obj) when "end-of-call-report" Vapi::ServerMessageEndOfCallReport.validate_raw(obj: obj) when "hang" Vapi::ServerMessageHang.validate_raw(obj: obj) when "model-output" Vapi::ServerMessageModelOutput.validate_raw(obj: obj) when "phone-call-control" Vapi::ServerMessagePhoneCallControl.validate_raw(obj: obj) when "speech-update" Vapi::ServerMessageSpeechUpdate.validate_raw(obj: obj) when "status-update" Vapi::ServerMessageStatusUpdate.validate_raw(obj: obj) when "tool-calls" Vapi::ServerMessageToolCalls.validate_raw(obj: obj) when "transfer-destination-request" Vapi::ServerMessageTransferDestinationRequest.validate_raw(obj: obj) when "transfer-update" Vapi::ServerMessageTransferUpdate.validate_raw(obj: obj) when "transcript" Vapi::ServerMessageTranscript.validate_raw(obj: obj) when "user-interrupted" Vapi::ServerMessageUserInterrupted.validate_raw(obj: obj) when "language-changed" Vapi::ServerMessageLanguageChanged.validate_raw(obj: obj) when "voice-input" Vapi::ServerMessageVoiceInput.validate_raw(obj: obj) when "voice-request" Vapi::ServerMessageVoiceRequest.validate_raw(obj: obj) else raise("Passed value matched no type within the union, validation failed.") end end |
.voice_input(member:) ⇒ Vapi::ServerMessageMessage
275 276 277 |
# File 'lib/vapi_server_sdk/types/server_message_message.rb', line 275 def self.voice_input(member:) new(member: member, discriminant: "voice-input") end |
.voice_request(member:) ⇒ Vapi::ServerMessageMessage
281 282 283 |
# File 'lib/vapi_server_sdk/types/server_message_message.rb', line 281 def self.voice_request(member:) new(member: member, discriminant: "voice-request") end |
Instance Method Details
#is_a?(obj) ⇒ Boolean
For Union Types, is_a? functionality is delegated to the wrapped member.
185 186 187 |
# File 'lib/vapi_server_sdk/types/server_message_message.rb', line 185 def is_a?(obj) @member.is_a?(obj) end |
#kind_of? ⇒ Object
38 |
# File 'lib/vapi_server_sdk/types/server_message_message.rb', line 38 alias kind_of? is_a? |
#to_json(*_args) ⇒ String
For Union Types, to_json functionality is delegated to the wrapped member.
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/vapi_server_sdk/types/server_message_message.rb', line 96 def to_json(*_args) case @discriminant when "assistant-request" { **@member.to_json, type: @discriminant }.to_json when "conversation-update" { **@member.to_json, type: @discriminant }.to_json when "end-of-call-report" { **@member.to_json, type: @discriminant }.to_json when "hang" { **@member.to_json, type: @discriminant }.to_json when "model-output" { **@member.to_json, type: @discriminant }.to_json when "phone-call-control" { **@member.to_json, type: @discriminant }.to_json when "speech-update" { **@member.to_json, type: @discriminant }.to_json when "status-update" { **@member.to_json, type: @discriminant }.to_json when "tool-calls" { **@member.to_json, type: @discriminant }.to_json when "transfer-destination-request" { **@member.to_json, type: @discriminant }.to_json when "transfer-update" { **@member.to_json, type: @discriminant }.to_json when "transcript" { **@member.to_json, type: @discriminant }.to_json when "user-interrupted" { **@member.to_json, type: @discriminant }.to_json when "language-changed" { **@member.to_json, type: @discriminant }.to_json when "voice-input" { **@member.to_json, type: @discriminant }.to_json when "voice-request" { **@member.to_json, type: @discriminant }.to_json else { "type": @discriminant, value: @member }.to_json end @member.to_json end |