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

Parameters:

  • voice (Hash{String => Object})

    This is the voice that was used during the call. This matches one of the following:

  • characters (Float)

    This is the number of characters that were generated during the call. These should be total characters used in the call for single assistant calls, while squad calls will have multiple voice costs one for each assistant that was used.

  • cost (Float)

    This is the cost of the component in USD.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



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

def additional_properties
  @additional_properties
end

#charactersFloat (readonly)

Returns This is the number of characters that were generated during the call. These should be total characters used in the call for single assistant calls, while squad calls will have multiple voice costs one for each assistant that was used.

Returns:

  • (Float)

    This is the number of characters that were generated during the call. These should be total characters used in the call for single assistant calls, while squad calls will have multiple voice costs one for each assistant that was used.



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

def characters
  @characters
end

#costFloat (readonly)

Returns This is the cost of the component in USD.

Returns:

  • (Float)

    This is the cost of the component in USD.



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

def cost
  @cost
end

#voiceHash{String => Object} (readonly)

Returns This is the voice that was used during the call. This matches one of the following:

Returns:

  • (Hash{String => Object})

    This is the voice that was used during the call. This matches one of the following:



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

Parameters:

  • json_object (String)

Returns:



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.

Parameters:

  • obj (Object)

Returns:

  • (Void)


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

Returns:

  • (String)


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

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