Class: Vapi::VoiceCost

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(voice:, characters:, cost:, additional_properties: nil) ⇒ Vapi::VoiceCost



45
46
47
48
49
50
51
# File 'lib/vapi_server_sdk/types/voice_cost.rb', line 45

def initialize(voice:, characters:, cost:, additional_properties: nil)
  @voice = voice
  @characters = characters
  @cost = cost
  @additional_properties = additional_properties
  @_field_set = { "voice": voice, "characters": characters, "cost": cost }
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)



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

def additional_properties
  @additional_properties
end

#charactersFloat (readonly)



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

def characters
  @characters
end

#costFloat (readonly)



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

def cost
  @cost
end

#voiceHash{String => Object} (readonly)



16
17
18
# File 'lib/vapi_server_sdk/types/voice_cost.rb', line 16

def voice
  @voice
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::VoiceCost

Deserialize a JSON object to an instance of VoiceCost



57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/vapi_server_sdk/types/voice_cost.rb', line 57

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


84
85
86
87
88
# File 'lib/vapi_server_sdk/types/voice_cost.rb', line 84

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

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of VoiceCost to a JSON object



74
75
76
# File 'lib/vapi_server_sdk/types/voice_cost.rb', line 74

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