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(sub_type:, minutes:, cost:, additional_properties: nil) ⇒ Vapi::VapiCost

Parameters:

  • sub_type (Vapi::VapiCostSubType)

    This is the sub type of the cost.

  • 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



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

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    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

#costFloat (readonly)

Returns This is the cost of the component in USD.

Returns:

  • (Float)

    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

#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`.



13
14
15
# File 'lib/vapi_server_sdk/types/vapi_cost.rb', line 13

def minutes
  @minutes
end

#sub_typeVapi::VapiCostSubType (readonly)

Returns This is the sub type of the cost.

Returns:



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

Parameters:

  • json_object (String)

Returns:



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.

Parameters:

  • obj (Object)

Returns:

  • (Void)


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

Returns:

  • (String)


59
60
61
# File 'lib/vapi_server_sdk/types/vapi_cost.rb', line 59

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