Class: Vapi::VoiceCost
- Inherits:
-
Object
- Object
- Vapi::VoiceCost
- Defined in:
- lib/vapi_server_sdk/types/voice_cost.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#characters ⇒ Float
readonly
This is the number of characters that were generated during the call.
-
#cost ⇒ Float
readonly
This is the cost of the component in USD.
-
#voice ⇒ Hash{String => Object}
readonly
This is the voice that was used during the call.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Vapi::VoiceCost
Deserialize a JSON object to an instance of VoiceCost.
-
.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.
Instance Method Summary collapse
- #initialize(voice:, characters:, cost:, additional_properties: nil) ⇒ Vapi::VoiceCost constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of VoiceCost to a JSON object.
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_properties ⇒ OpenStruct (readonly)
Returns 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 |
#characters ⇒ Float (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.
20 21 22 |
# File 'lib/vapi_server_sdk/types/voice_cost.rb', line 20 def characters @characters end |
#cost ⇒ Float (readonly)
Returns 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 |
#voice ⇒ Hash{String => Object} (readonly)
Returns This is the voice that was used during the call. This matches one of the following:
-
‘call.assistant.voice`,
-
‘call.assistantId->voice`,
-
‘call.squad.assistant.voice`,
-
‘call.squad.assistantId->voice`,
-
‘call.squadId->.assistant.voice`,
-
‘call.squadId->.assistantId->voice`.
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 |