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.
-
#sub_type ⇒ Vapi::VapiCostSubType
readonly
This is the sub type of the cost.
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(sub_type:, minutes:, cost:, additional_properties: nil) ⇒ Vapi::VapiCost constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of VapiCost to a JSON object.
Constructor Details
#initialize(sub_type:, minutes:, cost:, additional_properties: nil) ⇒ Vapi::VapiCost
30 31 32 33 34 35 36 |
# File 'lib/vapi_server_sdk/types/vapi_cost.rb', line 30 def initialize(sub_type:, minutes:, cost:, additional_properties: nil) @sub_type = sub_type @minutes = minutes @cost = cost @additional_properties = additional_properties @_field_set = { "subType": sub_type, "minutes": minutes, "cost": cost } end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
17 18 19 |
# File 'lib/vapi_server_sdk/types/vapi_cost.rb', line 17 def additional_properties @additional_properties end |
#cost ⇒ Float (readonly)
Returns This is the cost of the component in USD.
15 16 17 |
# File 'lib/vapi_server_sdk/types/vapi_cost.rb', line 15 def cost @cost end |
#minutes ⇒ Float (readonly)
Returns This is the minutes of Vapi usage. This should match ‘call.endedAt` - `call.startedAt`.
13 14 15 |
# File 'lib/vapi_server_sdk/types/vapi_cost.rb', line 13 def minutes @minutes end |
#sub_type ⇒ Vapi::VapiCostSubType (readonly)
Returns This is the sub type of the cost.
10 11 12 |
# File 'lib/vapi_server_sdk/types/vapi_cost.rb', line 10 def sub_type @sub_type end |
Class Method Details
.from_json(json_object:) ⇒ Vapi::VapiCost
Deserialize a JSON object to an instance of VapiCost
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/vapi_server_sdk/types/vapi_cost.rb', line 42 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) sub_type = parsed_json["subType"] minutes = parsed_json["minutes"] cost = parsed_json["cost"] new( sub_type: sub_type, 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.
69 70 71 72 73 |
# File 'lib/vapi_server_sdk/types/vapi_cost.rb', line 69 def self.validate_raw(obj:) obj.sub_type.is_a?(Vapi::VapiCostSubType) != false || raise("Passed value for field obj.sub_type is not the expected type, validation failed.") 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
59 60 61 |
# File 'lib/vapi_server_sdk/types/vapi_cost.rb', line 59 def to_json(*_args) @_field_set&.to_json end |