Class: Vapi::ServerMessageEndOfCallReportCostsItem

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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

Parameters:

  • member (Object)
  • discriminant (String)


24
25
26
27
# File 'lib/vapi_server_sdk/types/server_message_end_of_call_report_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/server_message_end_of_call_report_costs_item.rb', line 16

def discriminant
  @discriminant
end

#memberObject (readonly)

Returns:

  • (Object)


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

def member
  @member
end

Class Method Details

.analysis(member:) ⇒ Vapi::ServerMessageEndOfCallReportCostsItem



143
144
145
# File 'lib/vapi_server_sdk/types/server_message_end_of_call_report_costs_item.rb', line 143

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

.from_json(json_object:) ⇒ Vapi::ServerMessageEndOfCallReportCostsItem

Deserialize a JSON object to an instance of

ServerMessageEndOfCallReportCostsItem

Parameters:

  • json_object (String)

Returns:



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

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::ServerMessageEndOfCallReportCostsItem



125
126
127
# File 'lib/vapi_server_sdk/types/server_message_end_of_call_report_costs_item.rb', line 125

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

.transcriber(member:) ⇒ Vapi::ServerMessageEndOfCallReportCostsItem



119
120
121
# File 'lib/vapi_server_sdk/types/server_message_end_of_call_report_costs_item.rb', line 119

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

.transport(member:) ⇒ Vapi::ServerMessageEndOfCallReportCostsItem



113
114
115
# File 'lib/vapi_server_sdk/types/server_message_end_of_call_report_costs_item.rb', line 113

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)


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

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::ServerMessageEndOfCallReportCostsItem



137
138
139
# File 'lib/vapi_server_sdk/types/server_message_end_of_call_report_costs_item.rb', line 137

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

.voice(member:) ⇒ Vapi::ServerMessageEndOfCallReportCostsItem



131
132
133
# File 'lib/vapi_server_sdk/types/server_message_end_of_call_report_costs_item.rb', line 131

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)


107
108
109
# File 'lib/vapi_server_sdk/types/server_message_end_of_call_report_costs_item.rb', line 107

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

#kind_of?Object



19
# File 'lib/vapi_server_sdk/types/server_message_end_of_call_report_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)


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

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