Class: Vapi::ToolMessageComplete

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(contents: OMIT, role: OMIT, end_call_after_spoken_enabled: OMIT, content: OMIT, conditions: OMIT, additional_properties: nil) ⇒ Vapi::ToolMessageComplete



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

def initialize(contents: OMIT, role: OMIT, end_call_after_spoken_enabled: OMIT, content: OMIT, conditions: OMIT,
               additional_properties: nil)
  @contents = contents if contents != OMIT
  @role = role if role != OMIT
  @end_call_after_spoken_enabled = end_call_after_spoken_enabled if end_call_after_spoken_enabled != OMIT
  @content = content if content != OMIT
  @conditions = conditions if conditions != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "contents": contents,
    "role": role,
    "endCallAfterSpokenEnabled": end_call_after_spoken_enabled,
    "content": content,
    "conditions": conditions
  }.reject do |_k, v|
    v == OMIT
  end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)



48
49
50
# File 'lib/vapi_server_sdk/types/tool_message_complete.rb', line 48

def additional_properties
  @additional_properties
end

#conditionsArray<Vapi::Condition> (readonly)



46
47
48
# File 'lib/vapi_server_sdk/types/tool_message_complete.rb', line 46

def conditions
  @conditions
end

#contentString (readonly)



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

def content
  @content
end

#contentsArray<Vapi::TextContent> (readonly)



19
20
21
# File 'lib/vapi_server_sdk/types/tool_message_complete.rb', line 19

def contents
  @contents
end

#end_call_after_spoken_enabledBoolean (readonly)



41
42
43
# File 'lib/vapi_server_sdk/types/tool_message_complete.rb', line 41

def end_call_after_spoken_enabled
  @end_call_after_spoken_enabled
end

#roleVapi::ToolMessageCompleteRole (readonly)



36
37
38
# File 'lib/vapi_server_sdk/types/tool_message_complete.rb', line 36

def role
  @role
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::ToolMessageComplete

Deserialize a JSON object to an instance of ToolMessageComplete



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/vapi_server_sdk/types/tool_message_complete.rb', line 111

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  contents = parsed_json["contents"]&.map do |item|
    item = item.to_json
    Vapi::TextContent.from_json(json_object: item)
  end
  role = parsed_json["role"]
  end_call_after_spoken_enabled = parsed_json["endCallAfterSpokenEnabled"]
  content = parsed_json["content"]
  conditions = parsed_json["conditions"]&.map do |item|
    item = item.to_json
    Vapi::Condition.from_json(json_object: item)
  end
  new(
    contents: contents,
    role: role,
    end_call_after_spoken_enabled: end_call_after_spoken_enabled,
    content: content,
    conditions: conditions,
    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.


148
149
150
151
152
153
154
# File 'lib/vapi_server_sdk/types/tool_message_complete.rb', line 148

def self.validate_raw(obj:)
  obj.contents&.is_a?(Array) != false || raise("Passed value for field obj.contents is not the expected type, validation failed.")
  obj.role&.is_a?(Vapi::ToolMessageCompleteRole) != false || raise("Passed value for field obj.role is not the expected type, validation failed.")
  obj.end_call_after_spoken_enabled&.is_a?(Boolean) != false || raise("Passed value for field obj.end_call_after_spoken_enabled is not the expected type, validation failed.")
  obj.content&.is_a?(String) != false || raise("Passed value for field obj.content is not the expected type, validation failed.")
  obj.conditions&.is_a?(Array) != false || raise("Passed value for field obj.conditions is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of ToolMessageComplete to a JSON object



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

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