Class: Vapi::ServerMessageToolCallsToolWithToolCallListItem

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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



25
26
27
28
# File 'lib/vapi_server_sdk/types/server_message_tool_calls_tool_with_tool_call_list_item.rb', line 25

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

Instance Attribute Details

#discriminantString (readonly)



17
18
19
# File 'lib/vapi_server_sdk/types/server_message_tool_calls_tool_with_tool_call_list_item.rb', line 17

def discriminant
  @discriminant
end

#memberObject (readonly)



15
16
17
# File 'lib/vapi_server_sdk/types/server_message_tool_calls_tool_with_tool_call_list_item.rb', line 15

def member
  @member
end

Class Method Details

.bash(member:) ⇒ Vapi::ServerMessageToolCallsToolWithToolCallListItem



138
139
140
# File 'lib/vapi_server_sdk/types/server_message_tool_calls_tool_with_tool_call_list_item.rb', line 138

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

.computer(member:) ⇒ Vapi::ServerMessageToolCallsToolWithToolCallListItem



144
145
146
# File 'lib/vapi_server_sdk/types/server_message_tool_calls_tool_with_tool_call_list_item.rb', line 144

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

.from_json(json_object:) ⇒ Vapi::ServerMessageToolCallsToolWithToolCallListItem

Deserialize a JSON object to an instance of

ServerMessageToolCallsToolWithToolCallListItem


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

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  member = case struct.type
           when "function"
             Vapi::FunctionToolWithToolCall.from_json(json_object: json_object)
           when "ghl"
             Vapi::GhlToolWithToolCall.from_json(json_object: json_object)
           when "make"
             Vapi::MakeToolWithToolCall.from_json(json_object: json_object)
           when "bash"
             Vapi::BashToolWithToolCall.from_json(json_object: json_object)
           when "computer"
             Vapi::ComputerToolWithToolCall.from_json(json_object: json_object)
           when "textEditor"
             Vapi::TextEditorToolWithToolCall.from_json(json_object: json_object)
           when "google.calendar.event.create"
             Vapi::GoogleCalendarCreateEventToolWithToolCall.from_json(json_object: json_object)
           else
             Vapi::FunctionToolWithToolCall.from_json(json_object: json_object)
           end
  new(member: member, discriminant: struct.type)
end

.function(member:) ⇒ Vapi::ServerMessageToolCallsToolWithToolCallListItem



120
121
122
# File 'lib/vapi_server_sdk/types/server_message_tool_calls_tool_with_tool_call_list_item.rb', line 120

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

.ghl(member:) ⇒ Vapi::ServerMessageToolCallsToolWithToolCallListItem



126
127
128
# File 'lib/vapi_server_sdk/types/server_message_tool_calls_tool_with_tool_call_list_item.rb', line 126

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

.google_calendar_event_create(member:) ⇒ Vapi::ServerMessageToolCallsToolWithToolCallListItem



156
157
158
# File 'lib/vapi_server_sdk/types/server_message_tool_calls_tool_with_tool_call_list_item.rb', line 156

def self.google_calendar_event_create(member:)
  new(member: member, discriminant: "google.calendar.event.create")
end

.make(member:) ⇒ Vapi::ServerMessageToolCallsToolWithToolCallListItem



132
133
134
# File 'lib/vapi_server_sdk/types/server_message_tool_calls_tool_with_tool_call_list_item.rb', line 132

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

.text_editor(member:) ⇒ Vapi::ServerMessageToolCallsToolWithToolCallListItem



150
151
152
# File 'lib/vapi_server_sdk/types/server_message_tool_calls_tool_with_tool_call_list_item.rb', line 150

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


89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/vapi_server_sdk/types/server_message_tool_calls_tool_with_tool_call_list_item.rb', line 89

def self.validate_raw(obj:)
  case obj.type
  when "function"
    Vapi::FunctionToolWithToolCall.validate_raw(obj: obj)
  when "ghl"
    Vapi::GhlToolWithToolCall.validate_raw(obj: obj)
  when "make"
    Vapi::MakeToolWithToolCall.validate_raw(obj: obj)
  when "bash"
    Vapi::BashToolWithToolCall.validate_raw(obj: obj)
  when "computer"
    Vapi::ComputerToolWithToolCall.validate_raw(obj: obj)
  when "textEditor"
    Vapi::TextEditorToolWithToolCall.validate_raw(obj: obj)
  when "google.calendar.event.create"
    Vapi::GoogleCalendarCreateEventToolWithToolCall.validate_raw(obj: obj)
  else
    raise("Passed value matched no type within the union, validation failed.")
  end
end

Instance Method Details

#is_a?(obj) ⇒ Boolean

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



114
115
116
# File 'lib/vapi_server_sdk/types/server_message_tool_calls_tool_with_tool_call_list_item.rb', line 114

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

#kind_of?Object



20
# File 'lib/vapi_server_sdk/types/server_message_tool_calls_tool_with_tool_call_list_item.rb', line 20

alias kind_of? is_a?

#to_json(*_args) ⇒ String

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



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/vapi_server_sdk/types/server_message_tool_calls_tool_with_tool_call_list_item.rb', line 61

def to_json(*_args)
  case @discriminant
  when "function"
    { **@member.to_json, type: @discriminant }.to_json
  when "ghl"
    { **@member.to_json, type: @discriminant }.to_json
  when "make"
    { **@member.to_json, type: @discriminant }.to_json
  when "bash"
    { **@member.to_json, type: @discriminant }.to_json
  when "computer"
    { **@member.to_json, type: @discriminant }.to_json
  when "textEditor"
    { **@member.to_json, type: @discriminant }.to_json
  when "google.calendar.event.create"
    { **@member.to_json, type: @discriminant }.to_json
  else
    { "type": @discriminant, value: @member }.to_json
  end
  @member.to_json
end