Class: Vapi::VapiCost

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(minutes:, cost:, additional_properties: nil) ⇒ Vapi::VapiCost

Parameters:

  • minutes (Float)

    This is the minutes of Vapi usage. This should match ‘call.endedAt` - `call.startedAt`.

  • 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



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_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    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

#costFloat (readonly)

Returns This is the cost of the component in USD.

Returns:

  • (Float)

    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

#minutesFloat (readonly)

Returns This is the minutes of Vapi usage. This should match ‘call.endedAt` - `call.startedAt`.

Returns:

  • (Float)

    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

Parameters:

  • json_object (String)

Returns:



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.

Parameters:

  • obj (Object)

Returns:

  • (Void)


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

Returns:

  • (String)


52
53
54
# File 'lib/vapi_server_sdk/types/vapi_cost.rb', line 52

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