Class: Vapi::CallCostsItem

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(member:, discriminant:) ⇒ Vapi::CallCostsItem

Parameters:

  • member (Object)
  • discriminant (String)


24
25
26
27
# File 'lib/vapi_server_sdk/types/call_costs_item.rb', line 24

def initialize(member:, discriminant:)
  @member = member
  @discriminant = discriminant
end

Instance Attribute Details

#discriminantString (readonly)

Returns:

  • (String)


16
17
18
# File 'lib/vapi_server_sdk/types/call_costs_item.rb', line 16

def discriminant
  @discriminant
end

#memberObject (readonly)

Returns:

  • (Object)


14
15
16
# File 'lib/vapi_server_sdk/types/call_costs_item.rb', line 14

def member
  @member
end

Class Method Details

.analysis(member:) ⇒ Vapi::CallCostsItem

Parameters:

Returns:



142
143
144
# File 'lib/vapi_server_sdk/types/call_costs_item.rb', line 142

def self.analysis(member:)
  new(member: member, discriminant: "analysis")
end

.from_json(json_object:) ⇒ Vapi::CallCostsItem

Deserialize a JSON object to an instance of CallCostsItem

Parameters:

  • json_object (String)

Returns:



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/vapi_server_sdk/types/call_costs_item.rb', line 33

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  member = case struct.type
           when "transport"
             Vapi::TransportCost.from_json(json_object: json_object)
           when "transcriber"
             Vapi::TranscriberCost.from_json(json_object: json_object)
           when "model"
             Vapi::ModelCost.from_json(json_object: json_object)
           when "voice"
             Vapi::VoiceCost.from_json(json_object: json_object)
           when "vapi"
             Vapi::VapiCost.from_json(json_object: json_object)
           when "analysis"
             Vapi::AnalysisCost.from_json(json_object: json_object)
           else
             Vapi::TransportCost.from_json(json_object: json_object)
           end
  new(member: member, discriminant: struct.type)
end

.model(member:) ⇒ Vapi::CallCostsItem

Parameters:

Returns:



124
125
126
# File 'lib/vapi_server_sdk/types/call_costs_item.rb', line 124

def self.model(member:)
  new(member: member, discriminant: "model")
end

.transcriber(member:) ⇒ Vapi::CallCostsItem

Parameters:

Returns:



118
119
120
# File 'lib/vapi_server_sdk/types/call_costs_item.rb', line 118

def self.transcriber(member:)
  new(member: member, discriminant: "transcriber")
end

.transport(member:) ⇒ Vapi::CallCostsItem

Parameters:

Returns:



112
113
114
# File 'lib/vapi_server_sdk/types/call_costs_item.rb', line 112

def self.transport(member:)
  new(member: member, discriminant: "transport")
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)


83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/vapi_server_sdk/types/call_costs_item.rb', line 83

def self.validate_raw(obj:)
  case obj.type
  when "transport"
    Vapi::TransportCost.validate_raw(obj: obj)
  when "transcriber"
    Vapi::TranscriberCost.validate_raw(obj: obj)
  when "model"
    Vapi::ModelCost.validate_raw(obj: obj)
  when "voice"
    Vapi::VoiceCost.validate_raw(obj: obj)
  when "vapi"
    Vapi::VapiCost.validate_raw(obj: obj)
  when "analysis"
    Vapi::AnalysisCost.validate_raw(obj: obj)
  else
    raise("Passed value matched no type within the union, validation failed.")
  end
end

.vapi(member:) ⇒ Vapi::CallCostsItem

Parameters:

Returns:



136
137
138
# File 'lib/vapi_server_sdk/types/call_costs_item.rb', line 136

def self.vapi(member:)
  new(member: member, discriminant: "vapi")
end

.voice(member:) ⇒ Vapi::CallCostsItem

Parameters:

Returns:



130
131
132
# File 'lib/vapi_server_sdk/types/call_costs_item.rb', line 130

def self.voice(member:)
  new(member: member, discriminant: "voice")
end

Instance Method Details

#is_a?(obj) ⇒ Boolean

For Union Types, is_a? functionality is delegated to the wrapped member.

Parameters:

  • obj (Object)

Returns:

  • (Boolean)


106
107
108
# File 'lib/vapi_server_sdk/types/call_costs_item.rb', line 106

def is_a?(obj)
  @member.is_a?(obj)
end

#kind_of?Object



19
# File 'lib/vapi_server_sdk/types/call_costs_item.rb', line 19

alias kind_of? is_a?

#to_json(*_args) ⇒ String

For Union Types, to_json functionality is delegated to the wrapped member.

Returns:

  • (String)


57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/vapi_server_sdk/types/call_costs_item.rb', line 57

def to_json(*_args)
  case @discriminant
  when "transport"
    { **@member.to_json, type: @discriminant }.to_json
  when "transcriber"
    { **@member.to_json, type: @discriminant }.to_json
  when "model"
    { **@member.to_json, type: @discriminant }.to_json
  when "voice"
    { **@member.to_json, type: @discriminant }.to_json
  when "vapi"
    { **@member.to_json, type: @discriminant }.to_json
  when "analysis"
    { **@member.to_json, type: @discriminant }.to_json
  else
    { "type": @discriminant, value: @member }.to_json
  end
  @member.to_json
end