Class: Vapi::TavusVoice

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(voice_id:, caching_enabled: OMIT, chunk_plan: OMIT, persona_id: OMIT, callback_url: OMIT, conversation_name: OMIT, conversational_context: OMIT, custom_greeting: OMIT, properties: OMIT, fallback_plan: OMIT, additional_properties: nil) ⇒ Vapi::TavusVoice



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/tavus_voice.rb', line 64

def initialize(voice_id:, caching_enabled: OMIT, chunk_plan: OMIT, persona_id: OMIT, callback_url: OMIT,
               conversation_name: OMIT, conversational_context: OMIT, custom_greeting: OMIT, properties: OMIT, fallback_plan: OMIT, additional_properties: nil)
  @caching_enabled = caching_enabled if caching_enabled != OMIT
  @voice_id = voice_id
  @chunk_plan = chunk_plan if chunk_plan != OMIT
  @persona_id = persona_id if persona_id != OMIT
  @callback_url = callback_url if callback_url != OMIT
  @conversation_name = conversation_name if conversation_name != OMIT
  @conversational_context = conversational_context if conversational_context != OMIT
  @custom_greeting = custom_greeting if custom_greeting != OMIT
  @properties = properties if properties != OMIT
  @fallback_plan = fallback_plan if fallback_plan != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "cachingEnabled": caching_enabled,
    "voiceId": voice_id,
    "chunkPlan": chunk_plan,
    "personaId": persona_id,
    "callbackUrl": callback_url,
    "conversationName": conversation_name,
    "conversationalContext": conversational_context,
    "customGreeting": custom_greeting,
    "properties": properties,
    "fallbackPlan": fallback_plan
  }.reject do |_k, v|
    v == OMIT
  end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)



39
40
41
# File 'lib/vapi_server_sdk/types/tavus_voice.rb', line 39

def additional_properties
  @additional_properties
end

#caching_enabledBoolean (readonly)



13
14
15
# File 'lib/vapi_server_sdk/types/tavus_voice.rb', line 13

def caching_enabled
  @caching_enabled
end

#callback_urlString (readonly)



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

def callback_url
  @callback_url
end

#chunk_planVapi::ChunkPlan (readonly)



18
19
20
# File 'lib/vapi_server_sdk/types/tavus_voice.rb', line 18

def chunk_plan
  @chunk_plan
end

#conversation_nameString (readonly)



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

def conversation_name
  @conversation_name
end

#conversational_contextString (readonly)



29
30
31
# File 'lib/vapi_server_sdk/types/tavus_voice.rb', line 29

def conversational_context
  @conversational_context
end

#custom_greetingString (readonly)



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

def custom_greeting
  @custom_greeting
end

#fallback_planVapi::FallbackPlan (readonly)



37
38
39
# File 'lib/vapi_server_sdk/types/tavus_voice.rb', line 37

def fallback_plan
  @fallback_plan
end

#persona_idString (readonly)



21
22
23
# File 'lib/vapi_server_sdk/types/tavus_voice.rb', line 21

def persona_id
  @persona_id
end

#propertiesVapi::TavusConversationProperties (readonly)



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

def properties
  @properties
end

#voice_idVapi::TavusVoiceVoiceId (readonly)



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

def voice_id
  @voice_id
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::TavusVoice

Deserialize a JSON object to an instance of TavusVoice



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
139
140
141
142
143
# File 'lib/vapi_server_sdk/types/tavus_voice.rb', line 97

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  caching_enabled = parsed_json["cachingEnabled"]
  if parsed_json["voiceId"].nil?
    voice_id = nil
  else
    voice_id = parsed_json["voiceId"].to_json
    voice_id = Vapi::TavusVoiceVoiceId.from_json(json_object: voice_id)
  end
  if parsed_json["chunkPlan"].nil?
    chunk_plan = nil
  else
    chunk_plan = parsed_json["chunkPlan"].to_json
    chunk_plan = Vapi::ChunkPlan.from_json(json_object: chunk_plan)
  end
  persona_id = parsed_json["personaId"]
  callback_url = parsed_json["callbackUrl"]
  conversation_name = parsed_json["conversationName"]
  conversational_context = parsed_json["conversationalContext"]
  custom_greeting = parsed_json["customGreeting"]
  if parsed_json["properties"].nil?
    properties = nil
  else
    properties = parsed_json["properties"].to_json
    properties = Vapi::TavusConversationProperties.from_json(json_object: properties)
  end
  if parsed_json["fallbackPlan"].nil?
    fallback_plan = nil
  else
    fallback_plan = parsed_json["fallbackPlan"].to_json
    fallback_plan = Vapi::FallbackPlan.from_json(json_object: fallback_plan)
  end
  new(
    caching_enabled: caching_enabled,
    voice_id: voice_id,
    chunk_plan: chunk_plan,
    persona_id: persona_id,
    callback_url: callback_url,
    conversation_name: conversation_name,
    conversational_context: conversational_context,
    custom_greeting: custom_greeting,
    properties: properties,
    fallback_plan: fallback_plan,
    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.


158
159
160
161
162
163
164
165
166
167
168
169
# File 'lib/vapi_server_sdk/types/tavus_voice.rb', line 158

def self.validate_raw(obj:)
  obj.caching_enabled&.is_a?(Boolean) != false || raise("Passed value for field obj.caching_enabled is not the expected type, validation failed.")
  Vapi::TavusVoiceVoiceId.validate_raw(obj: obj.voice_id)
  obj.chunk_plan.nil? || Vapi::ChunkPlan.validate_raw(obj: obj.chunk_plan)
  obj.persona_id&.is_a?(String) != false || raise("Passed value for field obj.persona_id is not the expected type, validation failed.")
  obj.callback_url&.is_a?(String) != false || raise("Passed value for field obj.callback_url is not the expected type, validation failed.")
  obj.conversation_name&.is_a?(String) != false || raise("Passed value for field obj.conversation_name is not the expected type, validation failed.")
  obj.conversational_context&.is_a?(String) != false || raise("Passed value for field obj.conversational_context is not the expected type, validation failed.")
  obj.custom_greeting&.is_a?(String) != false || raise("Passed value for field obj.custom_greeting is not the expected type, validation failed.")
  obj.properties.nil? || Vapi::TavusConversationProperties.validate_raw(obj: obj.properties)
  obj.fallback_plan.nil? || Vapi::FallbackPlan.validate_raw(obj: obj.fallback_plan)
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of TavusVoice to a JSON object



148
149
150
# File 'lib/vapi_server_sdk/types/tavus_voice.rb', line 148

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