Class: Vapi::ServerMessageVoiceRequest

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text:, sample_rate:, phone_number: OMIT, timestamp: OMIT, artifact: OMIT, assistant: OMIT, customer: OMIT, call: OMIT, chat: OMIT, additional_properties: nil) ⇒ Vapi::ServerMessageVoiceRequest

Parameters:

  • phone_number (Vapi::ServerMessageVoiceRequestPhoneNumber) (defaults to: OMIT)

    This is the phone number that the message is associated with.

  • timestamp (Float) (defaults to: OMIT)

    This is the timestamp of the message.

  • artifact (Vapi::Artifact) (defaults to: OMIT)

    This is a live version of the ‘call.artifact`. This matches what is stored on `call.artifact` after the call.

  • assistant (Vapi::CreateAssistantDto) (defaults to: OMIT)

    This is the assistant that the message is associated with.

  • customer (Vapi::CreateCustomerDto) (defaults to: OMIT)

    This is the customer that the message is associated with.

  • call (Vapi::Call) (defaults to: OMIT)

    This is the call that the message is associated with.

  • chat (Vapi::Chat) (defaults to: OMIT)

    This is the chat object.

  • text (String)

    This is the text to be synthesized.

  • sample_rate (Float)

    This is the sample rate to be synthesized.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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
# File 'lib/vapi_server_sdk/types/server_message_voice_request.rb', line 53

def initialize(text:, sample_rate:, phone_number: OMIT, timestamp: OMIT, artifact: OMIT, assistant: OMIT, customer: OMIT, call: OMIT,
               chat: OMIT, additional_properties: nil)
  @phone_number = phone_number if phone_number != OMIT
  @timestamp = timestamp if timestamp != OMIT
  @artifact = artifact if artifact != OMIT
  @assistant = assistant if assistant != OMIT
  @customer = customer if customer != OMIT
  @call = call if call != OMIT
  @chat = chat if chat != OMIT
  @text = text
  @sample_rate = sample_rate
  @additional_properties = additional_properties
  @_field_set = {
    "phoneNumber": phone_number,
    "timestamp": timestamp,
    "artifact": artifact,
    "assistant": assistant,
    "customer": customer,
    "call": call,
    "chat": chat,
    "text": text,
    "sampleRate": sample_rate
  }.reject do |_k, v|
    v == OMIT
  end
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



34
35
36
# File 'lib/vapi_server_sdk/types/server_message_voice_request.rb', line 34

def additional_properties
  @additional_properties
end

#artifactVapi::Artifact (readonly)

Returns This is a live version of the ‘call.artifact`. This matches what is stored on `call.artifact` after the call.

Returns:

  • (Vapi::Artifact)

    This is a live version of the ‘call.artifact`. This matches what is stored on `call.artifact` after the call.



20
21
22
# File 'lib/vapi_server_sdk/types/server_message_voice_request.rb', line 20

def artifact
  @artifact
end

#assistantVapi::CreateAssistantDto (readonly)

Returns This is the assistant that the message is associated with.

Returns:



22
23
24
# File 'lib/vapi_server_sdk/types/server_message_voice_request.rb', line 22

def assistant
  @assistant
end

#callVapi::Call (readonly)

Returns This is the call that the message is associated with.

Returns:

  • (Vapi::Call)

    This is the call that the message is associated with.



26
27
28
# File 'lib/vapi_server_sdk/types/server_message_voice_request.rb', line 26

def call
  @call
end

#chatVapi::Chat (readonly)

Returns This is the chat object.

Returns:



28
29
30
# File 'lib/vapi_server_sdk/types/server_message_voice_request.rb', line 28

def chat
  @chat
end

#customerVapi::CreateCustomerDto (readonly)

Returns This is the customer that the message is associated with.

Returns:



24
25
26
# File 'lib/vapi_server_sdk/types/server_message_voice_request.rb', line 24

def customer
  @customer
end

#phone_numberVapi::ServerMessageVoiceRequestPhoneNumber (readonly)

Returns This is the phone number that the message is associated with.

Returns:



15
16
17
# File 'lib/vapi_server_sdk/types/server_message_voice_request.rb', line 15

def phone_number
  @phone_number
end

#sample_rateFloat (readonly)

Returns This is the sample rate to be synthesized.

Returns:

  • (Float)

    This is the sample rate to be synthesized.



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

def sample_rate
  @sample_rate
end

#textString (readonly)

Returns This is the text to be synthesized.

Returns:

  • (String)

    This is the text to be synthesized.



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

def text
  @text
end

#timestampFloat (readonly)

Returns This is the timestamp of the message.

Returns:

  • (Float)

    This is the timestamp of the message.



17
18
19
# File 'lib/vapi_server_sdk/types/server_message_voice_request.rb', line 17

def timestamp
  @timestamp
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::ServerMessageVoiceRequest

Deserialize a JSON object to an instance of ServerMessageVoiceRequest

Parameters:

  • json_object (String)

Returns:



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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/vapi_server_sdk/types/server_message_voice_request.rb', line 84

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::ServerMessageVoiceRequestPhoneNumber.from_json(json_object: phone_number)
  end
  timestamp = 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
  if parsed_json["chat"].nil?
    chat = nil
  else
    chat = parsed_json["chat"].to_json
    chat = Vapi::Chat.from_json(json_object: chat)
  end
  text = parsed_json["text"]
  sample_rate = parsed_json["sampleRate"]
  new(
    phone_number: phone_number,
    timestamp: timestamp,
    artifact: artifact,
    assistant: assistant,
    customer: customer,
    call: call,
    chat: chat,
    text: text,
    sample_rate: sample_rate,
    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)


153
154
155
156
157
158
159
160
161
162
163
# File 'lib/vapi_server_sdk/types/server_message_voice_request.rb', line 153

def self.validate_raw(obj:)
  obj.phone_number.nil? || Vapi::ServerMessageVoiceRequestPhoneNumber.validate_raw(obj: obj.phone_number)
  obj.timestamp&.is_a?(Float) != 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)
  obj.chat.nil? || Vapi::Chat.validate_raw(obj: obj.chat)
  obj.text.is_a?(String) != false || raise("Passed value for field obj.text is not the expected type, validation failed.")
  obj.sample_rate.is_a?(Float) != false || raise("Passed value for field obj.sample_rate is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of ServerMessageVoiceRequest to a JSON object

Returns:

  • (String)


143
144
145
# File 'lib/vapi_server_sdk/types/server_message_voice_request.rb', line 143

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