Class: Vapi::ServerMessageResponseVoiceRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/vapi_server_sdk/types/server_message_response_voice_request.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data:, additional_properties: nil) ⇒ Vapi::ServerMessageResponseVoiceRequest

Parameters:

  • data (String)

    DO NOT respond to a ‘voice-request` webhook with this schema of { data }. This schema just exists to document what the response should look like. Follow these instructions: Here is what the request will look like: POST https://Vapi::ServerMessageResponseVoiceRequest.assistantassistant.voiceassistant.voice.serverassistant.voice.server.url Content-Type: application/json { “messsage”: { “type”: “voice-request”, “text”: “Hello, world!”, “sampleRate”: 24000, …other metadata about the call… } } The expected response is 1-channel 16-bit raw PCM audio at the sample rate specified in the request. Here is how the response will be piped to the transport: “` response.on(’data’, (chunk: Buffer) => { outputStream.write(chunk); }); “‘

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition


63
64
65
66
67
# File 'lib/vapi_server_sdk/types/server_message_response_voice_request.rb', line 63

def initialize(data:, additional_properties: nil)
  @data = data
  @additional_properties = additional_properties
  @_field_set = { "data": data }
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition


32
33
34
# File 'lib/vapi_server_sdk/types/server_message_response_voice_request.rb', line 32

def additional_properties
  @additional_properties
end

#dataString (readonly)

Returns DO NOT respond to a ‘voice-request` webhook with this schema of { data }. This schema just exists to document what the response should look like. Follow these instructions: Here is what the request will look like: POST https://Vapi::ServerMessageResponseVoiceRequest.assistantassistant.voiceassistant.voice.serverassistant.voice.server.url Content-Type: application/json { “messsage”: { “type”: “voice-request”, “text”: “Hello, world!”, “sampleRate”: 24000, …other metadata about the call… } } The expected response is 1-channel 16-bit raw PCM audio at the sample rate specified in the request. Here is how the response will be piped to the transport: “` response.on(’data’, (chunk: Buffer) => { outputStream.write(chunk); }); “‘.

Returns:

  • (String)

    DO NOT respond to a ‘voice-request` webhook with this schema of { data }. This schema just exists to document what the response should look like. Follow these instructions: Here is what the request will look like: POST https://Vapi::ServerMessageResponseVoiceRequest.assistantassistant.voiceassistant.voice.serverassistant.voice.server.url Content-Type: application/json { “messsage”: { “type”: “voice-request”, “text”: “Hello, world!”, “sampleRate”: 24000, …other metadata about the call… } } The expected response is 1-channel 16-bit raw PCM audio at the sample rate specified in the request. Here is how the response will be piped to the transport: “` response.on(’data’, (chunk: Buffer) => { outputStream.write(chunk); }); “‘


30
31
32
# File 'lib/vapi_server_sdk/types/server_message_response_voice_request.rb', line 30

def data
  @data
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::ServerMessageResponseVoiceRequest

Deserialize a JSON object to an instance of ServerMessageResponseVoiceRequest

Parameters:

  • json_object (String)

Returns:


73
74
75
76
77
78
# File 'lib/vapi_server_sdk/types/server_message_response_voice_request.rb', line 73

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  data = parsed_json["data"]
  new(data: data, 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.

Parameters:

  • obj (Object)

Returns:

  • (Void)

93
94
95
# File 'lib/vapi_server_sdk/types/server_message_response_voice_request.rb', line 93

def self.validate_raw(obj:)
  obj.data.is_a?(String) != false || raise("Passed value for field obj.data is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of ServerMessageResponseVoiceRequest to a JSON object

Returns:

  • (String)

83
84
85
# File 'lib/vapi_server_sdk/types/server_message_response_voice_request.rb', line 83

def to_json(*_args)
  @_field_set&.to_json
end