Class: Vapi::UpdateFunctionToolDto

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(messages: OMIT, async: OMIT, server: OMIT, function: OMIT, additional_properties: nil) ⇒ Vapi::UpdateFunctionToolDto



83
84
85
86
87
88
89
90
91
92
# File 'lib/vapi_server_sdk/types/update_function_tool_dto.rb', line 83

def initialize(messages: OMIT, async: OMIT, server: OMIT, function: OMIT, additional_properties: nil)
  @messages = messages if messages != OMIT
  @async = async if async != OMIT
  @server = server if server != OMIT
  @function = function if function != OMIT
  @additional_properties = additional_properties
  @_field_set = { "messages": messages, "async": async, "server": server, "function": function }.reject do |_k, v|
    v == OMIT
  end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)



45
46
47
# File 'lib/vapi_server_sdk/types/update_function_tool_dto.rb', line 45

def additional_properties
  @additional_properties
end

#asyncBoolean (readonly)



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

def async
  @async
end

#functionVapi::OpenAiFunction (readonly)



43
44
45
# File 'lib/vapi_server_sdk/types/update_function_tool_dto.rb', line 43

def function
  @function
end

#messagesArray<Vapi::UpdateFunctionToolDtoMessagesItem> (readonly)



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

def messages
  @messages
end

#serverVapi::Server (readonly)



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

def server
  @server
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::UpdateFunctionToolDto

Deserialize a JSON object to an instance of UpdateFunctionToolDto



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
# File 'lib/vapi_server_sdk/types/update_function_tool_dto.rb', line 98

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  messages = parsed_json["messages"]&.map do |item|
    item = item.to_json
    Vapi::UpdateFunctionToolDtoMessagesItem.from_json(json_object: item)
  end
  async = parsed_json["async"]
  if parsed_json["server"].nil?
    server = nil
  else
    server = parsed_json["server"].to_json
    server = Vapi::Server.from_json(json_object: server)
  end
  if parsed_json["function"].nil?
    function = nil
  else
    function = parsed_json["function"].to_json
    function = Vapi::OpenAiFunction.from_json(json_object: function)
  end
  new(
    messages: messages,
    async: async,
    server: server,
    function: function,
    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.


140
141
142
143
144
145
# File 'lib/vapi_server_sdk/types/update_function_tool_dto.rb', line 140

def self.validate_raw(obj:)
  obj.messages&.is_a?(Array) != false || raise("Passed value for field obj.messages is not the expected type, validation failed.")
  obj.async&.is_a?(Boolean) != false || raise("Passed value for field obj.async is not the expected type, validation failed.")
  obj.server.nil? || Vapi::Server.validate_raw(obj: obj.server)
  obj.function.nil? || Vapi::OpenAiFunction.validate_raw(obj: obj.function)
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of UpdateFunctionToolDto to a JSON object



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

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