Class: Vapi::ServerMessageToolCalls

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tool_with_tool_call_list:, tool_call_list:, phone_number: OMIT, timestamp: OMIT, artifact: OMIT, assistant: OMIT, customer: OMIT, call: OMIT, chat: OMIT, additional_properties: nil) ⇒ Vapi::ServerMessageToolCalls



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

def initialize(tool_with_tool_call_list:, tool_call_list:, phone_number: OMIT, timestamp: OMIT, artifact: OMIT, assistant: OMIT,
               customer: OMIT, call: OMIT, chat: OMIT, additional_properties: nil)
  @phone_number = phone_number if phone_number != OMIT
  @tool_with_tool_call_list = tool_with_tool_call_list
  @timestamp = timestamp if timestamp != OMIT
  @artifact = artifact if artifact != OMIT
  @assistant = assistant if assistant != OMIT
  @customer = customer if customer != OMIT
  @call = call if call != OMIT
  @chat = chat if chat != OMIT
  @tool_call_list = tool_call_list
  @additional_properties = additional_properties
  @_field_set = {
    "phoneNumber": phone_number,
    "toolWithToolCallList": tool_with_tool_call_list,
    "timestamp": timestamp,
    "artifact": artifact,
    "assistant": assistant,
    "customer": customer,
    "call": call,
    "chat": chat,
    "toolCallList": tool_call_list
  }.reject do |_k, v|
    v == OMIT
  end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)



37
38
39
# File 'lib/vapi_server_sdk/types/server_message_tool_calls.rb', line 37

def additional_properties
  @additional_properties
end

#artifactVapi::Artifact (readonly)



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

def artifact
  @artifact
end

#assistantVapi::CreateAssistantDto (readonly)



27
28
29
# File 'lib/vapi_server_sdk/types/server_message_tool_calls.rb', line 27

def assistant
  @assistant
end

#callVapi::Call (readonly)



31
32
33
# File 'lib/vapi_server_sdk/types/server_message_tool_calls.rb', line 31

def call
  @call
end

#chatVapi::Chat (readonly)



33
34
35
# File 'lib/vapi_server_sdk/types/server_message_tool_calls.rb', line 33

def chat
  @chat
end

#customerVapi::CreateCustomerDto (readonly)



29
30
31
# File 'lib/vapi_server_sdk/types/server_message_tool_calls.rb', line 29

def customer
  @customer
end

#phone_numberVapi::ServerMessageToolCallsPhoneNumber (readonly)



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

def phone_number
  @phone_number
end

#timestampFloat (readonly)



22
23
24
# File 'lib/vapi_server_sdk/types/server_message_tool_calls.rb', line 22

def timestamp
  @timestamp
end

#tool_call_listArray<Vapi::ToolCall> (readonly)



35
36
37
# File 'lib/vapi_server_sdk/types/server_message_tool_calls.rb', line 35

def tool_call_list
  @tool_call_list
end

#tool_with_tool_call_listArray<Vapi::ServerMessageToolCallsToolWithToolCallListItem> (readonly)



20
21
22
# File 'lib/vapi_server_sdk/types/server_message_tool_calls.rb', line 20

def tool_with_tool_call_list
  @tool_with_tool_call_list
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::ServerMessageToolCalls

Deserialize a JSON object to an instance of ServerMessageToolCalls



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/vapi_server_sdk/types/server_message_tool_calls.rb', line 88

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  if parsed_json["phoneNumber"].nil?
    phone_number = nil
  else
    phone_number = parsed_json["phoneNumber"].to_json
    phone_number = Vapi::ServerMessageToolCallsPhoneNumber.from_json(json_object: phone_number)
  end
  tool_with_tool_call_list = parsed_json["toolWithToolCallList"]&.map do |item|
    item = item.to_json
    Vapi::ServerMessageToolCallsToolWithToolCallListItem.from_json(json_object: item)
  end
  timestamp = parsed_json["timestamp"]
  if parsed_json["artifact"].nil?
    artifact = nil
  else
    artifact = parsed_json["artifact"].to_json
    artifact = Vapi::Artifact.from_json(json_object: artifact)
  end
  if parsed_json["assistant"].nil?
    assistant = nil
  else
    assistant = parsed_json["assistant"].to_json
    assistant = Vapi::CreateAssistantDto.from_json(json_object: assistant)
  end
  if parsed_json["customer"].nil?
    customer = nil
  else
    customer = parsed_json["customer"].to_json
    customer = Vapi::CreateCustomerDto.from_json(json_object: customer)
  end
  if parsed_json["call"].nil?
    call = nil
  else
    call = parsed_json["call"].to_json
    call = Vapi::Call.from_json(json_object: call)
  end
  if parsed_json["chat"].nil?
    chat = nil
  else
    chat = parsed_json["chat"].to_json
    chat = Vapi::Chat.from_json(json_object: chat)
  end
  tool_call_list = parsed_json["toolCallList"]&.map do |item|
    item = item.to_json
    Vapi::ToolCall.from_json(json_object: item)
  end
  new(
    phone_number: phone_number,
    tool_with_tool_call_list: tool_with_tool_call_list,
    timestamp: timestamp,
    artifact: artifact,
    assistant: assistant,
    customer: customer,
    call: call,
    chat: chat,
    tool_call_list: tool_call_list,
    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.


163
164
165
166
167
168
169
170
171
172
173
# File 'lib/vapi_server_sdk/types/server_message_tool_calls.rb', line 163

def self.validate_raw(obj:)
  obj.phone_number.nil? || Vapi::ServerMessageToolCallsPhoneNumber.validate_raw(obj: obj.phone_number)
  obj.tool_with_tool_call_list.is_a?(Array) != false || raise("Passed value for field obj.tool_with_tool_call_list is not the expected type, validation failed.")
  obj.timestamp&.is_a?(Float) != false || raise("Passed value for field obj.timestamp is not the expected type, validation failed.")
  obj.artifact.nil? || Vapi::Artifact.validate_raw(obj: obj.artifact)
  obj.assistant.nil? || Vapi::CreateAssistantDto.validate_raw(obj: obj.assistant)
  obj.customer.nil? || Vapi::CreateCustomerDto.validate_raw(obj: obj.customer)
  obj.call.nil? || Vapi::Call.validate_raw(obj: obj.call)
  obj.chat.nil? || Vapi::Chat.validate_raw(obj: obj.chat)
  obj.tool_call_list.is_a?(Array) != false || raise("Passed value for field obj.tool_call_list is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of ServerMessageToolCalls to a JSON object



153
154
155
# File 'lib/vapi_server_sdk/types/server_message_tool_calls.rb', line 153

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