Class: Vapi::ClientMessageToolCallsToolWithToolCallListItem

Inherits:
Object
  • Object
show all
Defined in:
lib/vapi_server_sdk/types/client_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::ClientMessageToolCallsToolWithToolCallListItem

Parameters:

  • member (Object)
  • discriminant (String)


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

def discriminant
  @discriminant
end

#memberObject (readonly)

Returns:

  • (Object)


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

def member
  @member
end

Class Method Details

.bash(member:) ⇒ Vapi::ClientMessageToolCallsToolWithToolCallListItem



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

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

.computer(member:) ⇒ Vapi::ClientMessageToolCallsToolWithToolCallListItem



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

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

.from_json(json_object:) ⇒ Vapi::ClientMessageToolCallsToolWithToolCallListItem

Deserialize a JSON object to an instance of

ClientMessageToolCallsToolWithToolCallListItem

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/client_message_tool_calls_tool_with_tool_call_list_item.rb', line 34

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)
           else
             Vapi::FunctionToolWithToolCall.from_json(json_object: json_object)
           end
  new(member: member, discriminant: struct.type)
end

.function(member:) ⇒ Vapi::ClientMessageToolCallsToolWithToolCallListItem



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

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

.ghl(member:) ⇒ Vapi::ClientMessageToolCallsToolWithToolCallListItem



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

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

.make(member:) ⇒ Vapi::ClientMessageToolCallsToolWithToolCallListItem



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

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

.text_editor(member:) ⇒ Vapi::ClientMessageToolCallsToolWithToolCallListItem



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

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.

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/client_message_tool_calls_tool_with_tool_call_list_item.rb', line 84

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)
  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.

Parameters:

  • obj (Object)

Returns:

  • (Boolean)


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

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

#kind_of?Object



19
# File 'lib/vapi_server_sdk/types/client_message_tool_calls_tool_with_tool_call_list_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/client_message_tool_calls_tool_with_tool_call_list_item.rb', line 58

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
  else
    { "type": @discriminant, value: @member }.to_json
  end
  @member.to_json
end