Class: Vapi::VapiCost
- Inherits:
-
Object
- Object
- Vapi::VapiCost
- Defined in:
- lib/vapi_server_sdk/types/vapi_cost.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#cost ⇒ Float
readonly
This is the cost of the component in USD.
-
#minutes ⇒ Float
readonly
This is the minutes of Vapi usage.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Vapi::VapiCost
Deserialize a JSON object to an instance of VapiCost.
-
.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(minutes:, cost:, additional_properties: nil) ⇒ Vapi::VapiCost constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of VapiCost to a JSON object.
Constructor Details
#initialize(minutes:, cost:, additional_properties: nil) ⇒ Vapi::VapiCost
26 27 28 29 30 31 |
# File 'lib/vapi_server_sdk/types/vapi_cost.rb', line 26 def initialize(minutes:, cost:, additional_properties: nil) @minutes = minutes @cost = cost @additional_properties = additional_properties @_field_set = { "minutes": minutes, "cost": cost } end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
14 15 16 |
# File 'lib/vapi_server_sdk/types/vapi_cost.rb', line 14 def additional_properties @additional_properties end |
#cost ⇒ Float (readonly)
Returns This is the cost of the component in USD.
12 13 14 |
# File 'lib/vapi_server_sdk/types/vapi_cost.rb', line 12 def cost @cost end |
#minutes ⇒ Float (readonly)
Returns This is the minutes of Vapi usage. This should match ‘call.endedAt` - `call.startedAt`.
10 11 12 |
# File 'lib/vapi_server_sdk/types/vapi_cost.rb', line 10 def minutes @minutes end |
Class Method Details
.from_json(json_object:) ⇒ Vapi::VapiCost
Deserialize a JSON object to an instance of VapiCost
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/vapi_server_sdk/types/vapi_cost.rb', line 37 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) minutes = parsed_json["minutes"] cost = parsed_json["cost"] new( minutes: minutes, 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.
62 63 64 65 |
# File 'lib/vapi_server_sdk/types/vapi_cost.rb', line 62 def self.validate_raw(obj:) obj.minutes.is_a?(Float) != false || raise("Passed value for field obj.minutes 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 VapiCost to a JSON object
52 53 54 |
# File 'lib/vapi_server_sdk/types/vapi_cost.rb', line 52 def to_json(*_args) @_field_set&.to_json end |