Class: Vapi::CustomVoice

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server:, caching_enabled: OMIT, chunk_plan: OMIT, fallback_plan: OMIT, additional_properties: nil) ⇒ Vapi::CustomVoice



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/vapi_server_sdk/types/custom_voice.rb', line 73

def initialize(server:, caching_enabled: OMIT, chunk_plan: OMIT, fallback_plan: OMIT, additional_properties: nil)
  @caching_enabled = caching_enabled if caching_enabled != OMIT
  @chunk_plan = chunk_plan if chunk_plan != OMIT
  @server = server
  @fallback_plan = fallback_plan if fallback_plan != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "cachingEnabled": caching_enabled,
    "chunkPlan": chunk_plan,
    "server": server,
    "fallbackPlan": fallback_plan
  }.reject do |_k, v|
    v == OMIT
  end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)



40
41
42
# File 'lib/vapi_server_sdk/types/custom_voice.rb', line 40

def additional_properties
  @additional_properties
end

#caching_enabledBoolean (readonly)



12
13
14
# File 'lib/vapi_server_sdk/types/custom_voice.rb', line 12

def caching_enabled
  @caching_enabled
end

#chunk_planVapi::ChunkPlan (readonly)



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

def chunk_plan
  @chunk_plan
end

#fallback_planVapi::FallbackPlan (readonly)



38
39
40
# File 'lib/vapi_server_sdk/types/custom_voice.rb', line 38

def fallback_plan
  @fallback_plan
end

#serverVapi::Server (readonly)



35
36
37
# File 'lib/vapi_server_sdk/types/custom_voice.rb', line 35

def server
  @server
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::CustomVoice

Deserialize a JSON object to an instance of CustomVoice



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

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["chunkPlan"].nil?
    chunk_plan = nil
  else
    chunk_plan = parsed_json["chunkPlan"].to_json
    chunk_plan = Vapi::ChunkPlan.from_json(json_object: chunk_plan)
  end
  if parsed_json["server"].nil?
    server = nil
  else
    server = parsed_json["server"].to_json
    server = Vapi::Server.from_json(json_object: server)
  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,
    chunk_plan: chunk_plan,
    server: server,
    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.


137
138
139
140
141
142
# File 'lib/vapi_server_sdk/types/custom_voice.rb', line 137

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.")
  obj.chunk_plan.nil? || Vapi::ChunkPlan.validate_raw(obj: obj.chunk_plan)
  Vapi::Server.validate_raw(obj: obj.server)
  obj.fallback_plan.nil? || Vapi::FallbackPlan.validate_raw(obj: obj.fallback_plan)
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of CustomVoice to a JSON object



127
128
129
# File 'lib/vapi_server_sdk/types/custom_voice.rb', line 127

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